* 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.
13 files changed:
+2001-12-29 Akim Demaille <akim@epita.fr>
+
+ * 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 <akim@epita.fr>
* src/gram.c (rprec, rprecsym, rassoc): Remove, unused since long
2001-12-29 Akim Demaille <akim@epita.fr>
* src/gram.c (rprec, rprecsym, rassoc): Remove, unused since long
{
short *rhsp;
fprintf (stderr, "\t\t%d:", j - 1);
{
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);
}
fprintf (stderr, " %s", symbols[*rhsp]->tag);
fputc ('\n', stderr);
}
for (i = ntokens; i < nsyms; i++)
for (j = 0; derives[i][j] >= 0; ++j)
{
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);
}
if (ISVAR (symbol))
SETBIT (FIRSTS (i), symbol - ntokens);
}
for (ruleno = 0; ruleno < nrules + 1; ++ruleno)
if (BITISSET (ruleset, ruleno))
{
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];
while (c < n && core[c] < itemno)
{
itemset[nitemset] = core[c];
{
int i;
/* find the rule to reduce by to get precedence of reduction */
{
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;
errs *errp = errs_new (ntokens + 1);
errp->nerrs = 0;
check for shift-reduce conflict, and try to resolve using
precedence */
for (i = 0; i < state->nlookaheads; ++i)
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])
{
for (j = 0; j < tokensetsize; ++j)
if (LA (state->lookaheadsp + i)[j] & lookaheadset[j])
{
{
short *rhsp;
fprintf (stderr, "\t\t%d:", *sp);
{
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);
}
fprintf (stderr, " %s", symbols[*rhsp]->tag);
fprintf (stderr, " (rule %d)\n", -*rhsp - 1);
}
p = delts;
for (i = nrules; i > 0; i--)
p = delts;
for (i = nrules; i > 0; i--)
- if (rule_table[i].useful)
- int lhs = rule_table[i].lhs;
+ int lhs = rules[i].lhs;
p->next = dset[lhs];
p->value = i;
dset[lhs] = p;
p->next = dset[lhs];
p->value = i;
dset[lhs] = p;
short *ritem = NULL;
int nritems;
short *ritem = NULL;
int nritems;
-rule_t *rule_table = NULL;
struct bucket **symbols = NULL;
short *token_translations = NULL;
struct bucket **symbols = NULL;
short *token_translations = NULL;
written. Actions and guards are accessed via the rule number.
The rules themselves are described by several arrays: amongst which
written. Actions and guards are accessed via the rule number.
The rules themselves are described by several arrays: amongst which
- 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 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
- 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
- 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.
The right hand side is stored as symbol numbers in a portion of
RITEM.
short guard_line;
} rule_t;
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;
/* Table of the symbols, indexed by the symbol number. */
extern struct bucket **symbols;
state_t *state = state_table[from_state[i]];
states[0] = state->number;
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;
{
shifts *sp = state->shifts;
int j;
p = relts;
for (ruleno = 1; ruleno < nrules + 1; ++ruleno)
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;
{
/* 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)
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];
{
rcount[ruleno]++;
p->next = rsets[*r];
else
{
/* This rule has an empty RHS. */
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;
{
ruleno = p->value;
if (--rcount[ruleno] == 0)
{
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;
int i;
short *values = XCALLOC (short, nrules + 1);
for (i = 0; i < nrules + 1; ++i)
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);
output_table_data (&format_obstack, values,
0, 1, nrules + 1);
XFREE (values);
{
short *values = XCALLOC (short, nrules + 1);
for (i = 0; i < nrules + 1; ++i)
{
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));
output_table_data (&format_obstack, values,
0, 1, nrules + 1);
muscle_insert ("rline", obstack_finish (&format_obstack));
{
short *values = XCALLOC (short, nrules + 1);
for (i = 0; i < nrules + 1; ++i)
{
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));
output_table_data (&format_obstack, values,
0, 1, nrules + 1);
muscle_insert ("r1", obstack_finish (&format_obstack));
/* Output YYR2. */
short_tab = XMALLOC (short, nrules + 1);
for (i = 1; i < nrules; i++)
/* 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));
output_table_data (&format_obstack, short_tab,
0, 1, nrules + 1);
muscle_insert ("r2", obstack_finish (&format_obstack));
{
int rule;
for (rule = 1; rule < nrules + 1; ++rule)
{
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"),
{
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",
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,
yacc_flag ? ";" : "");
/* We always output 4 '\n' per action. */
yacc_flag ? ";" : "");
/* We always output 4 '\n' per action. */
if (!no_lines_flag)
++*line;
/* Get the number of lines written by the user. */
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);
{
int rule;
for (rule = 1; rule < nrules + 1; ++rule)
{
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"),
{
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",
quotearg_style (c_quoting_style,
muscle_find ("filename")));
fprintf (out, "{ %s; }\n break;\n\n",
- rule_table[rule].guard);
/* We always output 4 '\n' per action. */
*line += 4;
/* We always output 4 '\n' per action. */
*line += 4;
if (!no_lines_flag)
++*line;
/* Get the number of lines written by the user. */
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);
if (defines_flag)
header_output ();
if (defines_flag)
header_output ();
obstack_free (&muscle_obstack, NULL);
obstack_free (&format_obstack, NULL);
obstack_free (&action_obstack, NULL);
obstack_free (&muscle_obstack, NULL);
obstack_free (&format_obstack, NULL);
obstack_free (&action_obstack, NULL);
- 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);
fprintf (out, "%s ", escape (symbols[*sp]->tag));
fputc ('.', out);
if (state->consistent)
{
int rule = redp->rules[0];
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;
fprintf (out, _(" $default\treduce using rule %d (%s)\n\n"),
rule - 1, escape (symbols[symbol]->tag));
return;
if (BITISSET (lookaheadset, i))
fprintf (out, _(" %-4s\t[reduce using rule %d (%s)]\n"),
escape (symbols[i]->tag), default_rule - 1,
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"),
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)
{
}
else if (state->nlookaheads >= 1)
{
_(" %-4s\treduce using rule %d (%s)\n"),
escape (symbols[i]->tag),
LAruleno[state->lookaheadsp + j] - 1,
_(" %-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));
_(" %-4s\treduce using rule %d (%s)\n"),
escape (symbols[i]->tag),
LAruleno[default_LA] - 1,
_(" %-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,
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));
if (default_LA >= 0)
fprintf (out, _(" $default\treduce using rule %d (%s)\n"),
default_rule - 1,
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));
fprintf (out, " %s\n", _("Number, Line, Rule"));
for (i = 1; i <= nrules; i++)
/* Don't print rules disabled in reduce_grammar_tables. */
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)
{
fprintf (out, _(" %3d %3d %s ->"),
{
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));
if (*rule >= 0)
while (*rule >= 0)
fprintf (out, " %s", escape (symbols[*rule++]->tag));
sprintf (buffer, " (%d)", i);
for (j = 1; j <= nrules; j++)
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);
if (*rule == token_translations[i])
{
END_TEST (65);
for (j = 1; j <= nrules; j++)
{
for (j = 1; j <= nrules; j++)
{
- if (rule_table[j].lhs == i)
- for (rule = &ritem[rule_table[j].rhs]; *rule >= 0; rule++)
+ for (rule = &ritem[rules[j].rhs]; *rule >= 0; rule++)
if (*rule == i)
{
right_count++;
if (*rule == i)
{
right_count++;
for (j = 1; j <= nrules; j++)
{
END_TEST (65);
for (j = 1; j <= nrules; j++)
{
END_TEST (65);
- if (rule_table[j].lhs == i)
sprintf (buffer + strlen (buffer), " %d", j - 1);
}
}
sprintf (buffer + strlen (buffer), " %d", j - 1);
}
}
sprintf (buffer + strlen (buffer), _(" on right:"));
for (j = 1; j <= nrules; j++)
{
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);
if (*rule == i)
{
END_TEST (65);
if (i)
obstack_1grow (node_obstack, '\n');
obstack_fgrow1 (node_obstack, " %s -> ",
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, '.');
obstack_fgrow1 (node_obstack, "%s ", escape (symbols[*sp]->tag));
obstack_1grow (node_obstack, '.');
fatal (_("too many items (max %d)"), MAXSHORT);
ritem = XCALLOC (short, nitems + 1);
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;
while (p)
{
bucket *ruleprec = p->ruleprec;
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)
p = p->next;
while (p && p->sym)
of the last token in it. */
if (p->sym->class == token_sym)
{
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;
the specified symbol's precedence replaces the default. */
if (ruleprec)
{
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;
}
ritem[itemno++] = -ruleno;
/* A production is useful if all of the nonterminals in its appear
in the set of useful nonterminals. */
/* 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;
if (ISVAR (n = *r))
if (!BITISSET (N0, n - ntokens))
return FALSE;
{
if (useful_production (i, N))
{
{
if (useful_production (i, N))
{
- SETBIT (Np, rule_table[i].lhs - ntokens);
+ SETBIT (Np, rules[i].lhs - ntokens);
{
if (!BITISSET (Pp, i)
&& BITISSET (P, i)
{
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);
if (ISTOKEN (t = *r) || BITISSET (N, t - ntokens))
SETBIT (Vp, t);
SETBIT (Pp, i);
/* A token that was used in %prec should not be warned about. */
for (i = 1; i < nrules; i++)
/* 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);
- 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;
while (ritem[pi] >= 0)
ritem[ni++] = ritem[pi++];
ritem[ni++] = -np;
{
int pn;
for (pn = 1; pn <= nrules; pn++)
{
int pn;
for (pn = 1; pn <= nrules; pn++)
- rule_table[pn].useful = BITISSET (P, pn);
+ rules[pn].useful = BITISSET (P, pn);
for (i = 1; i <= nrules; i++)
{
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))
- rule_table[i].precsym = nontermmap[rule_table[i].precsym];
+ rules[i].precsym = nontermmap[rules[i].precsym];
}
for (i = 0; i < nritems; ++i)
}
for (i = 0; i < nritems; ++i)
int i;
fprintf (out, "%s\n\n", _("Useless rules:"));
for (i = 1; i <= nrules; i++)
int i;
fprintf (out, "%s\n\n", _("Useless rules:"));
for (i = 1; i <= nrules; i++)
- if (!rule_table[i].useful)
{
rule r;
fprintf (out, "#%-4d ", i - 1);
{
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);
}
fprintf (out, " %s", symbols[*r]->tag);
fputs (";\n", out);
}
{
int rhs_count = 0;
/* Find the last RHS index in ritems. */
{
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,
++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);
- 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);
}
fprintf (out, "%3d", *r);
fprintf (out, " [%d]\n", -(*r) - 1);
}
fprintf (out, "Rules interpreted\n-----------------\n\n");
for (i = 1; i <= nrules; i++)
{
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);
}
fprintf (out, " %s", symbols[*r]->tag);
fputc ('\n', out);
}