(LArule): this, which is an array to rule_t*.
* src/print.c, src/conflicts.c: Adjust.
+2002-04-07 Akim Demaille <akim@epita.fr>
+
+ * src/lalr.h, src/lalr.c (LAruleno): Replace with...
+ (LArule): this, which is an array to rule_t*.
+ * src/print.c, src/conflicts.c: Adjust.
+
+
2002-04-07 Akim Demaille <akim@epita.fr>
* src/gram.h (rule_t): Rename `number' as `user_number'.
2002-04-07 Akim Demaille <akim@epita.fr>
* src/gram.h (rule_t): Rename `number' as `user_number'.
obstack_fgrow4 (&output_obstack,
_("\
Conflict in state %d between rule %d and token %s resolved as %s.\n"),
obstack_fgrow4 (&output_obstack,
_("\
Conflict in state %d between rule %d and token %s resolved as %s.\n"),
- state->number, LAruleno[LAno], symbols[token]->tag,
+ state->number,
+ LArule[LAno]->number,
+ symbols[token]->tag,
{
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 = rules[LAruleno[lookahead]].prec;
+ int redprec = LArule[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 (rules[LAruleno[state->lookaheadsp + i]].prec
+ if (LArule[state->lookaheadsp + i]->prec
&& !bitset_disjoint_p (LA[state->lookaheadsp + i], lookaheadset))
{
resolve_sr_conflict (state, state->lookaheadsp + i);
&& !bitset_disjoint_p (LA[state->lookaheadsp + i], lookaheadset))
{
resolve_sr_conflict (state, state->lookaheadsp + i);
/* Compute look-ahead criteria for bison,
/* Compute look-ahead criteria for bison,
- Copyright 1984, 1986, 1989, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002
+ Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
This file is part of Bison, the GNU Compiler Compiler.
/* All the decorated states, indexed by the state number. */
state_t **states = NULL;
/* All the decorated states, indexed by the state number. */
state_t **states = NULL;
bitsetv LA = NULL;
size_t nLA;
bitsetv LA = NULL;
size_t nLA;
/* Avoid having to special case 0. */
if (!nLA)
nLA = 1;
LA = bitsetv_create (nLA, ntokens, BITSET_FIXED);
/* Avoid having to special case 0. */
if (!nLA)
nLA = 1;
LA = bitsetv_create (nLA, ntokens, BITSET_FIXED);
- LAruleno = XCALLOC (short, nLA);
+ LArule = XCALLOC (rule_t *, nLA);
lookback = XCALLOC (shorts *, nLA);
lookback = XCALLOC (shorts *, nLA);
for (i = 0; i < nstates; i++)
if (!states[i]->consistent)
for (j = 0; j < states[i]->reductions->nreds; j++)
for (i = 0; i < nstates; i++)
if (!states[i]->consistent)
for (j = 0; j < states[i]->reductions->nreds; j++)
- *np++ = states[i]->reductions->rules[j];
+ *np++ = &rules[states[i]->reductions->rules[j]];
shorts *sp;
for (i = 0; i < state->nlookaheads; ++i)
shorts *sp;
for (i = 0; i < state->nlookaheads; ++i)
- if (LAruleno[state->lookaheadsp + i] == ruleno)
+ if (LArule[state->lookaheadsp + i]->number == ruleno)
- assert (LAruleno[state->lookaheadsp + i] == ruleno);
+ assert (LArule[state->lookaheadsp + i]->number == ruleno);
sp = XCALLOC (shorts, 1);
sp->next = lookback[state->lookaheadsp + i];
sp = XCALLOC (shorts, 1);
sp->next = lookback[state->lookaheadsp + i];
if (bitset_test (LA[states[i]->lookaheadsp + j], j))
fprintf (out, " on %d (%s) -> rule %d\n",
k, symbols[k]->tag,
if (bitset_test (LA[states[i]->lookaheadsp + j], j))
fprintf (out, " on %d (%s) -> rule %d\n",
k, symbols[k]->tag,
- -LAruleno[states[i]->lookaheadsp + j] - 1);
+ LArule[states[i]->lookaheadsp + j]->number - 1);
}
fprintf (out, "Lookaheads: END\n");
}
}
fprintf (out, "Lookaheads: END\n");
}
/* Compute look-ahead criteria for bison,
/* Compute look-ahead criteria for bison,
- Copyright 1984, 1986, 1989, 2000, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1986, 1989, 2000, 2002 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
This file is part of Bison, the GNU Compiler Compiler.
/* Import the definition of CORE, SHIFTS and REDUCTIONS. */
# include "state.h"
/* Import the definition of CORE, SHIFTS and REDUCTIONS. */
# include "state.h"
+/* Import the definition of RULE_T. */
+# include "gram.h"
/* Compute how to make the finite state machine deterministic; find
which rules need lookahead in each state, and which lookahead
/* Compute how to make the finite state machine deterministic; find
which rules need lookahead in each state, and which lookahead
extern short *from_state;
extern short *to_state;
extern short *from_state;
extern short *to_state;
-/* LARULENO is a vector which records the rules that need lookahead in
- various states. The elements of LARULENO that apply to state S are
- those from LOOKAHEADS[S] through LOOKAHEADS[S+1]-1. Each element
- of LARULENO is a rule number.
+/* LARULE is a vector which records the rules that need lookahead in
+ various states. The elements of LARULE that apply to state S are
+ those from LOOKAHEADS[S] through LOOKAHEADS[S+1]-1.
- If LR is the length of LAruleno, then a number from 0 to LR-1 can
+ If LR is the length of LArule, then a number from 0 to LR-1 can
specify both a rule and a state where the rule might be applied.
*/
specify both a rule and a state where the rule might be applied.
*/
/* LA is a lr by ntokens matrix of bits. LA[l, i] is 1 if the rule
LAruleno[l] is applicable in the appropriate state when the next
/* LA is a lr by ntokens matrix of bits. LA[l, i] is 1 if the rule
LAruleno[l] is applicable in the appropriate state when the next
/* and record this rule as the rule to use if that
token follows. */
if (bitset_test (LA[state->lookaheadsp + i], j))
/* and record this rule as the rule to use if that
token follows. */
if (bitset_test (LA[state->lookaheadsp + i], j))
- actrow[j] = -LAruleno[state->lookaheadsp + i];
+ actrow[j] = -LArule[state->lookaheadsp + i]->number;
}
/* Now see which tokens are allowed for shifts in this state. For
}
/* Now see which tokens are allowed for shifts in this state. For
for (i = 0; i < state->nlookaheads; i++)
{
int count = 0;
for (i = 0; i < state->nlookaheads; i++)
{
int count = 0;
- int rule = -LAruleno[state->lookaheadsp + i];
+ int rule = -LArule[state->lookaheadsp + i]->number;
int j;
for (j = 0; j < ntokens; j++)
int j;
for (j = 0; j < ntokens; j++)
token_actions ();
bitsetv_free (LA);
token_actions ();
bitsetv_free (LA);
goto_actions ();
XFREE (goto_map + ntokens);
goto_actions ();
XFREE (goto_map + ntokens);
/* Print information on generated parser, for bison,
/* Print information on generated parser, for bison,
- Copyright 1984, 1986, 1989, 2000, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002
+ Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
This file is part of Bison, the GNU Compiler Compiler.
if (state->nlookaheads == 1 && !nodefault)
{
if (state->nlookaheads == 1 && !nodefault)
{
- int default_rule = LAruleno[state->lookaheadsp];
+ rule_t *default_rule = LArule[state->lookaheadsp];
bitset_and (lookaheadset, LA[state->lookaheadsp], shiftset);
for (i = 0; i < ntokens; i++)
if (bitset_test (lookaheadset, i))
fprintf (out, _(" %-4s\t[reduce using rule %d (%s)]\n"),
bitset_and (lookaheadset, LA[state->lookaheadsp], shiftset);
for (i = 0; i < ntokens; i++)
if (bitset_test (lookaheadset, i))
fprintf (out, _(" %-4s\t[reduce using rule %d (%s)]\n"),
- escape (symbols[i]->tag), default_rule - 1,
- escape2 (rules[default_rule].lhs->tag));
+ escape (symbols[i]->tag),
+ default_rule->number - 1,
+ escape2 (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 (rules[default_rule].lhs->tag));
+ default_rule->number - 1,
+ escape (default_rule->lhs->tag));
}
else if (state->nlookaheads >= 1)
{
int cmax = 0;
int default_LA = -1;
}
else if (state->nlookaheads >= 1)
{
int cmax = 0;
int default_LA = -1;
+ rule_t *default_rule = NULL;
if (!nodefault)
for (i = 0; i < state->nlookaheads; ++i)
if (!nodefault)
for (i = 0; i < state->nlookaheads; ++i)
{
cmax = count;
default_LA = state->lookaheadsp + i;
{
cmax = count;
default_LA = state->lookaheadsp + i;
- default_rule = LAruleno[state->lookaheadsp + i];
+ default_rule = LArule[state->lookaheadsp + i];
}
bitset_or (shiftset, shiftset, lookaheadset);
}
bitset_or (shiftset, shiftset, lookaheadset);
fprintf (out,
_(" %-4s\treduce using rule %d (%s)\n"),
escape (symbols[i]->tag),
fprintf (out,
_(" %-4s\treduce using rule %d (%s)\n"),
escape (symbols[i]->tag),
- LAruleno[state->lookaheadsp + j] - 1,
- escape2 (rules[LAruleno[state->lookaheadsp + j]].lhs->tag));
+ LArule[state->lookaheadsp + j]->number - 1,
+ escape2 (LArule[state->lookaheadsp + j]->lhs->tag));
fprintf (out,
_(" %-4s\treduce using rule %d (%s)\n"),
escape (symbols[i]->tag),
fprintf (out,
_(" %-4s\treduce using rule %d (%s)\n"),
escape (symbols[i]->tag),
- LAruleno[default_LA] - 1,
- escape2 (rules[LAruleno[default_LA]].lhs->tag));
+ LArule[default_LA]->number - 1,
+ escape2 (LArule[default_LA]->lhs->tag));
defaulted = 0;
fprintf (out,
_(" %-4s\t[reduce using rule %d (%s)]\n"),
escape (symbols[i]->tag),
defaulted = 0;
fprintf (out,
_(" %-4s\t[reduce using rule %d (%s)]\n"),
escape (symbols[i]->tag),
- LAruleno[state->lookaheadsp + j] - 1,
- escape2 (rules[LAruleno[state->lookaheadsp + j]].lhs->tag));
+ LArule[state->lookaheadsp + j]->number - 1,
+ escape2 (LArule[state->lookaheadsp + j]->lhs->tag));
}
}
}
if (default_LA >= 0)
fprintf (out, _(" $default\treduce using rule %d (%s)\n"),
}
}
}
if (default_LA >= 0)
fprintf (out, _(" $default\treduce using rule %d (%s)\n"),
- default_rule - 1,
- escape (rules[default_rule].lhs->tag));
+ default_rule->number - 1,
+ escape (default_rule->lhs->tag));