35 err = callbacks->
init(scan, &scanner);
42 state = callbacks->
scan(text.text, text.
length, scanner);
48 err = callbacks->
parse(scanner, scan);
58 return parse_value(tree);
CT_NODISCARD CT_PUREFN CT_SCAN_API void * scan_get(scan_t *scan)
get the compiled object from a scanner
CT_NODISCARD CT_PUREFN CT_SCAN_API text_view_t scan_source(const scan_t *scan)
get a text span of the scanners contents
#define STA_DECL
sal2 annotation on function implementations to copy annotations from the declaration
STA_DECL parse_result_t scan_buffer(scan_t *scan, const scan_callbacks_t *callbacks)
parse the contents of a scanner into a language specific ast
@ eParseInitError
error initializing the scanner internals (our fault)
@ eParseOk
parse was successful
@ eParseScanError
entered invalid state during scanning (our fault)
@ eParseReject
failed due to invalid input (users fault)
#define CTASSERT(expr)
assert a condition, prints the condition as a message
scanner function callbacks for flex and bison
void(* destroy_buffer)(void *buffer, void *scanner)
yy_delete_buffer
int(* parse)(void *scanner, scan_t *extra)
yyparse
void *(* scan)(const char *text, size_t size, void *scanner)
yy_scan_bytes
void(* destroy)(void *scanner)
yylex_destroy
int(* init)(scan_t *extra, void *scanner)
yylex_init_extra
a non-owning view of text
size_t length
the number of characters in the text