aboutsummaryrefslogtreecommitdiff
path: root/demos/generate-parser.c
diff options
context:
space:
mode:
authorkartofen <mladenovnasko0@gmail.com>2025-07-05 12:14:27 +0300
committerkartofen <mladenovnasko0@gmail.com>2025-07-05 12:14:27 +0300
commit0e0c0e0f26fcd669e45604fd5d9bcc2891a932a2 (patch)
treef57eb9f80883bdab57d00a97ad97508ecdbb0c2d /demos/generate-parser.c
parentf2bef76fb369d4c9c3e53dca60eb78b75bb02d97 (diff)
lalr now acutally works
Diffstat (limited to 'demos/generate-parser.c')
-rw-r--r--demos/generate-parser.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/demos/generate-parser.c b/demos/generate-parser.c
index fc022be..8d50ad6 100644
--- a/demos/generate-parser.c
+++ b/demos/generate-parser.c
@@ -16,20 +16,19 @@ size_t total_productions;
#include "util-tables.c"
-// _LAZY_LALR on clr does not work??
-#include "slr-table.c"
+#define _LAZY_LALR
+#include "clr-table.c"
void *xdlsym(void *handle, char *sym)
{
void *r = dlsym(handle, sym);
if(!r) {
- fprintf(stderr, "ERROR: Symbol \"%s\" was not found\n", sym);
+ fprintf(stderr, "ERROR: Symbol '%s' was not found\n", sym);
exit(1);
}
return r;
}
-
#define GET_VARIABLE(var, handle) \
var = *(typeof(&var))xdlsym(handle, #var)
@@ -46,12 +45,11 @@ int main(int argc, char **argv)
GET_VARIABLE(symbol_is_valid, handle);
GET_VARIABLE(grammar, handle);
GET_VARIABLE(total_productions, handle);
-
util_tables_fill();
- table_fill() && (exit(1), 1);
+ table_fill() && (fprintf(stderr, "ERROR: Table couldn't be generated\n"), exit(1), 1);
printf("size_t total_symbols = %zu;\n", total_symbols);
- printf("IMPLEMENT_FUNCPTR(int, symbol_is_valid, (symbol s), {return s >= 0 && s < total_symbols;})\n");
+ printf("IMPLEMENT_FUNCPTR(int, symbol_is_valid, (symbol s), {return s < total_symbols;})\n");
printf("struct production _grammar[] = {\n");
grammar_print_cstyle();