diff options
author | midipix <writeonce@midipix.org> | 2024-05-14 23:20:38 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2024-05-15 04:57:14 +0000 |
commit | 6291ad9865afff38f6cb96906ff8afade950b868 (patch) | |
tree | 17a867d99aac7bb1dd9c0511fd44930bafa02f73 /include | |
parent | 02e59c946d51faf976a85610e44d7b0ccf4a6e59 (diff) | |
download | treebnf-6291ad9865afff38f6cb96906ff8afade950b868.tar.bz2 treebnf-6291ad9865afff38f6cb96906ff8afade950b868.tar.xz |
library api: added token scanner definitions and structures.
Diffstat (limited to 'include')
-rw-r--r-- | include/treebnf/treebnf.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/include/treebnf/treebnf.h b/include/treebnf/treebnf.h index c10f115..1a8db27 100644 --- a/include/treebnf/treebnf.h +++ b/include/treebnf/treebnf.h @@ -24,6 +24,11 @@ extern "C" { #define TBNF_USAGE 0x01 #define TBNF_ERROR 0x02 +/* token scanner state ops */ +#define TBNF_STATE_POP (-1) +#define TBNF_STATE_KEEP ( 0) +#define TBNF_STATE_PUSH (+1) + /* driver flags */ #define TBNF_DRIVER_XFLAG(x) ((uint64_t)(x) << 32) @@ -51,6 +56,39 @@ enum tbnf_custom_error { TBNF_ERR_IMAGE_SIZE_ZERO, }; +/* token api structures */ +struct tbnf_token; +struct tbnf_scan_tbl; +struct tbnf_scan_ctx; + +struct tbnf_token { + int tok_type; + int tok_len; + int tok_off; + int tok_any; +}; + +struct tbnf_scan_tbl { + int (*tok_scan_fn)(const struct tbnf_scan_ctx *); + int tok_state_op; + int tok_state_next; +}; + +struct tbnf_scan_ctx { + const char * tok_scan_base; + const char * tok_scan_mark; + const char * tok_scan_cap; + int tok_scan_type; + int tok_scan_state; + int tok_scan_nents; + int tok_scan_ntbls; + struct tbnf_scan_tbl ** tok_scan_tbls; +}; + + + + + struct tbnf_raw_input { void * map_addr; size_t map_size; |