aboutsummaryrefslogtreecommitdiff
path: root/clr-table.c
diff options
context:
space:
mode:
authorkartofen <kartofen.mail.0@protonmail.com>2025-07-03 19:11:36 +0300
committerkartofen <kartofen.mail.0@protonmail.com>2025-07-03 19:11:36 +0300
commit98254bbeb96e1c868d761e81f39f59744a6837c6 (patch)
tree94de181d7dae1d35310e1e9bfbf761b0fc536adf /clr-table.c
parent67447ebd3a51a9af29d18a53a38aba038a0c039e (diff)
working more or less parser generator (no semantic action, so pretty much useless
Diffstat (limited to 'clr-table.c')
-rw-r--r--clr-table.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/clr-table.c b/clr-table.c
index 37b2cd6..82f553d 100644
--- a/clr-table.c
+++ b/clr-table.c
@@ -268,12 +268,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[] = {
#if (CHOOSE_GRAMMAR == 0)
PROD(EP, ->, E, END_INPUT),
PROD(E, -->, L, EQUAL, R),
@@ -289,7 +289,8 @@ struct production grammar[] = {
#endif
};
-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"