virtual symbols are used internally to parsergen
and of no interest to the parser. So they shouldn't
appear in the non_term[] array.
So assign them higher numbers so the nonterminals are dense, and only
include non-virtual non-terminals in the non_term[] array.
Signed-off-by: NeilBrown <neil@brown.name>
snum++;
}
g->first_nonterm = snum;
+ for (s = g->syms; s; s = s->next)
+ if (s->num < 0 && s->type != Virtual) {
+ s->num = snum;
+ snum++;
+ }
for (s = g->syms; s; s = s->next)
if (s->num < 0) {
s->num = snum;
for (i = TK_reserved;
i < g->num_syms;
i++)
- if (g->symtab[i]->type != Terminal)
+ if (g->symtab[i]->type == Nonterminal)
fprintf(f, "\t\"%.*s\",\n", g->symtab[i]->name.len,
g->symtab[i]->name.txt);
fprintf(f, "};\n\n");