]> ocean-lang.org Git - ocean/commitdiff
parsergen: remove unused 'start' field from grammar.
authorNeilBrown <neilb@suse.de>
Sun, 11 May 2014 04:57:10 +0000 (14:57 +1000)
committerNeilBrown <neilb@suse.de>
Sun, 15 Jun 2014 07:13:10 +0000 (17:13 +1000)
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>
csrc/parsergen.mdc

index 9def0826d5ea57ac6b333f74c5bbe3767f78de59..819396551cf265c1a97293f018d6ff4f873df55e 100644 (file)
@@ -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;