gen/
.clang-format
570 B
.gitignore
30 B
.gitsigners
112 B
LICENSE
1.1 KiB
Makefile
911 B
README
1.8 KiB
ast.c
5.0 KiB
ast.h
15.1 KiB
desugar.c
23.1 KiB
desugar.h
286 B
gen.c
108.5 KiB
gen.h
4.9 KiB
io.c
1.1 KiB
io.h
444 B
limits.h
1.3 KiB
module.c
10.0 KiB
module.h
2.2 KiB
options.c
1.4 KiB
options.h
472 B
parser.c
68.3 KiB
parser.h
942 B
radiance.c
3.7 KiB
ralloc.c
2.0 KiB
ralloc.h
1.1 KiB
resolver.c
109.7 KiB
resolver.h
5.6 KiB
riscv.c
12.0 KiB
riscv.h
12.0 KiB
scanner.c
10.2 KiB
scanner.h
3.2 KiB
strings.c
2.6 KiB
strings.h
407 B
symtab.c
5.7 KiB
symtab.h
4.6 KiB
types.h
1.0 KiB
util.h
1.5 KiB
parser.h
raw
| 1 | #ifndef PARSER_H |
| 2 | #define PARSER_H |
| 3 | |
| 4 | #include "ast.h" |
| 5 | #include "limits.h" |
| 6 | #include "scanner.h" |
| 7 | |
| 8 | /* Parsing context to handle ambiguities */ |
| 9 | typedef enum { |
| 10 | PARSE_CTX_NORMAL, /* Normal expression context */ |
| 11 | PARSE_CTX_CONDITION, /* Inside condition where { starts block */ |
| 12 | } parse_ctx_t; |
| 13 | |
| 14 | /* Parser state */ |
| 15 | typedef struct parser_t { |
| 16 | scanner_t scanner; |
| 17 | token_t current; |
| 18 | token_t previous; |
| 19 | node_t *root; |
| 20 | u32 errors; |
| 21 | node_t nodes[MAX_NODES]; |
| 22 | u32 nnodes; |
| 23 | parse_ctx_t context; |
| 24 | |
| 25 | /* Pool for variable-length node pointer arrays. |
| 26 | * Nodes store an index + count into this pool instead of |
| 27 | * embedding large arrays, keeping node_t small. */ |
| 28 | struct node_t *ptrs[MAX_NODEPTR_POOL]; |
| 29 | u32 nptrs; |
| 30 | } parser_t; |
| 31 | |
| 32 | /* Initialize parser with scanner */ |
| 33 | void parser_init(parser_t *p); |
| 34 | |
| 35 | /* Parse a complete program */ |
| 36 | node_t *parser_parse(parser_t *p); |
| 37 | |
| 38 | #endif |