mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 16:53:02 +00:00
* src/lalr.h (reduction_table, shift_table): Removed arrays, which
contents is now members of... (state_t): this structure. * src/output.c, src/lalr.c, src/print_graph.c, src/conflicts.c: Adjust.
This commit is contained in:
@@ -1,3 +1,12 @@
|
|||||||
|
2001-11-19 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
* src/lalr.h (reduction_table, shift_table): Removed arrays, which
|
||||||
|
contents is now members of...
|
||||||
|
(state_t): this structure.
|
||||||
|
* src/output.c, src/lalr.c, src/print_graph.c, src/conflicts.c:
|
||||||
|
Adjust.
|
||||||
|
|
||||||
|
|
||||||
2001-11-19 Akim Demaille <akim@epita.fr>
|
2001-11-19 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* src/lalr.h (state_t): New.
|
* src/lalr.h (state_t): New.
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ flush_shift (int state, int token)
|
|||||||
shifts *shiftp;
|
shifts *shiftp;
|
||||||
int k, i;
|
int k, i;
|
||||||
|
|
||||||
shiftp = shift_table[state];
|
shiftp = state_table[state].shift_table;
|
||||||
|
|
||||||
if (shiftp)
|
if (shiftp)
|
||||||
{
|
{
|
||||||
@@ -197,7 +197,7 @@ set_conflicts (int state)
|
|||||||
for (i = 0; i < tokensetsize; i++)
|
for (i = 0; i < tokensetsize; i++)
|
||||||
lookaheadset[i] = 0;
|
lookaheadset[i] = 0;
|
||||||
|
|
||||||
shiftp = shift_table[state];
|
shiftp = state_table[state].shift_table;
|
||||||
if (shiftp)
|
if (shiftp)
|
||||||
{
|
{
|
||||||
k = shiftp->nshifts;
|
k = shiftp->nshifts;
|
||||||
@@ -288,7 +288,7 @@ count_sr_conflicts (int state)
|
|||||||
|
|
||||||
int src_count = 0;
|
int src_count = 0;
|
||||||
|
|
||||||
shiftp = shift_table[state];
|
shiftp = state_table[state].shift_table;
|
||||||
if (!shiftp)
|
if (!shiftp)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -533,7 +533,7 @@ print_reductions (FILE *out, int state)
|
|||||||
for (i = 0; i < tokensetsize; i++)
|
for (i = 0; i < tokensetsize; i++)
|
||||||
shiftset[i] = 0;
|
shiftset[i] = 0;
|
||||||
|
|
||||||
shiftp = shift_table[state];
|
shiftp = state_table[state].shift_table;
|
||||||
if (shiftp)
|
if (shiftp)
|
||||||
{
|
{
|
||||||
k = shiftp->nshifts;
|
k = shiftp->nshifts;
|
||||||
|
|||||||
61
src/lalr.c
61
src/lalr.c
@@ -43,8 +43,6 @@ short *LAruleno;
|
|||||||
unsigned *LA;
|
unsigned *LA;
|
||||||
|
|
||||||
char *consistent;
|
char *consistent;
|
||||||
shifts **shift_table;
|
|
||||||
reductions **reduction_table;
|
|
||||||
short *goto_map;
|
short *goto_map;
|
||||||
short *from_state;
|
short *from_state;
|
||||||
short *to_state;
|
short *to_state;
|
||||||
@@ -148,39 +146,28 @@ digraph (short **relation)
|
|||||||
static void
|
static void
|
||||||
set_state_table (void)
|
set_state_table (void)
|
||||||
{
|
{
|
||||||
core *sp;
|
|
||||||
|
|
||||||
state_table = XCALLOC (state_t, nstates);
|
state_table = XCALLOC (state_t, nstates);
|
||||||
|
|
||||||
for (sp = first_state; sp; sp = sp->next)
|
{
|
||||||
{
|
core *sp;
|
||||||
state_table[sp->number].state = sp;
|
for (sp = first_state; sp; sp = sp->next)
|
||||||
state_table[sp->number].accessing_symbol = sp->accessing_symbol;
|
{
|
||||||
}
|
state_table[sp->number].state = sp;
|
||||||
}
|
state_table[sp->number].accessing_symbol = sp->accessing_symbol;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
shifts *sp;
|
||||||
|
for (sp = first_shift; sp; sp = sp->next)
|
||||||
|
state_table[sp->number].shift_table = sp;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
{
|
||||||
set_shift_table (void)
|
reductions *rp;
|
||||||
{
|
for (rp = first_reduction; rp; rp = rp->next)
|
||||||
shifts *sp;
|
state_table[rp->number].reduction_table = rp;
|
||||||
|
}
|
||||||
shift_table = XCALLOC (shifts *, nstates);
|
|
||||||
|
|
||||||
for (sp = first_shift; sp; sp = sp->next)
|
|
||||||
shift_table[sp->number] = sp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
set_reduction_table (void)
|
|
||||||
{
|
|
||||||
reductions *rp;
|
|
||||||
|
|
||||||
reduction_table = XCALLOC (reductions *, nstates);
|
|
||||||
|
|
||||||
for (rp = first_reduction; rp; rp = rp->next)
|
|
||||||
reduction_table[rp->number] = rp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -231,8 +218,8 @@ initialize_LA (void)
|
|||||||
|
|
||||||
lookaheads[i] = count;
|
lookaheads[i] = count;
|
||||||
|
|
||||||
rp = reduction_table[i];
|
rp = state_table[i].reduction_table;
|
||||||
sp = shift_table[i];
|
sp = state_table[i].shift_table;
|
||||||
if (rp
|
if (rp
|
||||||
&& (rp->nreds > 1
|
&& (rp->nreds > 1
|
||||||
|| (sp && !ISVAR (state_table[sp->shifts[0]].accessing_symbol))))
|
|| (sp && !ISVAR (state_table[sp->shifts[0]].accessing_symbol))))
|
||||||
@@ -270,7 +257,7 @@ initialize_LA (void)
|
|||||||
{
|
{
|
||||||
if (!consistent[i])
|
if (!consistent[i])
|
||||||
{
|
{
|
||||||
if ((rp = reduction_table[i]))
|
if ((rp = state_table[i].reduction_table))
|
||||||
for (j = 0; j < rp->nreds; j++)
|
for (j = 0; j < rp->nreds; j++)
|
||||||
*np++ = rp->rules[j];
|
*np++ = rp->rules[j];
|
||||||
}
|
}
|
||||||
@@ -408,7 +395,7 @@ initialize_F (void)
|
|||||||
for (i = 0; i < ngotos; i++)
|
for (i = 0; i < ngotos; i++)
|
||||||
{
|
{
|
||||||
stateno = to_state[i];
|
stateno = to_state[i];
|
||||||
sp = shift_table[stateno];
|
sp = state_table[stateno].shift_table;
|
||||||
|
|
||||||
if (sp)
|
if (sp)
|
||||||
{
|
{
|
||||||
@@ -580,7 +567,7 @@ build_relations (void)
|
|||||||
for (rp = ritem + rrhs[*rulep]; *rp > 0; rp++)
|
for (rp = ritem + rrhs[*rulep]; *rp > 0; rp++)
|
||||||
{
|
{
|
||||||
symbol2 = *rp;
|
symbol2 = *rp;
|
||||||
sp = shift_table[stateno];
|
sp = state_table[stateno].shift_table;
|
||||||
k = sp->nshifts;
|
k = sp->nshifts;
|
||||||
|
|
||||||
for (j = 0; j < k; j++)
|
for (j = 0; j < k; j++)
|
||||||
@@ -704,8 +691,6 @@ lalr (void)
|
|||||||
tokensetsize = WORDSIZE (ntokens);
|
tokensetsize = WORDSIZE (ntokens);
|
||||||
|
|
||||||
set_state_table ();
|
set_state_table ();
|
||||||
set_shift_table ();
|
|
||||||
set_reduction_table ();
|
|
||||||
set_maxrhs ();
|
set_maxrhs ();
|
||||||
initialize_LA ();
|
initialize_LA ();
|
||||||
set_goto_map ();
|
set_goto_map ();
|
||||||
|
|||||||
@@ -82,6 +82,9 @@ typedef struct state_s
|
|||||||
|
|
||||||
/* Its accessing symbol. */
|
/* Its accessing symbol. */
|
||||||
short accessing_symbol;
|
short accessing_symbol;
|
||||||
|
|
||||||
|
shifts *shift_table;
|
||||||
|
reductions *reduction_table;
|
||||||
} state_t;
|
} state_t;
|
||||||
|
|
||||||
/* All the decorated states, indexed by the state number. Warning:
|
/* All the decorated states, indexed by the state number. Warning:
|
||||||
@@ -91,8 +94,7 @@ extern state_t *state_table;
|
|||||||
|
|
||||||
extern int tokensetsize;
|
extern int tokensetsize;
|
||||||
extern short *lookaheads;
|
extern short *lookaheads;
|
||||||
extern shifts **shift_table;
|
|
||||||
extern reductions **reduction_table;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -530,7 +530,7 @@ action_row (int state)
|
|||||||
|
|
||||||
default_rule = 0;
|
default_rule = 0;
|
||||||
nreds = 0;
|
nreds = 0;
|
||||||
redp = reduction_table[state];
|
redp = state_table[state].reduction_table;
|
||||||
|
|
||||||
if (redp)
|
if (redp)
|
||||||
{
|
{
|
||||||
@@ -569,7 +569,7 @@ action_row (int state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shiftp = shift_table[state];
|
shiftp = state_table[state].shift_table;
|
||||||
|
|
||||||
/* Now see which tokens are allowed for shifts in this state. For
|
/* Now see which tokens are allowed for shifts in this state. For
|
||||||
them, record the shift as the thing to do. So shift is preferred
|
them, record the shift as the thing to do. So shift is preferred
|
||||||
@@ -747,8 +747,6 @@ free_shifts (void)
|
|||||||
{
|
{
|
||||||
shifts *sp, *sptmp; /* JF derefrenced freed ptr */
|
shifts *sp, *sptmp; /* JF derefrenced freed ptr */
|
||||||
|
|
||||||
XFREE (shift_table);
|
|
||||||
|
|
||||||
for (sp = first_shift; sp; sp = sptmp)
|
for (sp = first_shift; sp; sp = sptmp)
|
||||||
{
|
{
|
||||||
sptmp = sp->next;
|
sptmp = sp->next;
|
||||||
@@ -762,8 +760,6 @@ free_reductions (void)
|
|||||||
{
|
{
|
||||||
reductions *rp, *rptmp; /* JF fixed freed ptr */
|
reductions *rp, *rptmp; /* JF fixed freed ptr */
|
||||||
|
|
||||||
XFREE (reduction_table);
|
|
||||||
|
|
||||||
for (rp = first_reduction; rp; rp = rptmp)
|
for (rp = first_reduction; rp; rp = rptmp)
|
||||||
{
|
{
|
||||||
rptmp = rp->next;
|
rptmp = rp->next;
|
||||||
|
|||||||
@@ -102,8 +102,8 @@ print_actions (FILE *out, int state)
|
|||||||
reductions *redp;
|
reductions *redp;
|
||||||
int rule;
|
int rule;
|
||||||
|
|
||||||
shiftp = shift_table[state];
|
shiftp = state_table[state].shift_table;
|
||||||
redp = reduction_table[state];
|
redp = state_table[state].reduction_table;
|
||||||
errp = err_table[state];
|
errp = err_table[state];
|
||||||
|
|
||||||
if (!shiftp && !redp)
|
if (!shiftp && !redp)
|
||||||
|
|||||||
@@ -104,8 +104,8 @@ print_actions (int state, const char *node_name, struct obstack *node_obstack)
|
|||||||
static char buff[10];
|
static char buff[10];
|
||||||
edge_t edge;
|
edge_t edge;
|
||||||
|
|
||||||
shiftp = shift_table[state];
|
shiftp = state_table[state].shift_table;
|
||||||
redp = reduction_table[state];
|
redp = state_table[state].reduction_table;
|
||||||
errp = err_table[state];
|
errp = err_table[state];
|
||||||
|
|
||||||
if (!shiftp && !redp)
|
if (!shiftp && !redp)
|
||||||
|
|||||||
Reference in New Issue
Block a user