This field is only used to see if we have found the start symbol yet,
and that can be done using "production_count".
Further, that value actually stored here is "-1" as symbol numbers
haven't been assigned yet.
So discard 'start'. We know that the real 'start' symbol is whatever
starts production '0'.
Signed-off-by: NeilBrown <neilb@suse.de>
p->head->type = Nonterminal;
array_add(&p->body, &p->body_size, head);
array_add(&p->body, &p->body_size, sym_find(g, eof));
p->head->type = Nonterminal;
array_add(&p->body, &p->body_size, head);
array_add(&p->body, &p->body_size, sym_find(g, eof));
- g->start = p->head->num;
p->head->first_production = g->production_count;
array_add(&g->productions, &g->production_count, p);
Now we are ready to read in the grammar.
p->head->first_production = g->production_count;
array_add(&g->productions, &g->production_count, p);
Now we are ready to read in the grammar.
-###### grammar fields
- int start; // the 'start' symbol.
-
###### grammar_read
static struct grammar *grammar_read(struct code_node *code)
{
###### grammar_read
static struct grammar *grammar_read(struct code_node *code)
{
else {
head->type = Nonterminal;
head->struct_name = g->current_type;
else {
head->type = Nonterminal;
head->struct_name = g->current_type;
+ if (g->production_count == 0) {
## create production zero
}
head->first_production = g->production_count;
## create production zero
}
head->first_production = g->production_count;