* 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.
This commit is contained in:
Akim Demaille
2001-12-29 14:20:13 +00:00
parent 1cca533e2e
commit 1a2b5d37e1
13 changed files with 114 additions and 106 deletions

View File

@@ -1,3 +1,11 @@
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> 2001-12-29 Akim Demaille <akim@epita.fr>
* src/gram.c (rprec, rprecsym, rassoc): Remove, unused since long * src/gram.c (rprec, rprecsym, rassoc): Remove, unused since long

View File

@@ -103,7 +103,7 @@ print_fderives (void)
{ {
short *rhsp; short *rhsp;
fprintf (stderr, "\t\t%d:", j - 1); 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); fprintf (stderr, " %s", symbols[*rhsp]->tag);
fputc ('\n', stderr); fputc ('\n', stderr);
} }
@@ -133,7 +133,7 @@ set_firsts (void)
for (i = ntokens; i < nsyms; i++) for (i = ntokens; i < nsyms; i++)
for (j = 0; derives[i][j] >= 0; ++j) 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)) if (ISVAR (symbol))
SETBIT (FIRSTS (i), symbol - ntokens); SETBIT (FIRSTS (i), symbol - ntokens);
} }
@@ -225,7 +225,7 @@ closure (short *core, int n)
for (ruleno = 0; ruleno < nrules + 1; ++ruleno) for (ruleno = 0; ruleno < nrules + 1; ++ruleno)
if (BITISSET (ruleset, ruleno)) if (BITISSET (ruleset, ruleno))
{ {
int itemno = rule_table[ruleno].rhs; int itemno = rules[ruleno].rhs;
while (c < n && core[c] < itemno) while (c < n && core[c] < itemno)
{ {
itemset[nitemset] = core[c]; itemset[nitemset] = core[c];

View File

@@ -94,7 +94,7 @@ resolve_sr_conflict (state_t *state, int lookahead)
{ {
int i; int i;
/* find the rule to reduce by to get precedence of reduction */ /* 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); errs *errp = errs_new (ntokens + 1);
errp->nerrs = 0; errp->nerrs = 0;
@@ -172,7 +172,7 @@ set_conflicts (state_t *state)
check for shift-reduce conflict, and try to resolve using check for shift-reduce conflict, and try to resolve using
precedence */ precedence */
for (i = 0; i < state->nlookaheads; ++i) 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) for (j = 0; j < tokensetsize; ++j)
if (LA (state->lookaheadsp + i)[j] & lookaheadset[j]) if (LA (state->lookaheadsp + i)[j] & lookaheadset[j])
{ {

View File

@@ -44,7 +44,7 @@ print_derives (void)
{ {
short *rhsp; short *rhsp;
fprintf (stderr, "\t\t%d:", *sp); 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, " %s", symbols[*rhsp]->tag);
fprintf (stderr, " (rule %d)\n", -*rhsp - 1); fprintf (stderr, " (rule %d)\n", -*rhsp - 1);
} }
@@ -68,9 +68,9 @@ set_derives (void)
p = delts; p = delts;
for (i = nrules; i > 0; i--) 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->next = dset[lhs];
p->value = i; p->value = i;
dset[lhs] = p; dset[lhs] = p;

View File

@@ -35,7 +35,7 @@ int nvars;
short *ritem = NULL; short *ritem = NULL;
int nritems; int nritems;
rule_t *rule_table = NULL; rule_t *rules = NULL;
struct bucket **symbols = NULL; struct bucket **symbols = NULL;
short *token_translations = NULL; short *token_translations = NULL;

View File

@@ -39,27 +39,27 @@
written. Actions and guards are accessed via the rule number. written. Actions and guards are accessed via the rule number.
The rules themselves are described by several arrays: amongst which 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 rule R. If -1, the rule has been thrown out by reduce.c and should
be ignored. 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. 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). 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 The right hand side is stored as symbol numbers in a portion of
RITEM. RITEM.
@@ -128,7 +128,7 @@ typedef struct rule_s
short guard_line; short guard_line;
} rule_t; } rule_t;
extern struct rule_s *rule_table; extern struct rule_s *rules;
/* Table of the symbols, indexed by the symbol number. */ /* Table of the symbols, indexed by the symbol number. */
extern struct bucket **symbols; extern struct bucket **symbols;

View File

@@ -420,7 +420,7 @@ build_relations (void)
state_t *state = state_table[from_state[i]]; state_t *state = state_table[from_state[i]];
states[0] = state->number; 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; shifts *sp = state->shifts;
int j; int j;

View File

@@ -69,21 +69,21 @@ set_nullable (void)
p = relts; p = relts;
for (ruleno = 1; ruleno < nrules + 1; ++ruleno) 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. */ /* This rule has a non empty RHS. */
short *r; short *r;
int any_tokens = 0; 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)) if (ISTOKEN (*r))
any_tokens = 1; any_tokens = 1;
/* This rule has only nonterminals: schedule it for the second /* This rule has only nonterminals: schedule it for the second
pass. */ pass. */
if (!any_tokens) if (!any_tokens)
for (r = &ritem[rule_table[ruleno].rhs]; *r >= 0; ++r) for (r = &ritem[rules[ruleno].rhs]; *r >= 0; ++r)
{ {
rcount[ruleno]++; rcount[ruleno]++;
p->next = rsets[*r]; p->next = rsets[*r];
@@ -95,11 +95,11 @@ set_nullable (void)
else else
{ {
/* This rule has an empty RHS. */ /* This rule has an empty RHS. */
assert (ritem[rule_table[ruleno].rhs] == -ruleno); assert (ritem[rules[ruleno].rhs] == -ruleno);
if (rule_table[ruleno].useful && !nullable[rule_table[ruleno].lhs]) if (rules[ruleno].useful && !nullable[rules[ruleno].lhs])
{ {
nullable[rule_table[ruleno].lhs] = 1; nullable[rules[ruleno].lhs] = 1;
*s2++ = rule_table[ruleno].lhs; *s2++ = rules[ruleno].lhs;
} }
} }
} }
@@ -109,10 +109,10 @@ set_nullable (void)
{ {
ruleno = p->value; ruleno = p->value;
if (--rcount[ruleno] == 0) 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; nullable[rules[ruleno].lhs] = 1;
*s2++ = rule_table[ruleno].lhs; *s2++ = rules[ruleno].lhs;
} }
} }

View File

@@ -185,7 +185,7 @@ output_gram (void)
int i; int i;
short *values = XCALLOC (short, nrules + 1); short *values = XCALLOC (short, nrules + 1);
for (i = 0; i < nrules + 1; ++i) for (i = 0; i < nrules + 1; ++i)
values[i] = rule_table[i].rhs; values[i] = rules[i].rhs;
output_table_data (&format_obstack, values, output_table_data (&format_obstack, values,
0, 1, nrules + 1); 0, 1, nrules + 1);
XFREE (values); XFREE (values);
@@ -239,7 +239,7 @@ output_rule_data (void)
{ {
short *values = XCALLOC (short, nrules + 1); short *values = XCALLOC (short, nrules + 1);
for (i = 0; i < nrules + 1; ++i) for (i = 0; i < nrules + 1; ++i)
values[i] = rule_table[i].line; values[i] = rules[i].line;
output_table_data (&format_obstack, values, output_table_data (&format_obstack, values,
0, 1, nrules + 1); 0, 1, nrules + 1);
muscle_insert ("rline", obstack_finish (&format_obstack)); muscle_insert ("rline", obstack_finish (&format_obstack));
@@ -291,7 +291,7 @@ output_rule_data (void)
{ {
short *values = XCALLOC (short, nrules + 1); short *values = XCALLOC (short, nrules + 1);
for (i = 0; i < nrules + 1; ++i) for (i = 0; i < nrules + 1; ++i)
values[i] = rule_table[i].lhs; values[i] = rules[i].lhs;
output_table_data (&format_obstack, values, output_table_data (&format_obstack, values,
0, 1, nrules + 1); 0, 1, nrules + 1);
muscle_insert ("r1", obstack_finish (&format_obstack)); muscle_insert ("r1", obstack_finish (&format_obstack));
@@ -301,8 +301,8 @@ output_rule_data (void)
/* Output YYR2. */ /* Output YYR2. */
short_tab = XMALLOC (short, nrules + 1); short_tab = XMALLOC (short, nrules + 1);
for (i = 1; i < nrules; i++) for (i = 1; i < nrules; i++)
short_tab[i] = rule_table[i + 1].rhs - rule_table[i].rhs - 1; short_tab[i] = rules[i + 1].rhs - rules[i].rhs - 1;
short_tab[nrules] = nritems - rule_table[nrules].rhs - 1; short_tab[nrules] = nritems - rules[nrules].rhs - 1;
output_table_data (&format_obstack, short_tab, output_table_data (&format_obstack, short_tab,
0, 1, nrules + 1); 0, 1, nrules + 1);
muscle_insert ("r2", obstack_finish (&format_obstack)); muscle_insert ("r2", obstack_finish (&format_obstack));
@@ -508,20 +508,20 @@ actions_output (FILE *out, size_t *line)
{ {
int rule; int rule;
for (rule = 1; rule < nrules + 1; ++rule) for (rule = 1; rule < nrules + 1; ++rule)
if (rule_table[rule].action) if (rules[rule].action)
{ {
fprintf (out, " case %d:\n", rule); fprintf (out, " case %d:\n", rule);
if (!no_lines_flag) if (!no_lines_flag)
fprintf (out, muscle_find ("linef"), fprintf (out, muscle_find ("linef"),
rule_table[rule].action_line, rules[rule].action_line,
quotearg_style (c_quoting_style, quotearg_style (c_quoting_style,
muscle_find ("filename"))); muscle_find ("filename")));
/* As a Bison extension, add the ending semicolon. Since some /* As a Bison extension, add the ending semicolon. Since some
Yacc don't do that, help people using bison as a Yacc Yacc don't do that, help people using bison as a Yacc
finding their missing semicolons. */ finding their missing semicolons. */
fprintf (out, "{ %s%s }\n break;\n\n", fprintf (out, "{ %s%s }\n break;\n\n",
rule_table[rule].action, rules[rule].action,
yacc_flag ? ";" : ""); yacc_flag ? ";" : "");
/* We always output 4 '\n' per action. */ /* We always output 4 '\n' per action. */
@@ -530,7 +530,7 @@ actions_output (FILE *out, size_t *line)
if (!no_lines_flag) if (!no_lines_flag)
++*line; ++*line;
/* Get the number of lines written by the user. */ /* 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; int rule;
for (rule = 1; rule < nrules + 1; ++rule) for (rule = 1; rule < nrules + 1; ++rule)
if (rule_table[rule].action) if (rules[rule].action)
{ {
fprintf (out, " case %d:\n", rule); fprintf (out, " case %d:\n", rule);
if (!no_lines_flag) if (!no_lines_flag)
fprintf (out, muscle_find ("linef"), fprintf (out, muscle_find ("linef"),
rule_table[rule].guard_line, rules[rule].guard_line,
quotearg_style (c_quoting_style, quotearg_style (c_quoting_style,
muscle_find ("filename"))); muscle_find ("filename")));
fprintf (out, "{ %s; }\n break;\n\n", fprintf (out, "{ %s; }\n break;\n\n",
rule_table[rule].guard); rules[rule].guard);
/* We always output 4 '\n' per action. */ /* We always output 4 '\n' per action. */
*line += 4; *line += 4;
@@ -562,7 +562,7 @@ guards_output (FILE *out, size_t *line)
if (!no_lines_flag) if (!no_lines_flag)
++*line; ++*line;
/* Get the number of lines written by the user. */ /* 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) if (defines_flag)
header_output (); header_output ();
free (rule_table + 1); free (rules + 1);
obstack_free (&muscle_obstack, NULL); obstack_free (&muscle_obstack, NULL);
obstack_free (&format_obstack, NULL); obstack_free (&format_obstack, NULL);
obstack_free (&action_obstack, NULL); obstack_free (&action_obstack, NULL);

View File

@@ -93,9 +93,9 @@ print_core (FILE *out, state_t *state)
sp++; sp++;
rule = -(*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)); fprintf (out, "%s ", escape (symbols[*sp]->tag));
fputc ('.', out); fputc ('.', out);
@@ -188,7 +188,7 @@ print_reductions (FILE *out, state_t *state)
if (state->consistent) if (state->consistent)
{ {
int rule = redp->rules[0]; 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"), fprintf (out, _(" $default\treduce using rule %d (%s)\n\n"),
rule - 1, escape (symbols[symbol]->tag)); rule - 1, escape (symbols[symbol]->tag));
return; return;
@@ -223,10 +223,10 @@ print_reductions (FILE *out, state_t *state)
if (BITISSET (lookaheadset, i)) if (BITISSET (lookaheadset, i))
fprintf (out, _(" %-4s\t[reduce using rule %d (%s)]\n"), fprintf (out, _(" %-4s\t[reduce using rule %d (%s)]\n"),
escape (symbols[i]->tag), default_rule - 1, 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)
{ {
@@ -282,7 +282,7 @@ print_reductions (FILE *out, state_t *state)
_(" %-4s\treduce using rule %d (%s)\n"), _(" %-4s\treduce using rule %d (%s)\n"),
escape (symbols[i]->tag), escape (symbols[i]->tag),
LAruleno[state->lookaheadsp + j] - 1, 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 else
defaulted = 1; defaulted = 1;
@@ -295,13 +295,13 @@ print_reductions (FILE *out, state_t *state)
_(" %-4s\treduce using rule %d (%s)\n"), _(" %-4s\treduce using rule %d (%s)\n"),
escape (symbols[i]->tag), escape (symbols[i]->tag),
LAruleno[default_LA] - 1, LAruleno[default_LA] - 1,
escape2 (symbols[rule_table[LAruleno[default_LA]].lhs]->tag)); escape2 (symbols[rules[LAruleno[default_LA]].lhs]->tag));
defaulted = 0; defaulted = 0;
fprintf (out, fprintf (out,
_(" %-4s\t[reduce using rule %d (%s)]\n"), _(" %-4s\t[reduce using rule %d (%s)]\n"),
escape (symbols[i]->tag), escape (symbols[i]->tag),
LAruleno[state->lookaheadsp + j] - 1, 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) if (default_LA >= 0)
fprintf (out, _(" $default\treduce using rule %d (%s)\n"), fprintf (out, _(" $default\treduce using rule %d (%s)\n"),
default_rule - 1, 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")); fprintf (out, " %s\n", _("Number, Line, Rule"));
for (i = 1; i <= nrules; i++) for (i = 1; i <= nrules; i++)
/* Don't print rules disabled in reduce_grammar_tables. */ /* Don't print rules disabled in reduce_grammar_tables. */
if (rule_table[i].useful) if (rules[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)); i - 1, rules[i].line, escape (symbols[rules[i].lhs]->tag));
rule = &ritem[rule_table[i].rhs]; rule = &ritem[rules[i].rhs];
if (*rule >= 0) if (*rule >= 0)
while (*rule >= 0) while (*rule >= 0)
fprintf (out, " %s", escape (symbols[*rule++]->tag)); fprintf (out, " %s", escape (symbols[*rule++]->tag));
@@ -401,7 +401,7 @@ print_grammar (FILE *out)
sprintf (buffer, " (%d)", i); sprintf (buffer, " (%d)", i);
for (j = 1; j <= nrules; j++) 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]) if (*rule == token_translations[i])
{ {
END_TEST (65); END_TEST (65);
@@ -420,9 +420,9 @@ print_grammar (FILE *out)
for (j = 1; j <= nrules; j++) for (j = 1; j <= nrules; j++)
{ {
if (rule_table[j].lhs == i) if (rules[j].lhs == i)
left_count++; left_count++;
for (rule = &ritem[rule_table[j].rhs]; *rule >= 0; rule++) for (rule = &ritem[rules[j].rhs]; *rule >= 0; rule++)
if (*rule == i) if (*rule == i)
{ {
right_count++; right_count++;
@@ -444,7 +444,7 @@ print_grammar (FILE *out)
for (j = 1; j <= nrules; j++) for (j = 1; j <= nrules; j++)
{ {
END_TEST (65); END_TEST (65);
if (rule_table[j].lhs == i) if (rules[j].lhs == i)
sprintf (buffer + strlen (buffer), " %d", j - 1); sprintf (buffer + strlen (buffer), " %d", j - 1);
} }
} }
@@ -457,7 +457,7 @@ print_grammar (FILE *out)
sprintf (buffer + strlen (buffer), _(" on right:")); sprintf (buffer + strlen (buffer), _(" on right:"));
for (j = 1; j <= nrules; j++) 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) if (*rule == i)
{ {
END_TEST (65); END_TEST (65);

View File

@@ -78,9 +78,9 @@ print_core (state_t *state, struct obstack *node_obstack)
if (i) if (i)
obstack_1grow (node_obstack, '\n'); obstack_1grow (node_obstack, '\n');
obstack_fgrow1 (node_obstack, " %s -> ", 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_fgrow1 (node_obstack, "%s ", escape (symbols[*sp]->tag));
obstack_1grow (node_obstack, '.'); obstack_1grow (node_obstack, '.');

View File

@@ -1720,7 +1720,7 @@ packgram (void)
fatal (_("too many items (max %d)"), MAXSHORT); fatal (_("too many items (max %d)"), MAXSHORT);
ritem = XCALLOC (short, nitems + 1); ritem = XCALLOC (short, nitems + 1);
rule_table = XCALLOC (rule_t, nrules) - 1; rules = XCALLOC (rule_t, nrules) - 1;
itemno = 0; itemno = 0;
ruleno = 1; ruleno = 1;
@@ -1729,14 +1729,14 @@ packgram (void)
while (p) while (p)
{ {
bucket *ruleprec = p->ruleprec; bucket *ruleprec = p->ruleprec;
rule_table[ruleno].lhs = p->sym->value; rules[ruleno].lhs = p->sym->value;
rule_table[ruleno].rhs = itemno; rules[ruleno].rhs = itemno;
rule_table[ruleno].line = p->line; rules[ruleno].line = p->line;
rule_table[ruleno].useful = TRUE; rules[ruleno].useful = TRUE;
rule_table[ruleno].action = p->action; rules[ruleno].action = p->action;
rule_table[ruleno].action_line = p->action_line; rules[ruleno].action_line = p->action_line;
rule_table[ruleno].guard = p->guard; rules[ruleno].guard = p->guard;
rule_table[ruleno].guard_line = p->guard_line; rules[ruleno].guard_line = p->guard_line;
p = p->next; p = p->next;
while (p && p->sym) while (p && p->sym)
@@ -1746,8 +1746,8 @@ packgram (void)
of the last token in it. */ of the last token in it. */
if (p->sym->class == token_sym) if (p->sym->class == token_sym)
{ {
rule_table[ruleno].prec = p->sym->prec; rules[ruleno].prec = p->sym->prec;
rule_table[ruleno].assoc = p->sym->assoc; rules[ruleno].assoc = p->sym->assoc;
} }
if (p) if (p)
p = p->next; p = p->next;
@@ -1757,9 +1757,9 @@ packgram (void)
the specified symbol's precedence replaces the default. */ the specified symbol's precedence replaces the default. */
if (ruleprec) if (ruleprec)
{ {
rule_table[ruleno].prec = ruleprec->prec; rules[ruleno].prec = ruleprec->prec;
rule_table[ruleno].assoc = ruleprec->assoc; rules[ruleno].assoc = ruleprec->assoc;
rule_table[ruleno].precsym = ruleprec->value; rules[ruleno].precsym = ruleprec->value;
} }
ritem[itemno++] = -ruleno; ritem[itemno++] = -ruleno;

View File

@@ -108,7 +108,7 @@ useful_production (int i, BSet N0)
/* A production is useful if all of the nonterminals in its appear /* A production is useful if all of the nonterminals in its appear
in the set of useful nonterminals. */ 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 (ISVAR (n = *r))
if (!BITISSET (N0, n - ntokens)) if (!BITISSET (N0, n - ntokens))
return FALSE; return FALSE;
@@ -157,7 +157,7 @@ useless_nonterminals (void)
{ {
if (useful_production (i, N)) if (useful_production (i, N))
{ {
SETBIT (Np, rule_table[i].lhs - ntokens); SETBIT (Np, rules[i].lhs - ntokens);
SETBIT (P, i); SETBIT (P, i);
} }
} }
@@ -220,9 +220,9 @@ inaccessable_symbols (void)
{ {
if (!BITISSET (Pp, i) if (!BITISSET (Pp, i)
&& BITISSET (P, 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)) if (ISTOKEN (t = *r) || BITISSET (N, t - ntokens))
SETBIT (Vp, t); SETBIT (Vp, t);
SETBIT (Pp, i); SETBIT (Pp, i);
@@ -258,8 +258,8 @@ inaccessable_symbols (void)
/* A token that was used in %prec should not be warned about. */ /* A token that was used in %prec should not be warned about. */
for (i = 1; i < nrules; i++) for (i = 1; i < nrules; i++)
if (rule_table[i].precsym != 0) if (rules[i].precsym != 0)
SETBIT (V1, rule_table[i].precsym); SETBIT (V1, rules[i].precsym);
} }
static void static void
@@ -289,15 +289,15 @@ reduce_grammar_tables (void)
np++; np++;
if (pn != np) if (pn != np)
{ {
rule_table[np].lhs = rule_table[pn].lhs; rules[np].lhs = rules[pn].lhs;
rule_table[np].line = rule_table[pn].line; rules[np].line = rules[pn].line;
rule_table[np].prec = rule_table[pn].prec; rules[np].prec = rules[pn].prec;
rule_table[np].assoc = rule_table[pn].assoc; rules[np].assoc = rules[pn].assoc;
rule_table[np].rhs = rule_table[pn].rhs; rules[np].rhs = rules[pn].rhs;
if (rule_table[np].rhs != ni) if (rules[np].rhs != ni)
{ {
pi = rule_table[np].rhs; pi = rules[np].rhs;
rule_table[np].rhs = ni; rules[np].rhs = ni;
while (ritem[pi] >= 0) while (ritem[pi] >= 0)
ritem[ni++] = ritem[pi++]; ritem[ni++] = ritem[pi++];
ritem[ni++] = -np; ritem[ni++] = -np;
@@ -324,7 +324,7 @@ reduce_grammar_tables (void)
{ {
int pn; int pn;
for (pn = 1; pn <= nrules; 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++) for (i = 1; i <= nrules; i++)
{ {
rule_table[i].lhs = nontermmap[rule_table[i].lhs]; rules[i].lhs = nontermmap[rules[i].lhs];
if (ISVAR (rule_table[i].precsym)) if (ISVAR (rules[i].precsym))
/* Can this happen? */ /* 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) for (i = 0; i < nritems; ++i)
@@ -422,12 +422,12 @@ reduce_output (FILE *out)
int i; int i;
fprintf (out, "%s\n\n", _("Useless rules:")); fprintf (out, "%s\n\n", _("Useless rules:"));
for (i = 1; i <= nrules; i++) for (i = 1; i <= nrules; i++)
if (!rule_table[i].useful) if (!rules[i].useful)
{ {
rule r; rule r;
fprintf (out, "#%-4d ", i - 1); fprintf (out, "#%-4d ", i - 1);
fprintf (out, "%s:", symbols[rule_table[i].lhs]->tag); fprintf (out, "%s:", symbols[rules[i].lhs]->tag);
for (r = &ritem[rule_table[i].rhs]; *r >= 0; r++) for (r = &ritem[rules[i].rhs]; *r >= 0; r++)
fprintf (out, " %s", symbols[*r]->tag); fprintf (out, " %s", symbols[*r]->tag);
fputs (";\n", out); fputs (";\n", out);
} }
@@ -458,15 +458,15 @@ dump_grammar (FILE *out)
{ {
int rhs_count = 0; int rhs_count = 0;
/* Find the last RHS index in ritems. */ /* 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; ++rhs_count;
fprintf (out, "%3d (%2d, %2d, %2d, %2d-%2d) %2d ->", fprintf (out, "%3d (%2d, %2d, %2d, %2d-%2d) %2d ->",
i - 1, i - 1,
rule_table[i].prec, rule_table[i].assoc, rule_table[i].useful, rules[i].prec, rules[i].assoc, rules[i].useful,
rule_table[i].rhs, rule_table[i].rhs + rhs_count - 1, rules[i].rhs, rules[i].rhs + rhs_count - 1,
rule_table[i].lhs); rules[i].lhs);
/* Dumped the RHS. */ /* 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, "%3d", *r);
fprintf (out, " [%d]\n", -(*r) - 1); fprintf (out, " [%d]\n", -(*r) - 1);
} }
@@ -474,8 +474,8 @@ dump_grammar (FILE *out)
fprintf (out, "Rules interpreted\n-----------------\n\n"); fprintf (out, "Rules interpreted\n-----------------\n\n");
for (i = 1; i <= nrules; i++) for (i = 1; i <= nrules; i++)
{ {
fprintf (out, "%-5d %s :", i, symbols[rule_table[i].lhs]->tag); fprintf (out, "%-5d %s :", i, symbols[rules[i].lhs]->tag);
for (r = &ritem[rule_table[i].rhs]; *r >= 0; r++) for (r = &ritem[rules[i].rhs]; *r >= 0; r++)
fprintf (out, " %s", symbols[*r]->tag); fprintf (out, " %s", symbols[*r]->tag);
fputc ('\n', out); fputc ('\n', out);
} }