diff options
author | kartofen <mladenovnasko0@gmail.com> | 2025-07-09 22:49:24 +0300 |
---|---|---|
committer | kartofen <mladenovnasko0@gmail.com> | 2025-07-09 22:49:24 +0300 |
commit | d69d2e7a7e09c4f08cd416241e2f2d9dc7d7d05f (patch) | |
tree | d8b32a0749e79ddc79ce998a382ee7dc06f0a175 /slr-table.c | |
parent | 2c85f2d087b9b2f3922b856beed4e2dd5b0fc126 (diff) |
untested precednece lol
Diffstat (limited to 'slr-table.c')
-rw-r--r-- | slr-table.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/slr-table.c b/slr-table.c index 4e12efd..ac90755 100644 --- a/slr-table.c +++ b/slr-table.c @@ -28,7 +28,7 @@ static jmp_buf fail_jmpbuf; static void table_allocate() { for(size_t i = 0; i < TABLE_CAP; i++) table[i] = xcalloc(total_symbols, sizeof(*table[i])); } static void table_deallocate() { for(size_t i = 0; i < TABLE_CAP; i++) free(table[i]); } -static int table_insert(size_t state, symbol sym, struct action a); +// static int table_insert(size_t state, symbol sym, struct action a); // in table.h struct item { size_t prod_idx; @@ -185,20 +185,6 @@ cleanup: return nout; } -static int table_insert(size_t state, symbol sym, struct action a) -{ - if(table[state][sym].type != ACTION_NOT_SET) { - fprintf(stderr, "TABLE COLLISION on state '%zu' sym '%d'\n", state, sym); - fprintf(stderr, "\t{%d %zu} vs {%d %zu}\n", - table[state][sym].type, table[state][sym].arg, - a.type, a.arg); - return 1; - } - - table[state][sym] = a; - return 0; -} - IMPLEMENT_FUNCPTR(int, table_fill, ()) { table_allocate(); @@ -235,7 +221,7 @@ 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)} +#define PROD(LHS, _, ...) {LHS, (symbol[]){__VA_ARGS__}, sizeof((symbol[]){__VA_ARGS__})/sizeof(symbol), 0} static struct production _grammar[] = { PROD(EP, ->, E, END_INPUT), PROD(E, -->, E, PLUS, T), |