1#ifndef PRISM_INTERNAL_CHAR_H
2#define PRISM_INTERNAL_CHAR_H
14#define PRISM_CHAR_BIT_WHITESPACE (1 << 0)
17#define PRISM_CHAR_BIT_INLINE_WHITESPACE (1 << 1)
23extern const uint8_t pm_byte_table[256];
27pm_char_is_whitespace(
const uint8_t b) {
28 return (pm_byte_table[b] & PRISM_CHAR_BIT_WHITESPACE) != 0;
33pm_char_is_inline_whitespace(
const uint8_t b) {
34 return (pm_byte_table[b] & PRISM_CHAR_BIT_INLINE_WHITESPACE) != 0;
42pm_strspn_inline_whitespace(
const uint8_t *
string, ptrdiff_t length) {
43 if (length <= 0)
return 0;
45 size_t maximum = (size_t) length;
46 while (size < maximum && (pm_byte_table[
string[size]] & PRISM_CHAR_BIT_INLINE_WHITESPACE)) size++;
54size_t pm_strspn_whitespace(
const uint8_t *
string, ptrdiff_t length);
61size_t pm_strspn_whitespace_newlines(
const uint8_t *
string, ptrdiff_t length,
pm_arena_t *arena,
pm_line_offset_list_t *line_offsets, uint32_t start_offset);
67size_t pm_strspn_decimal_digit(
const uint8_t *
string, ptrdiff_t length);
74size_t pm_strspn_hexadecimal_digit(
const uint8_t *
string, ptrdiff_t length);
85size_t pm_strspn_octal_number(
const uint8_t *
string, ptrdiff_t length,
const uint8_t **invalid);
96size_t pm_strspn_decimal_number(
const uint8_t *
string, ptrdiff_t length,
const uint8_t **invalid);
107size_t pm_strspn_hexadecimal_number(
const uint8_t *
string, ptrdiff_t length,
const uint8_t **invalid);
113size_t pm_strspn_regexp_option(
const uint8_t *
string, ptrdiff_t length);
124size_t pm_strspn_binary_number(
const uint8_t *
string, ptrdiff_t length,
const uint8_t **invalid);
128bool pm_char_is_binary_digit(
const uint8_t b);
131bool pm_char_is_octal_digit(
const uint8_t b);
134bool pm_char_is_decimal_digit(
const uint8_t b);
137bool pm_char_is_hexadecimal_digit(
const uint8_t b);
A bump allocator for the prism parser.
#define PRISM_FORCE_INLINE
Force a function to be inlined at every call site.
A list of byte offsets of newlines in a string.
A list of offsets of the start of lines in a string.