to the bucket giving the priority/associativity.
Member `associativity' removed: useless.
* src/reduce.c, src/conflicts.c: Adjust.
+2002-04-07 Akim Demaille <akim@epita.fr>
+
+ * src/gram.h (rule_s): prec and precsym are now pointers
+ to the bucket giving the priority/associativity.
+ Member `associativity' removed: useless.
+ * src/reduce.c, src/conflicts.c: Adjust.
+
2002-04-07 Akim Demaille <akim@epita.fr>
* src/lalr.c, src/LR0.c, src/closure.c, src/gram.c, src/reduce.c:
/* Find and resolve or report look-ahead conflicts for bison,
- Copyright 1984, 1989, 1992, 2000, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989, 1992, 2000, 2001, 2002
+ Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
{
int i;
/* find the rule to reduce by to get precedence of reduction */
- int redprec = LArule[lookahead]->prec;
+ int redprec = LArule[lookahead]->prec->prec;
errs *errp = errs_new (ntokens + 1);
errp->nerrs = 0;
precedence */
for (i = 0; i < state->nlookaheads; ++i)
if (LArule[state->lookaheadsp + i]->prec
+ && LArule[state->lookaheadsp + i]->prec->prec
&& !bitset_disjoint_p (LA[state->lookaheadsp + i], lookaheadset))
{
resolve_sr_conflict (state, state->lookaheadsp + i);
RULES is an array of struct rule_s, which members are:
- 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.
+ RULES[R].lhs -- the symbol of the left hand side of rule R.
RULES[R].rhs -- the index in RITEM of the beginning of the portion
for rule R.
- RULES[R].prec -- the precedence level of R.
+ RULES[R].prec -- the symbol providing the precedence level of R.
- RULES[R].precsym -- the symbol-number of the symbol in %prec for R
- (if any).
+ RULES[R].precsym -- the symbol attached (via %prec) to give its
+ precedence to R. Of course, if set, it is equal to `prec', but we
+ need to distinguish one from the other when reducing: a symbol used
+ in a %prec is not useless.
RULES[R].assoc -- the associativity of R.
RULES[R].line -- the line where R was defined.
- RULES[R].useful -- TRUE iff the rule is used.
+ RULES[R].useful -- TRUE iff the rule is used (i.e., FALSE if thrown
+ away by reduce).
The right hand side is stored as symbol numbers in a portion of
RITEM.
bucket *lhs;
short *rhs;
- short prec;
- short precsym;
- associativity assoc;
+
+ /* This symbol provides both the associativity, and the precedence. */
+ bucket *prec;
+
+ /* This symbol was attached to the rule via %prec. */
+ bucket *precsym;
+
short line;
bool useful;
/* A rule gets by default the precedence and associativity
of the last token in it. */
if (p->sym->class == token_sym)
- {
- rules[ruleno].prec = p->sym->prec;
- rules[ruleno].assoc = p->sym->assoc;
- }
+ rules[ruleno].prec = p->sym;
if (p)
p = p->next;
}
the specified symbol's precedence replaces the default. */
if (ruleprec)
{
- rules[ruleno].prec = ruleprec->prec;
- rules[ruleno].assoc = ruleprec->assoc;
- rules[ruleno].precsym = ruleprec->number;
+ rules[ruleno].precsym = ruleprec;
+ rules[ruleno].prec = ruleprec;
}
-
ritem[itemno++] = -ruleno;
ruleno++;
/* A token that was used in %prec should not be warned about. */
for (i = 1; i < nrules + 1; i++)
if (rules[i].precsym != 0)
- bitset_set (V1, rules[i].precsym);
+ bitset_set (V1, rules[i].precsym->number);
}
free (symbols_sorted + ntokens);
}
- /* Replace all symbol numbers in valid data structures. */
-
- for (i = 1; i < nrules + 1; i++)
- {
- if (ISVAR (rules[i].precsym))
- /* Can this happen? */
- rules[i].precsym = nontermmap[rules[i].precsym];
- }
-
for (i = 0; i < nritems; ++i)
if (ISVAR (ritem[i]))
ritem[i] = nontermmap[ritem[i]];
++rhs_count;
fprintf (out, "%3d (%2d, %2d, %2d, %2d-%2d) %2d ->",
i - 1,
- rules[i].prec, rules[i].assoc, rules[i].useful,
- rules[i].rhs - ritem, rules[i].rhs - ritem + rhs_count - 1,
+ rules[i].prec->prec,
+ rules[i].prec->assoc,
+ rules[i].useful,
+ rules[i].rhs - ritem,
+ rules[i].rhs - ritem + rhs_count - 1,
rules[i].lhs->number);
/* Dumped the RHS. */
for (r = rules[i].rhs; *r >= 0; r++)
/* Definitions for symtab.c and callers, part of bison,
- Copyright 1984, 1989, 1992, 2000, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989, 1992, 2000, 2001, 2002
+ Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.