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);
60size_t pm_strrspn_whitespace(
const uint8_t *
string, ptrdiff_t length);
67size_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);
73size_t pm_strspn_decimal_digit(
const uint8_t *
string, ptrdiff_t length);
80size_t pm_strspn_hexadecimal_digit(
const uint8_t *
string, ptrdiff_t length);
91size_t pm_strspn_octal_number(
const uint8_t *
string, ptrdiff_t length,
const uint8_t **invalid);
102size_t pm_strspn_decimal_number(
const uint8_t *
string, ptrdiff_t length,
const uint8_t **invalid);
113size_t pm_strspn_hexadecimal_number(
const uint8_t *
string, ptrdiff_t length,
const uint8_t **invalid);
119size_t pm_strspn_regexp_option(
const uint8_t *
string, ptrdiff_t length);
130size_t pm_strspn_binary_number(
const uint8_t *
string, ptrdiff_t length,
const uint8_t **invalid);
134bool pm_char_is_binary_digit(
const uint8_t b);
137bool pm_char_is_octal_digit(
const uint8_t b);
140bool pm_char_is_decimal_digit(
const uint8_t b);
143bool 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.
C99 shim for <stdbool.h>.
A list of offsets of the start of lines in a string.