19 #ifndef PS_LEXER_MAX_ERRORS
22 #define PS_LEXER_MAX_ERRORS 5
51 #define ps_lexer_next_are(next, n) _ps_lexer_next_are(next, n)
56 #define ps_lexer_next_are_lit(next) \
57 _ps_lexer_next_are(next, sizeof(next) - 1)
Defines safe file I/O functions.
void ps_add_token(enum ps_token_type type, usize length)
bool ps_lexer_is_eof(void)
Checks whether the lexer is at the end of input.
void ps_lexer_advance(void)
Advances past one character in the lexer.
void ps_add_token_with_loc(enum ps_token_type type, usize length, struct ps_loc loc)
void ps_lexer_advance_n(usize n)
Advances past the next n characters in the lexer, updating internal state as necessary.
static void usize struct ps_loc loc
struct ps_token_arr * ps_lex(const struct ps_file_ctx *file_ctx)
Lexes the given source code into tokens.
Information captured in a file necessary for effective info/error reporting.
Represents lexer state for a single file.
struct ps_loc loc
The current location of the lexer.
usize length
The length of the file.
usize par_nesting
Nesting level of parentheses.
STR code
The source code of the file.
bool is_string_escaped
Whether the next character in the string should be escaped.
usize interp_par_nesting
The nesting of parentheses at the start of string interpolation.
bool in_comment
Whether the lexer is currently in a comment.
bool interp_string
Whether the lexer is currrently in an interpolated string.
struct ps_token_arr * tokens
The token array.
struct ps_string_arr * defines
Represents a token location.
ps_token_type
The type of a token.