#ifndef GRAMMAR_H #define GRAMMAR_H #include // size_t extern struct production { symbol LHS; symbol *RHS; size_t nRHS; } *grammar; extern size_t total_productions; #include void grammar_print() { for(size_t i = 0; i < total_productions; i++) { printf("%d --> ", grammar[i].LHS); for(size_t j = 0; j < grammar[i].nRHS; j++) printf("%d ", grammar[i].RHS[j]); 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