mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-17 08:13:02 +00:00
* src/state.h (SHIFT_SYMBOL): New.
* src/conflicts.c: Use it to deobfuscate.
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2001-12-05 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
* src/state.h (SHIFT_SYMBOL): New.
|
||||||
|
* src/conflicts.c: Use it to deobfuscate.
|
||||||
|
|
||||||
|
|
||||||
2001-12-05 Akim Demaille <akim@epita.fr>
|
2001-12-05 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* src/conflicts.c (count_sr_conflicts, count_rr_conflicts)
|
* src/conflicts.c (count_sr_conflicts, count_rr_conflicts)
|
||||||
|
|||||||
@@ -184,7 +184,6 @@ set_conflicts (int state)
|
|||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
shifts *shiftp;
|
shifts *shiftp;
|
||||||
int symbol;
|
|
||||||
|
|
||||||
if (state_table[state].consistent)
|
if (state_table[state].consistent)
|
||||||
return;
|
return;
|
||||||
@@ -194,13 +193,8 @@ set_conflicts (int state)
|
|||||||
|
|
||||||
shiftp = state_table[state].shift_table;
|
shiftp = state_table[state].shift_table;
|
||||||
if (shiftp)
|
if (shiftp)
|
||||||
for (i = 0; i < shiftp->nshifts; i++)
|
for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)
|
||||||
{
|
SETBIT (lookaheadset, SHIFT_SYMBOL (shiftp, i));
|
||||||
symbol = state_table[shiftp->shifts[i]].accessing_symbol;
|
|
||||||
if (ISVAR (symbol))
|
|
||||||
break;
|
|
||||||
SETBIT (lookaheadset, symbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Loop over all rules which require lookahead in this state. First
|
/* Loop over all rules which require lookahead in this state. First
|
||||||
check for shift-reduce conflict, and try to resolve using
|
check for shift-reduce conflict, and try to resolve using
|
||||||
@@ -269,10 +263,7 @@ count_sr_conflicts (int state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)
|
for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)
|
||||||
{
|
SETBIT (shiftset, SHIFT_SYMBOL (shiftp, i));
|
||||||
int symbol = state_table[shiftp->shifts[i]].accessing_symbol;
|
|
||||||
SETBIT (shiftset, symbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = state_table[state].lookaheads;
|
for (i = state_table[state].lookaheads;
|
||||||
i < state_table[state + 1].lookaheads;
|
i < state_table[state + 1].lookaheads;
|
||||||
@@ -451,7 +442,6 @@ print_reductions (FILE *out, int state)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
int symbol;
|
|
||||||
int m;
|
int m;
|
||||||
int n;
|
int n;
|
||||||
shifts *shiftp;
|
shifts *shiftp;
|
||||||
@@ -463,18 +453,13 @@ print_reductions (FILE *out, int state)
|
|||||||
|
|
||||||
shiftp = state_table[state].shift_table;
|
shiftp = state_table[state].shift_table;
|
||||||
if (shiftp)
|
if (shiftp)
|
||||||
for (i = 0; i < shiftp->nshifts; i++)
|
for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)
|
||||||
{
|
{
|
||||||
if (!shiftp->shifts[i])
|
/* if this state has a shift for the error token, don't use a
|
||||||
continue;
|
default rule. */
|
||||||
symbol = state_table[shiftp->shifts[i]].accessing_symbol;
|
if (SHIFT_IS_ERROR (shiftp, i))
|
||||||
if (ISVAR (symbol))
|
|
||||||
break;
|
|
||||||
/* if this state has a shift for the error token,
|
|
||||||
don't use a default rule. */
|
|
||||||
if (symbol == error_token_number)
|
|
||||||
nodefault = 1;
|
nodefault = 1;
|
||||||
SETBIT (shiftset, symbol);
|
SETBIT (shiftset, SHIFT_SYMBOL (shiftp, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
errp = err_table[state];
|
errp = err_table[state];
|
||||||
@@ -538,15 +523,8 @@ print_reductions (FILE *out, int state)
|
|||||||
shiftset[i] = 0;
|
shiftset[i] = 0;
|
||||||
|
|
||||||
if (shiftp)
|
if (shiftp)
|
||||||
for (i = 0; i < shiftp->nshifts; i++)
|
for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)
|
||||||
{
|
SETBIT (shiftset, SHIFT_SYMBOL (shiftp, i));
|
||||||
if (!shiftp->shifts[i])
|
|
||||||
continue;
|
|
||||||
symbol = state_table[shiftp->shifts[i]].accessing_symbol;
|
|
||||||
if (ISVAR (symbol))
|
|
||||||
break;
|
|
||||||
SETBIT (shiftset, symbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < ntokens; i++)
|
for (i = 0; i < ntokens; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
11
src/state.h
11
src/state.h
@@ -124,10 +124,17 @@ typedef struct shifts
|
|||||||
(shifts *) xcalloc ((unsigned) (sizeof (shifts) \
|
(shifts *) xcalloc ((unsigned) (sizeof (shifts) \
|
||||||
+ (Nshifts - 1) * sizeof (short)), 1)
|
+ (Nshifts - 1) * sizeof (short)), 1)
|
||||||
|
|
||||||
|
/* What is the symbol which is shifted by SHIFTS->shifts[Shift]? Can
|
||||||
|
be a token (amongst which the error token), or non terminals in
|
||||||
|
case of gotos. */
|
||||||
|
|
||||||
|
#define SHIFT_SYMBOL(Shifts, Shift) \
|
||||||
|
(state_table[Shifts->shifts[Shift]].accessing_symbol)
|
||||||
|
|
||||||
/* Is the SHIFTS->shifts[Shift] a real shift? (as opposed to gotos.) */
|
/* Is the SHIFTS->shifts[Shift] a real shift? (as opposed to gotos.) */
|
||||||
|
|
||||||
#define SHIFT_IS_SHIFT(Shifts, Shift) \
|
#define SHIFT_IS_SHIFT(Shifts, Shift) \
|
||||||
(ISTOKEN (state_table[Shifts->shifts[Shift]].accessing_symbol))
|
(ISTOKEN (SHIFT_SYMBOL (Shifts, Shift)))
|
||||||
|
|
||||||
/* Is the SHIFTS->shifts[Shift] a goto?. */
|
/* Is the SHIFTS->shifts[Shift] a goto?. */
|
||||||
|
|
||||||
@@ -137,7 +144,7 @@ typedef struct shifts
|
|||||||
/* Is the SHIFTS->shifts[Shift] then handling of the error token?. */
|
/* Is the SHIFTS->shifts[Shift] then handling of the error token?. */
|
||||||
|
|
||||||
#define SHIFT_IS_ERROR(Shifts, Shift) \
|
#define SHIFT_IS_ERROR(Shifts, Shift) \
|
||||||
(state_table[Shifts->shifts[Shift]].accessing_symbol == error_token_number)
|
(SHIFT_SYMBOL (Shifts, Shift) == error_token_number)
|
||||||
|
|
||||||
|
|
||||||
/*-------.
|
/*-------.
|
||||||
|
|||||||
Reference in New Issue
Block a user