Ruby: prism/util/pm_char.h Source File

Ruby 3.4.4p34 (2025-05-14 revision a38531fd3f617bf734ef7d6c595325f69985ea1d)

pm_char.h
Go to the documentation of this file.
1
6#ifndef PRISM_CHAR_H
7#define PRISM_CHAR_H
8
9#include "prism/defines.h"
10#include "prism/util/pm_newline_list.h"
11
12#include <stdbool.h>
13#include <stddef.h>
14
24size_t pm_strspn_whitespace(const uint8_t *string, ptrdiff_t length);
25
37size_t pm_strspn_whitespace_newlines(const uint8_t *string, ptrdiff_t length, pm_newline_list_t *newline_list);
38
48size_t pm_strspn_inline_whitespace(const uint8_t *string, ptrdiff_t length);
49
59size_t pm_strspn_decimal_digit(const uint8_t *string, ptrdiff_t length);
60
71size_t pm_strspn_hexadecimal_digit(const uint8_t *string, ptrdiff_t length);
72
89size_t pm_strspn_octal_number(const uint8_t *string, ptrdiff_t length, const uint8_t **invalid);
90
107size_t pm_strspn_decimal_number(const uint8_t *string, ptrdiff_t length, const uint8_t **invalid);
108
125size_t pm_strspn_hexadecimal_number(const uint8_t *string, ptrdiff_t length, const uint8_t **invalid);
126
136size_t pm_strspn_regexp_option(const uint8_t *string, ptrdiff_t length);
137
154size_t pm_strspn_binary_number(const uint8_t *string, ptrdiff_t length, const uint8_t **invalid);
155
162bool pm_char_is_whitespace(const uint8_t b);
163
170bool pm_char_is_inline_whitespace(const uint8_t b);
171
178bool pm_char_is_binary_digit(const uint8_t b);
179
186bool pm_char_is_octal_digit(const uint8_t b);
187
194bool pm_char_is_decimal_digit(const uint8_t b);
195
202bool pm_char_is_hexadecimal_digit(const uint8_t b);
203
204#endif
pm_strspn_hexadecimal_digit
size_t pm_strspn_hexadecimal_digit(const uint8_t *string, ptrdiff_t length)
Returns the number of characters at the start of the string that are hexadecimal digits.
Definition pm_char.c:249
pm_char_is_decimal_digit
bool pm_char_is_decimal_digit(const uint8_t b)
Returns true if the given character is a decimal digit.
Definition pm_char.c:295
pm_strspn_whitespace
size_t pm_strspn_whitespace(const uint8_t *string, ptrdiff_t length)
Returns the number of characters at the start of the string that are whitespace.
Definition pm_char.c:76
pm_strspn_hexadecimal_number
size_t pm_strspn_hexadecimal_number(const uint8_t *string, ptrdiff_t length, const uint8_t **invalid)
Returns the number of characters at the start of the string that are hexadecimal digits or underscore...
Definition pm_char.c:263
pm_strspn_decimal_number
size_t pm_strspn_decimal_number(const uint8_t *string, ptrdiff_t length, const uint8_t **invalid)
Returns the number of characters at the start of the string that are decimal digits or underscores.
Definition pm_char.c:239
pm_strspn_decimal_digit
size_t pm_strspn_decimal_digit(const uint8_t *string, ptrdiff_t length)
Returns the number of characters at the start of the string that are decimal digits.
Definition pm_char.c:225
pm_strspn_binary_number
size_t pm_strspn_binary_number(const uint8_t *string, ptrdiff_t length, const uint8_t **invalid)
Returns the number of characters at the start of the string that are binary digits or underscores.
Definition pm_char.c:202
pm_strspn_octal_number
size_t pm_strspn_octal_number(const uint8_t *string, ptrdiff_t length, const uint8_t **invalid)
Returns the number of characters at the start of the string that are octal digits or underscores.
Definition pm_char.c:216
pm_strspn_whitespace_newlines
size_t pm_strspn_whitespace_newlines(const uint8_t *string, ptrdiff_t length, pm_newline_list_t *newline_list)
Returns the number of characters at the start of the string that are whitespace while also tracking t...
Definition pm_char.c:86
pm_char_is_hexadecimal_digit
bool pm_char_is_hexadecimal_digit(const uint8_t b)
Returns true if the given character is a hexadecimal digit.
Definition pm_char.c:303
pm_char_is_octal_digit
bool pm_char_is_octal_digit(const uint8_t b)
Returns true if the given character is an octal digit.
Definition pm_char.c:287
pm_char_is_binary_digit
bool pm_char_is_binary_digit(const uint8_t b)
Returns true if the given character is a binary digit.
Definition pm_char.c:279
pm_char_is_inline_whitespace
bool pm_char_is_inline_whitespace(const uint8_t b)
Returns true if the given character is an inline whitespace character.
Definition pm_char.c:141
pm_strspn_inline_whitespace
size_t pm_strspn_inline_whitespace(const uint8_t *string, ptrdiff_t length)
Returns the number of characters at the start of the string that are inline whitespace.
Definition pm_char.c:108
pm_char_is_whitespace
bool pm_char_is_whitespace(const uint8_t b)
Returns true if the given character is a whitespace character.
Definition pm_char.c:133
pm_strspn_regexp_option
size_t pm_strspn_regexp_option(const uint8_t *string, ptrdiff_t length)
Returns the number of characters at the start of the string that are regexp options.
Definition pm_char.c:117
pm_newline_list.h
A list of byte offsets of newlines in a string.
defines.h
Macro definitions used throughout the prism library.
stdbool.h
C99 shim for <stdbool.h>
pm_newline_list_t
A list of offsets of newlines in a string.
Definition pm_newline_list.h:28