diff options
author | kartofen <mladenovnasko0@gmail.com> | 2025-07-03 19:11:36 +0300 |
---|---|---|
committer | kartofen <mladenovnasko0@gmail.com> | 2025-07-03 19:11:36 +0300 |
commit | f2bef76fb369d4c9c3e53dca60eb78b75bb02d97 (patch) | |
tree | 94de181d7dae1d35310e1e9bfbf761b0fc536adf /slr-table.c | |
parent | 5064a7ebce75a26d0405c92040f1a40187fcc7e3 (diff) |
working more or less parser generator (no semantic action, so pretty much useless
Diffstat (limited to 'slr-table.c')
-rw-r--r-- | slr-table.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/slr-table.c b/slr-table.c index d5f4505..9bcdc3e 100644 --- a/slr-table.c +++ b/slr-table.c @@ -227,12 +227,12 @@ enum symbol { size_t total_symbols = SYMBOLS_END; -int symbol_is_terminal(symbol s) { return s < EP; } -int symbol_is_input_end(symbol s) { return s == END_INPUT; } +IMPLEMENT_FUNCPTR(int, symbol_is_terminal, (symbol s), { return s < EP; }) +IMPLEMENT_FUNCPTR(int, symbol_is_input_end, (symbol s), { return s == END_INPUT; }) // implement grammar.h #define PROD(LHS, _, ...) {LHS, (symbol[]){__VA_ARGS__}, sizeof((symbol[]){__VA_ARGS__})/sizeof(symbol)} -struct production grammar[] = { +static struct production _grammar[] = { PROD(EP, ->, E, END_INPUT), PROD(E, -->, E, PLUS, T), PROD(E, -->, E, MINUS, T), @@ -243,7 +243,8 @@ struct production grammar[] = { PROD(N, -->, N1), }; -const size_t total_productions = sizeof(grammar)/sizeof(*grammar); +struct production *grammar = _grammar; +size_t total_productions = sizeof(_grammar)/sizeof(*_grammar); // implement util-tables.h #include "util-tables.c" |