From b944d50308a919178d83d52685aab433c99e1ac1 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sun, 11 May 2014 14:57:10 +1000 Subject: [PATCH] parsergen: remove unused 'start' field from grammar. 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 --- csrc/parsergen.mdc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/csrc/parsergen.mdc b/csrc/parsergen.mdc index 9def082..8193965 100644 --- a/csrc/parsergen.mdc +++ b/csrc/parsergen.mdc @@ -541,15 +541,11 @@ where `START` is the first non-terminal given. 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. -###### grammar fields - int start; // the 'start' symbol. - ###### grammar_read static struct grammar *grammar_read(struct code_node *code) { @@ -591,7 +587,7 @@ Now we are ready to read in the grammar. else { head->type = Nonterminal; head->struct_name = g->current_type; - if (g->start == 0) { + if (g->production_count == 0) { ## create production zero } head->first_production = g->production_count; -- 2.43.0