5 #include <ctu_interop_api.h>
29 void *(*scan)(
const char *text,
size_t size,
void *scanner);
42 #define CT_CALLBACKS(id, prefix) \
43 static int prefix##_##id##_##init(scan_t *extra, void *scanner) \
45 return prefix##lex_init_extra(extra, (yyscan_t *)scanner); \
47 static int prefix##_##id##_parse(void *scanner, scan_t *extra) \
49 return prefix##parse(scanner, (scan_t *)extra); \
51 static void *prefix##_##id##_scan(const char *text, size_t size, void *scanner) \
53 CTASSERTF(size <= INT_MAX, #prefix "_scan (size = %zu > %d, name = %s)", size, INT_MAX, \
54 scan_path((scan_t *)scanner)); \
55 return prefix##_scan_bytes(text, (int)size, scanner); \
57 static void prefix##_##id##_destroy_buffer(void *buffer, void *scanner) \
59 prefix##_delete_buffer((YY_BUFFER_STATE)buffer, scanner); \
61 static void prefix##_##id##_destroy(void *scanner) \
63 prefix##lex_destroy(scanner); \
65 static const scan_callbacks_t id = { \
66 .init = prefix##_##id##_##init, \
67 .parse = prefix##_##id##_parse, \
68 .scan = prefix##_##id##_scan, \
69 .destroy_buffer = prefix##_##id##_destroy_buffer, \
70 .destroy = prefix##_##id##_destroy, \
#define IN_NOTNULL
annotate a parameter as not being null
CT_INTEROP_API 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)
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(* destroy)(void *scanner)
yylex_destroy
int(* init)(scan_t *extra, void *scanner)
yylex_init_extra