aboutsummaryrefslogtreecommitdiff
path: root/demos/generate-parser.c
diff options
context:
space:
mode:
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();