diff options
Diffstat (limited to 'parts/grammar.h')
-rw-r--r-- | parts/grammar.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/parts/grammar.h b/parts/grammar.h index 328f88e..a02a99e 100644 --- a/parts/grammar.h +++ b/parts/grammar.h @@ -5,9 +5,9 @@ extern struct production { symbol LHS; symbol *RHS; size_t nRHS; -} grammar[]; +} *grammar; -extern const size_t total_productions; +extern size_t total_productions; void grammar_print() { @@ -18,5 +18,15 @@ void grammar_print() printf("\n"); } } +void grammar_print_cstyle() + +{ + for(size_t i = 0; i < total_productions; i++) { + printf("{%d, (symbol[]){", grammar[i].LHS); + for(size_t j = 0; j < grammar[i].nRHS; j++) + printf("%d, ", grammar[i].RHS[j]); + printf("}, %zu},\n", grammar[i].nRHS); + } +} #endif |