X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/5f7e08323a452b0b55ad94b8c866970a2929d9ad..e41dc70020f5101795c601729594de8661d616e2:/src/reader.c diff --git a/src/reader.c b/src/reader.c index 6206adca..5abb46ed 100644 --- a/src/reader.c +++ b/src/reader.c @@ -1251,20 +1251,6 @@ copy_guard (symbol_list *rule, int stack_offset) } -static void -record_rule_line (void) -{ - /* Record each rule's source line number in rline table. */ - - if (nrules >= rline_allocated) - { - rline_allocated = nrules * 2; - rline = XREALLOC (rline, short, rline_allocated); - } - rline[nrules] = lineno; -} - - /*-------------------------------------------------------------------. | Generate a dummy symbol, a nonterminal, whose name cannot conflict | | with the user's names. | @@ -1407,8 +1393,6 @@ readgram (void) nrules++; nitems++; - record_rule_line (); - p = XCALLOC (symbol_list, 1); p->sym = lhs; @@ -1486,7 +1470,6 @@ readgram (void) just read can belong to it. */ nrules++; nitems++; - record_rule_line (); p = XCALLOC (symbol_list, 1); if (crule1) crule1->next = p; @@ -1494,9 +1477,10 @@ readgram (void) grammar = p; p->sym = sdummy; crule1 = XCALLOC (symbol_list, 1); - p->next = crule1; crule1->next = crule; + p->next = crule1; + /* Insert the dummy generated by that rule into this rule. */ nitems++; @@ -1922,11 +1906,7 @@ packgram (void) bucket *ruleprec; ritem = XCALLOC (short, nitems + 1); - rlhs = XCALLOC (short, nrules) - 1; - rrhs = XCALLOC (short, nrules) - 1; - rprec = XCALLOC (short, nrules) - 1; - rprecsym = XCALLOC (short, nrules) - 1; - rassoc = XCALLOC (short, nrules) - 1; + rule_table = XCALLOC (rule_t, nrules) - 1; itemno = 0; ruleno = 1; @@ -1934,8 +1914,9 @@ packgram (void) p = grammar; while (p) { - rlhs[ruleno] = p->sym->value; - rrhs[ruleno] = itemno; + rule_table[ruleno].lhs = p->sym->value; + rule_table[ruleno].rhs = itemno; + rule_table[ruleno].line = p->sym->line; ruleprec = p->ruleprec; p = p->next; @@ -1946,8 +1927,8 @@ packgram (void) of the last token in it. */ if (p->sym->class == token_sym) { - rprec[ruleno] = p->sym->prec; - rassoc[ruleno] = p->sym->assoc; + rule_table[ruleno].prec = p->sym->prec; + rule_table[ruleno].assoc = p->sym->assoc; } if (p) p = p->next; @@ -1957,9 +1938,9 @@ packgram (void) the specified symbol's precedence replaces the default. */ if (ruleprec) { - rprec[ruleno] = ruleprec->prec; - rassoc[ruleno] = ruleprec->assoc; - rprecsym[ruleno] = ruleprec->value; + rule_table[ruleno].prec = ruleprec->prec; + rule_table[ruleno].assoc = ruleprec->assoc; + rule_table[ruleno].precsym = ruleprec->value; } ritem[itemno++] = -ruleno; @@ -1990,8 +1971,6 @@ reader (void) nvars = 0; nrules = 0; nitems = 0; - rline_allocated = 10; - rline = XCALLOC (short, rline_allocated); typed = 0; lastprec = 0; @@ -2041,4 +2020,6 @@ reader (void) symbols_output (); /* Convert the grammar into the format described in gram.h. */ packgram (); + /* Output the headers. */ + symbols_output (); }