From 1a2b5d37e1d44b47cd51220945f4ba29c228a419 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sat, 29 Dec 2001 14:20:13 +0000 Subject: [PATCH] * src/closure.c, src/conflicts.c, src/derives.c, src/gram.c * src/gram.h, src/lalr.c, src/nullable.c, src/output.c, src/print.c * src/print_graph.c, src/reader.c, src/reduce.c: Rename rule_table as rules. --- ChangeLog | 8 +++++++ src/closure.c | 6 ++--- src/conflicts.c | 4 ++-- src/derives.c | 6 ++--- src/gram.c | 2 +- src/gram.h | 20 ++++++++--------- src/lalr.c | 2 +- src/nullable.c | 22 +++++++++---------- src/output.c | 28 ++++++++++++------------ src/print.c | 34 ++++++++++++++-------------- src/print_graph.c | 4 ++-- src/reader.c | 28 ++++++++++++------------ src/reduce.c | 56 +++++++++++++++++++++++------------------------ 13 files changed, 114 insertions(+), 106 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1cc44d69..0150abe0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2001-12-29 Akim Demaille + + * src/closure.c, src/conflicts.c, src/derives.c, src/gram.c + * src/gram.h, src/lalr.c, src/nullable.c, src/output.c, src/print.c + * src/print_graph.c, src/reader.c, src/reduce.c: Rename rule_table + as rules. + + 2001-12-29 Akim Demaille * src/gram.c (rprec, rprecsym, rassoc): Remove, unused since long diff --git a/src/closure.c b/src/closure.c index 61a111be..d24e2eab 100644 --- a/src/closure.c +++ b/src/closure.c @@ -103,7 +103,7 @@ print_fderives (void) { short *rhsp; fprintf (stderr, "\t\t%d:", j - 1); - for (rhsp = &ritem[rule_table[j].rhs]; *rhsp >= 0; ++rhsp) + for (rhsp = &ritem[rules[j].rhs]; *rhsp >= 0; ++rhsp) fprintf (stderr, " %s", symbols[*rhsp]->tag); fputc ('\n', stderr); } @@ -133,7 +133,7 @@ set_firsts (void) for (i = ntokens; i < nsyms; i++) for (j = 0; derives[i][j] >= 0; ++j) { - int symbol = ritem[rule_table[derives[i][j]].rhs]; + int symbol = ritem[rules[derives[i][j]].rhs]; if (ISVAR (symbol)) SETBIT (FIRSTS (i), symbol - ntokens); } @@ -225,7 +225,7 @@ closure (short *core, int n) for (ruleno = 0; ruleno < nrules + 1; ++ruleno) if (BITISSET (ruleset, ruleno)) { - int itemno = rule_table[ruleno].rhs; + int itemno = rules[ruleno].rhs; while (c < n && core[c] < itemno) { itemset[nitemset] = core[c]; diff --git a/src/conflicts.c b/src/conflicts.c index 2dc1cc5c..3a979410 100644 --- a/src/conflicts.c +++ b/src/conflicts.c @@ -94,7 +94,7 @@ resolve_sr_conflict (state_t *state, int lookahead) { int i; /* find the rule to reduce by to get precedence of reduction */ - int redprec = rule_table[LAruleno[lookahead]].prec; + int redprec = rules[LAruleno[lookahead]].prec; errs *errp = errs_new (ntokens + 1); errp->nerrs = 0; @@ -172,7 +172,7 @@ set_conflicts (state_t *state) check for shift-reduce conflict, and try to resolve using precedence */ for (i = 0; i < state->nlookaheads; ++i) - if (rule_table[LAruleno[state->lookaheadsp + i]].prec) + if (rules[LAruleno[state->lookaheadsp + i]].prec) for (j = 0; j < tokensetsize; ++j) if (LA (state->lookaheadsp + i)[j] & lookaheadset[j]) { diff --git a/src/derives.c b/src/derives.c index 479a3551..795bc08e 100644 --- a/src/derives.c +++ b/src/derives.c @@ -44,7 +44,7 @@ print_derives (void) { short *rhsp; fprintf (stderr, "\t\t%d:", *sp); - for (rhsp = &ritem[rule_table[*sp].rhs]; *rhsp >= 0; ++rhsp) + for (rhsp = &ritem[rules[*sp].rhs]; *rhsp >= 0; ++rhsp) fprintf (stderr, " %s", symbols[*rhsp]->tag); fprintf (stderr, " (rule %d)\n", -*rhsp - 1); } @@ -68,9 +68,9 @@ set_derives (void) p = delts; for (i = nrules; i > 0; i--) - if (rule_table[i].useful) + if (rules[i].useful) { - int lhs = rule_table[i].lhs; + int lhs = rules[i].lhs; p->next = dset[lhs]; p->value = i; dset[lhs] = p; diff --git a/src/gram.c b/src/gram.c index a67bf2e2..f6f39f5a 100644 --- a/src/gram.c +++ b/src/gram.c @@ -35,7 +35,7 @@ int nvars; short *ritem = NULL; int nritems; -rule_t *rule_table = NULL; +rule_t *rules = NULL; struct bucket **symbols = NULL; short *token_translations = NULL; diff --git a/src/gram.h b/src/gram.h index bf49c402..9e16c031 100644 --- a/src/gram.h +++ b/src/gram.h @@ -39,27 +39,27 @@ written. Actions and guards are accessed via the rule number. The rules themselves are described by several arrays: amongst which - RITEM, and RULE_TABLE. + RITEM, and RULES. - RULE_TABLE is an array of struct rule_s, which members are: + RULES is an array of struct rule_s, which members are: - RULE_TABLE[R].lhs -- the symbol number of the left hand side of + RULES[R].lhs -- the symbol number of the left hand side of rule R. If -1, the rule has been thrown out by reduce.c and should be ignored. - RULE_TABLE[R].rhs -- the index in RITEM of the beginning of the + RULES[R].rhs -- the index in RITEM of the beginning of the portion for rule R. - RULE_TABLE[R].prec -- the precedence level of R. + RULES[R].prec -- the precedence level of R. - RULE_TABLE[R].precsym -- the symbol-number of the symbol in %prec + RULES[R].precsym -- the symbol-number of the symbol in %prec for R (if any). - RULE_TABLE[R].assoc -- the associativity of R. + RULES[R].assoc -- the associativity of R. - RULE_TABLE[R].line -- the line where R was defined. + RULES[R].line -- the line where R was defined. - RULE_TABLE[R].useful -- TRUE iff the rule is used. + RULES[R].useful -- TRUE iff the rule is used. The right hand side is stored as symbol numbers in a portion of RITEM. @@ -128,7 +128,7 @@ typedef struct rule_s short guard_line; } rule_t; -extern struct rule_s *rule_table; +extern struct rule_s *rules; /* Table of the symbols, indexed by the symbol number. */ extern struct bucket **symbols; diff --git a/src/lalr.c b/src/lalr.c index f7fead37..55986f33 100644 --- a/src/lalr.c +++ b/src/lalr.c @@ -420,7 +420,7 @@ build_relations (void) state_t *state = state_table[from_state[i]]; states[0] = state->number; - for (rp = &ritem[rule_table[*rulep].rhs]; *rp >= 0; rp++) + for (rp = &ritem[rules[*rulep].rhs]; *rp >= 0; rp++) { shifts *sp = state->shifts; int j; diff --git a/src/nullable.c b/src/nullable.c index 082f2b32..f8c9b32e 100644 --- a/src/nullable.c +++ b/src/nullable.c @@ -69,21 +69,21 @@ set_nullable (void) p = relts; for (ruleno = 1; ruleno < nrules + 1; ++ruleno) - if (rule_table[ruleno].useful) + if (rules[ruleno].useful) { - if (ritem[rule_table[ruleno].rhs] >= 0) + if (ritem[rules[ruleno].rhs] >= 0) { /* This rule has a non empty RHS. */ short *r; int any_tokens = 0; - for (r = &ritem[rule_table[ruleno].rhs]; *r >= 0; ++r) + for (r = &ritem[rules[ruleno].rhs]; *r >= 0; ++r) if (ISTOKEN (*r)) any_tokens = 1; /* This rule has only nonterminals: schedule it for the second pass. */ if (!any_tokens) - for (r = &ritem[rule_table[ruleno].rhs]; *r >= 0; ++r) + for (r = &ritem[rules[ruleno].rhs]; *r >= 0; ++r) { rcount[ruleno]++; p->next = rsets[*r]; @@ -95,11 +95,11 @@ set_nullable (void) else { /* This rule has an empty RHS. */ - assert (ritem[rule_table[ruleno].rhs] == -ruleno); - if (rule_table[ruleno].useful && !nullable[rule_table[ruleno].lhs]) + assert (ritem[rules[ruleno].rhs] == -ruleno); + if (rules[ruleno].useful && !nullable[rules[ruleno].lhs]) { - nullable[rule_table[ruleno].lhs] = 1; - *s2++ = rule_table[ruleno].lhs; + nullable[rules[ruleno].lhs] = 1; + *s2++ = rules[ruleno].lhs; } } } @@ -109,10 +109,10 @@ set_nullable (void) { ruleno = p->value; if (--rcount[ruleno] == 0) - if (rule_table[ruleno].useful && !nullable[rule_table[ruleno].lhs]) + if (rules[ruleno].useful && !nullable[rules[ruleno].lhs]) { - nullable[rule_table[ruleno].lhs] = 1; - *s2++ = rule_table[ruleno].lhs; + nullable[rules[ruleno].lhs] = 1; + *s2++ = rules[ruleno].lhs; } } diff --git a/src/output.c b/src/output.c index 37ce24cf..3a8bc994 100644 --- a/src/output.c +++ b/src/output.c @@ -185,7 +185,7 @@ output_gram (void) int i; short *values = XCALLOC (short, nrules + 1); for (i = 0; i < nrules + 1; ++i) - values[i] = rule_table[i].rhs; + values[i] = rules[i].rhs; output_table_data (&format_obstack, values, 0, 1, nrules + 1); XFREE (values); @@ -239,7 +239,7 @@ output_rule_data (void) { short *values = XCALLOC (short, nrules + 1); for (i = 0; i < nrules + 1; ++i) - values[i] = rule_table[i].line; + values[i] = rules[i].line; output_table_data (&format_obstack, values, 0, 1, nrules + 1); muscle_insert ("rline", obstack_finish (&format_obstack)); @@ -291,7 +291,7 @@ output_rule_data (void) { short *values = XCALLOC (short, nrules + 1); for (i = 0; i < nrules + 1; ++i) - values[i] = rule_table[i].lhs; + values[i] = rules[i].lhs; output_table_data (&format_obstack, values, 0, 1, nrules + 1); muscle_insert ("r1", obstack_finish (&format_obstack)); @@ -301,8 +301,8 @@ output_rule_data (void) /* Output YYR2. */ short_tab = XMALLOC (short, nrules + 1); for (i = 1; i < nrules; i++) - short_tab[i] = rule_table[i + 1].rhs - rule_table[i].rhs - 1; - short_tab[nrules] = nritems - rule_table[nrules].rhs - 1; + short_tab[i] = rules[i + 1].rhs - rules[i].rhs - 1; + short_tab[nrules] = nritems - rules[nrules].rhs - 1; output_table_data (&format_obstack, short_tab, 0, 1, nrules + 1); muscle_insert ("r2", obstack_finish (&format_obstack)); @@ -508,20 +508,20 @@ actions_output (FILE *out, size_t *line) { int rule; for (rule = 1; rule < nrules + 1; ++rule) - if (rule_table[rule].action) + if (rules[rule].action) { fprintf (out, " case %d:\n", rule); if (!no_lines_flag) fprintf (out, muscle_find ("linef"), - rule_table[rule].action_line, + rules[rule].action_line, quotearg_style (c_quoting_style, muscle_find ("filename"))); /* As a Bison extension, add the ending semicolon. Since some Yacc don't do that, help people using bison as a Yacc finding their missing semicolons. */ fprintf (out, "{ %s%s }\n break;\n\n", - rule_table[rule].action, + rules[rule].action, yacc_flag ? ";" : ""); /* We always output 4 '\n' per action. */ @@ -530,7 +530,7 @@ actions_output (FILE *out, size_t *line) if (!no_lines_flag) ++*line; /* Get the number of lines written by the user. */ - *line += get_lines_number (rule_table[rule].action); + *line += get_lines_number (rules[rule].action); } } @@ -544,17 +544,17 @@ guards_output (FILE *out, size_t *line) { int rule; for (rule = 1; rule < nrules + 1; ++rule) - if (rule_table[rule].action) + if (rules[rule].action) { fprintf (out, " case %d:\n", rule); if (!no_lines_flag) fprintf (out, muscle_find ("linef"), - rule_table[rule].guard_line, + rules[rule].guard_line, quotearg_style (c_quoting_style, muscle_find ("filename"))); fprintf (out, "{ %s; }\n break;\n\n", - rule_table[rule].guard); + rules[rule].guard); /* We always output 4 '\n' per action. */ *line += 4; @@ -562,7 +562,7 @@ guards_output (FILE *out, size_t *line) if (!no_lines_flag) ++*line; /* Get the number of lines written by the user. */ - *line += get_lines_number (rule_table[rule].guard); + *line += get_lines_number (rules[rule].guard); } } @@ -1122,7 +1122,7 @@ output (void) if (defines_flag) header_output (); - free (rule_table + 1); + free (rules + 1); obstack_free (&muscle_obstack, NULL); obstack_free (&format_obstack, NULL); obstack_free (&action_obstack, NULL); diff --git a/src/print.c b/src/print.c index 96c59fc7..5a417d32 100644 --- a/src/print.c +++ b/src/print.c @@ -93,9 +93,9 @@ print_core (FILE *out, state_t *state) sp++; rule = -(*sp); - fprintf (out, " %s -> ", escape (symbols[rule_table[rule].lhs]->tag)); + fprintf (out, " %s -> ", escape (symbols[rules[rule].lhs]->tag)); - for (sp = ritem + rule_table[rule].rhs; sp < sp1; sp++) + for (sp = ritem + rules[rule].rhs; sp < sp1; sp++) fprintf (out, "%s ", escape (symbols[*sp]->tag)); fputc ('.', out); @@ -188,7 +188,7 @@ print_reductions (FILE *out, state_t *state) if (state->consistent) { int rule = redp->rules[0]; - int symbol = rule_table[rule].lhs; + int symbol = rules[rule].lhs; fprintf (out, _(" $default\treduce using rule %d (%s)\n\n"), rule - 1, escape (symbols[symbol]->tag)); return; @@ -223,10 +223,10 @@ print_reductions (FILE *out, state_t *state) if (BITISSET (lookaheadset, i)) fprintf (out, _(" %-4s\t[reduce using rule %d (%s)]\n"), escape (symbols[i]->tag), default_rule - 1, - escape2 (symbols[rule_table[default_rule].lhs]->tag)); + escape2 (symbols[rules[default_rule].lhs]->tag)); fprintf (out, _(" $default\treduce using rule %d (%s)\n\n"), - default_rule - 1, escape (symbols[rule_table[default_rule].lhs]->tag)); + default_rule - 1, escape (symbols[rules[default_rule].lhs]->tag)); } else if (state->nlookaheads >= 1) { @@ -282,7 +282,7 @@ print_reductions (FILE *out, state_t *state) _(" %-4s\treduce using rule %d (%s)\n"), escape (symbols[i]->tag), LAruleno[state->lookaheadsp + j] - 1, - escape2 (symbols[rule_table[LAruleno[state->lookaheadsp + j]].lhs]->tag)); + escape2 (symbols[rules[LAruleno[state->lookaheadsp + j]].lhs]->tag)); else defaulted = 1; @@ -295,13 +295,13 @@ print_reductions (FILE *out, state_t *state) _(" %-4s\treduce using rule %d (%s)\n"), escape (symbols[i]->tag), LAruleno[default_LA] - 1, - escape2 (symbols[rule_table[LAruleno[default_LA]].lhs]->tag)); + escape2 (symbols[rules[LAruleno[default_LA]].lhs]->tag)); defaulted = 0; fprintf (out, _(" %-4s\t[reduce using rule %d (%s)]\n"), escape (symbols[i]->tag), LAruleno[state->lookaheadsp + j] - 1, - escape2 (symbols[rule_table[LAruleno[state->lookaheadsp + j]].lhs]->tag)); + escape2 (symbols[rules[LAruleno[state->lookaheadsp + j]].lhs]->tag)); } } } @@ -310,7 +310,7 @@ print_reductions (FILE *out, state_t *state) if (default_LA >= 0) fprintf (out, _(" $default\treduce using rule %d (%s)\n"), default_rule - 1, - escape (symbols[rule_table[default_rule].lhs]->tag)); + escape (symbols[rules[default_rule].lhs]->tag)); } } @@ -374,11 +374,11 @@ print_grammar (FILE *out) fprintf (out, " %s\n", _("Number, Line, Rule")); for (i = 1; i <= nrules; i++) /* Don't print rules disabled in reduce_grammar_tables. */ - if (rule_table[i].useful) + if (rules[i].useful) { fprintf (out, _(" %3d %3d %s ->"), - i - 1, rule_table[i].line, escape (symbols[rule_table[i].lhs]->tag)); - rule = &ritem[rule_table[i].rhs]; + i - 1, rules[i].line, escape (symbols[rules[i].lhs]->tag)); + rule = &ritem[rules[i].rhs]; if (*rule >= 0) while (*rule >= 0) fprintf (out, " %s", escape (symbols[*rule++]->tag)); @@ -401,7 +401,7 @@ print_grammar (FILE *out) sprintf (buffer, " (%d)", i); for (j = 1; j <= nrules; j++) - for (rule = &ritem[rule_table[j].rhs]; *rule >= 0; rule++) + for (rule = &ritem[rules[j].rhs]; *rule >= 0; rule++) if (*rule == token_translations[i]) { END_TEST (65); @@ -420,9 +420,9 @@ print_grammar (FILE *out) for (j = 1; j <= nrules; j++) { - if (rule_table[j].lhs == i) + if (rules[j].lhs == i) left_count++; - for (rule = &ritem[rule_table[j].rhs]; *rule >= 0; rule++) + for (rule = &ritem[rules[j].rhs]; *rule >= 0; rule++) if (*rule == i) { right_count++; @@ -444,7 +444,7 @@ print_grammar (FILE *out) for (j = 1; j <= nrules; j++) { END_TEST (65); - if (rule_table[j].lhs == i) + if (rules[j].lhs == i) sprintf (buffer + strlen (buffer), " %d", j - 1); } } @@ -457,7 +457,7 @@ print_grammar (FILE *out) sprintf (buffer + strlen (buffer), _(" on right:")); for (j = 1; j <= nrules; j++) { - for (rule = &ritem[rule_table[j].rhs]; *rule >= 0; rule++) + for (rule = &ritem[rules[j].rhs]; *rule >= 0; rule++) if (*rule == i) { END_TEST (65); diff --git a/src/print_graph.c b/src/print_graph.c index dd271d78..d32e5520 100644 --- a/src/print_graph.c +++ b/src/print_graph.c @@ -78,9 +78,9 @@ print_core (state_t *state, struct obstack *node_obstack) if (i) obstack_1grow (node_obstack, '\n'); obstack_fgrow1 (node_obstack, " %s -> ", - escape (symbols[rule_table[rule].lhs]->tag)); + escape (symbols[rules[rule].lhs]->tag)); - for (sp = ritem + rule_table[rule].rhs; sp < sp1; sp++) + for (sp = ritem + rules[rule].rhs; sp < sp1; sp++) obstack_fgrow1 (node_obstack, "%s ", escape (symbols[*sp]->tag)); obstack_1grow (node_obstack, '.'); diff --git a/src/reader.c b/src/reader.c index 527194e0..d76bd6fe 100644 --- a/src/reader.c +++ b/src/reader.c @@ -1720,7 +1720,7 @@ packgram (void) fatal (_("too many items (max %d)"), MAXSHORT); ritem = XCALLOC (short, nitems + 1); - rule_table = XCALLOC (rule_t, nrules) - 1; + rules = XCALLOC (rule_t, nrules) - 1; itemno = 0; ruleno = 1; @@ -1729,14 +1729,14 @@ packgram (void) while (p) { bucket *ruleprec = p->ruleprec; - rule_table[ruleno].lhs = p->sym->value; - rule_table[ruleno].rhs = itemno; - rule_table[ruleno].line = p->line; - rule_table[ruleno].useful = TRUE; - rule_table[ruleno].action = p->action; - rule_table[ruleno].action_line = p->action_line; - rule_table[ruleno].guard = p->guard; - rule_table[ruleno].guard_line = p->guard_line; + rules[ruleno].lhs = p->sym->value; + rules[ruleno].rhs = itemno; + rules[ruleno].line = p->line; + rules[ruleno].useful = TRUE; + rules[ruleno].action = p->action; + rules[ruleno].action_line = p->action_line; + rules[ruleno].guard = p->guard; + rules[ruleno].guard_line = p->guard_line; p = p->next; while (p && p->sym) @@ -1746,8 +1746,8 @@ packgram (void) of the last token in it. */ if (p->sym->class == token_sym) { - rule_table[ruleno].prec = p->sym->prec; - rule_table[ruleno].assoc = p->sym->assoc; + rules[ruleno].prec = p->sym->prec; + rules[ruleno].assoc = p->sym->assoc; } if (p) p = p->next; @@ -1757,9 +1757,9 @@ packgram (void) the specified symbol's precedence replaces the default. */ if (ruleprec) { - rule_table[ruleno].prec = ruleprec->prec; - rule_table[ruleno].assoc = ruleprec->assoc; - rule_table[ruleno].precsym = ruleprec->value; + rules[ruleno].prec = ruleprec->prec; + rules[ruleno].assoc = ruleprec->assoc; + rules[ruleno].precsym = ruleprec->value; } ritem[itemno++] = -ruleno; diff --git a/src/reduce.c b/src/reduce.c index 83909619..c4a2bd1c 100644 --- a/src/reduce.c +++ b/src/reduce.c @@ -108,7 +108,7 @@ useful_production (int i, BSet N0) /* A production is useful if all of the nonterminals in its appear in the set of useful nonterminals. */ - for (r = &ritem[rule_table[i].rhs]; *r >= 0; r++) + for (r = &ritem[rules[i].rhs]; *r >= 0; r++) if (ISVAR (n = *r)) if (!BITISSET (N0, n - ntokens)) return FALSE; @@ -157,7 +157,7 @@ useless_nonterminals (void) { if (useful_production (i, N)) { - SETBIT (Np, rule_table[i].lhs - ntokens); + SETBIT (Np, rules[i].lhs - ntokens); SETBIT (P, i); } } @@ -220,9 +220,9 @@ inaccessable_symbols (void) { if (!BITISSET (Pp, i) && BITISSET (P, i) - && BITISSET (V, rule_table[i].lhs)) + && BITISSET (V, rules[i].lhs)) { - for (r = &ritem[rule_table[i].rhs]; *r >= 0; r++) + for (r = &ritem[rules[i].rhs]; *r >= 0; r++) if (ISTOKEN (t = *r) || BITISSET (N, t - ntokens)) SETBIT (Vp, t); SETBIT (Pp, i); @@ -258,8 +258,8 @@ inaccessable_symbols (void) /* A token that was used in %prec should not be warned about. */ for (i = 1; i < nrules; i++) - if (rule_table[i].precsym != 0) - SETBIT (V1, rule_table[i].precsym); + if (rules[i].precsym != 0) + SETBIT (V1, rules[i].precsym); } static void @@ -289,15 +289,15 @@ reduce_grammar_tables (void) np++; if (pn != np) { - rule_table[np].lhs = rule_table[pn].lhs; - rule_table[np].line = rule_table[pn].line; - rule_table[np].prec = rule_table[pn].prec; - rule_table[np].assoc = rule_table[pn].assoc; - rule_table[np].rhs = rule_table[pn].rhs; - if (rule_table[np].rhs != ni) + rules[np].lhs = rules[pn].lhs; + rules[np].line = rules[pn].line; + rules[np].prec = rules[pn].prec; + rules[np].assoc = rules[pn].assoc; + rules[np].rhs = rules[pn].rhs; + if (rules[np].rhs != ni) { - pi = rule_table[np].rhs; - rule_table[np].rhs = ni; + pi = rules[np].rhs; + rules[np].rhs = ni; while (ritem[pi] >= 0) ritem[ni++] = ritem[pi++]; ritem[ni++] = -np; @@ -324,7 +324,7 @@ reduce_grammar_tables (void) { int pn; for (pn = 1; pn <= nrules; pn++) - rule_table[pn].useful = BITISSET (P, pn); + rules[pn].useful = BITISSET (P, pn); } } @@ -367,10 +367,10 @@ nonterminals_reduce (void) for (i = 1; i <= nrules; i++) { - rule_table[i].lhs = nontermmap[rule_table[i].lhs]; - if (ISVAR (rule_table[i].precsym)) + rules[i].lhs = nontermmap[rules[i].lhs]; + if (ISVAR (rules[i].precsym)) /* Can this happen? */ - rule_table[i].precsym = nontermmap[rule_table[i].precsym]; + rules[i].precsym = nontermmap[rules[i].precsym]; } for (i = 0; i < nritems; ++i) @@ -422,12 +422,12 @@ reduce_output (FILE *out) int i; fprintf (out, "%s\n\n", _("Useless rules:")); for (i = 1; i <= nrules; i++) - if (!rule_table[i].useful) + if (!rules[i].useful) { rule r; fprintf (out, "#%-4d ", i - 1); - fprintf (out, "%s:", symbols[rule_table[i].lhs]->tag); - for (r = &ritem[rule_table[i].rhs]; *r >= 0; r++) + fprintf (out, "%s:", symbols[rules[i].lhs]->tag); + for (r = &ritem[rules[i].rhs]; *r >= 0; r++) fprintf (out, " %s", symbols[*r]->tag); fputs (";\n", out); } @@ -458,15 +458,15 @@ dump_grammar (FILE *out) { int rhs_count = 0; /* Find the last RHS index in ritems. */ - for (r = &ritem[rule_table[i].rhs]; *r >= 0; ++r) + for (r = &ritem[rules[i].rhs]; *r >= 0; ++r) ++rhs_count; fprintf (out, "%3d (%2d, %2d, %2d, %2d-%2d) %2d ->", i - 1, - rule_table[i].prec, rule_table[i].assoc, rule_table[i].useful, - rule_table[i].rhs, rule_table[i].rhs + rhs_count - 1, - rule_table[i].lhs); + rules[i].prec, rules[i].assoc, rules[i].useful, + rules[i].rhs, rules[i].rhs + rhs_count - 1, + rules[i].lhs); /* Dumped the RHS. */ - for (r = &ritem[rule_table[i].rhs]; *r >= 0; r++) + for (r = &ritem[rules[i].rhs]; *r >= 0; r++) fprintf (out, "%3d", *r); fprintf (out, " [%d]\n", -(*r) - 1); } @@ -474,8 +474,8 @@ dump_grammar (FILE *out) fprintf (out, "Rules interpreted\n-----------------\n\n"); for (i = 1; i <= nrules; i++) { - fprintf (out, "%-5d %s :", i, symbols[rule_table[i].lhs]->tag); - for (r = &ritem[rule_table[i].rhs]; *r >= 0; r++) + fprintf (out, "%-5d %s :", i, symbols[rules[i].lhs]->tag); + for (r = &ritem[rules[i].rhs]; *r >= 0; r++) fprintf (out, " %s", symbols[*r]->tag); fputc ('\n', out); } -- 2.45.2