mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-22 02:33:03 +00:00
Now that states have a complete set of members, the linked list of
reductions is useless: just fill directly the state's reductions member. * src/state.h (struct reductions): Remove member `number' and `next'. * src/LR0.c (first_reduction, last_reduction): Remove. (save_reductions): Don't link the new reductions, store them in this_state. * src/lalr.c (set_state_table): No need to attach reductions to states, it's already done. * src/output.c (output_actions): No longer free the shifts, then the reductions, then the states: free all the states and their members.
This commit is contained in:
18
ChangeLog
18
ChangeLog
@@ -1,3 +1,21 @@
|
|||||||
|
2001-12-10 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
Now that states have a complete set of members, the linked list of
|
||||||
|
reductions is useless: just fill directly the state's reductions
|
||||||
|
member.
|
||||||
|
|
||||||
|
* src/state.h (struct reductions): Remove member `number' and
|
||||||
|
`next'.
|
||||||
|
* src/LR0.c (first_reduction, last_reduction): Remove.
|
||||||
|
(save_reductions): Don't link the new reductions, store them in
|
||||||
|
this_state.
|
||||||
|
* src/lalr.c (set_state_table): No need to attach reductions to
|
||||||
|
states, it's already done.
|
||||||
|
* src/output.c (output_actions): No longer free the shifts, then
|
||||||
|
the reductions, then the states: free all the states and their
|
||||||
|
members.
|
||||||
|
|
||||||
|
|
||||||
2001-12-10 Akim Demaille <akim@epita.fr>
|
2001-12-10 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* src/options.c (OPTN, DRTV, BOTH): New.
|
* src/options.c (OPTN, DRTV, BOTH): New.
|
||||||
|
|||||||
12
src/LR0.c
12
src/LR0.c
@@ -30,18 +30,17 @@
|
|||||||
#include "complain.h"
|
#include "complain.h"
|
||||||
#include "closure.h"
|
#include "closure.h"
|
||||||
#include "LR0.h"
|
#include "LR0.h"
|
||||||
|
#include "lalr.h"
|
||||||
#include "reduce.h"
|
#include "reduce.h"
|
||||||
|
|
||||||
int nstates;
|
int nstates;
|
||||||
int final_state;
|
int final_state;
|
||||||
state_t *first_state = NULL;
|
state_t *first_state = NULL;
|
||||||
shifts *first_shift = NULL;
|
shifts *first_shift = NULL;
|
||||||
reductions *first_reduction = NULL;
|
|
||||||
|
|
||||||
static state_t *this_state = NULL;
|
static state_t *this_state = NULL;
|
||||||
static state_t *last_state = NULL;
|
static state_t *last_state = NULL;
|
||||||
static shifts *last_shift = NULL;
|
static shifts *last_shift = NULL;
|
||||||
static reductions *last_reduction = NULL;
|
|
||||||
|
|
||||||
static int nshifts;
|
static int nshifts;
|
||||||
static short *shift_symbol = NULL;
|
static short *shift_symbol = NULL;
|
||||||
@@ -551,17 +550,10 @@ save_reductions (void)
|
|||||||
if (count)
|
if (count)
|
||||||
{
|
{
|
||||||
reductions *p = REDUCTIONS_ALLOC (count);
|
reductions *p = REDUCTIONS_ALLOC (count);
|
||||||
|
|
||||||
p->number = this_state->number;
|
|
||||||
p->nreds = count;
|
p->nreds = count;
|
||||||
|
|
||||||
shortcpy (p->rules, redset, count);
|
shortcpy (p->rules, redset, count);
|
||||||
|
|
||||||
if (last_reduction)
|
this_state->reductions = p;
|
||||||
last_reduction->next = p;
|
|
||||||
else
|
|
||||||
first_reduction = p;
|
|
||||||
last_reduction = p;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -156,12 +156,6 @@ set_state_table (void)
|
|||||||
state_table[sp->number]->shifts = sp;
|
state_table[sp->number]->shifts = sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
reductions *rp;
|
|
||||||
for (rp = first_reduction; rp; rp = rp->next)
|
|
||||||
state_table[rp->number]->reductions = rp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Pessimization, but simplification of the code: make sure all the
|
/* Pessimization, but simplification of the code: make sure all the
|
||||||
states have a shifts, even if reduced to 0 shifts. */
|
states have a shifts, even if reduced to 0 shifts. */
|
||||||
{
|
{
|
||||||
|
|||||||
12
src/output.c
12
src/output.c
@@ -885,6 +885,7 @@ output_check (void)
|
|||||||
static void
|
static void
|
||||||
output_actions (void)
|
output_actions (void)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
nvectors = nstates + nvars;
|
nvectors = nstates + nvars;
|
||||||
|
|
||||||
froms = XCALLOC (short *, nvectors);
|
froms = XCALLOC (short *, nvectors);
|
||||||
@@ -893,8 +894,6 @@ output_actions (void)
|
|||||||
width = XCALLOC (short, nvectors);
|
width = XCALLOC (short, nvectors);
|
||||||
|
|
||||||
token_actions ();
|
token_actions ();
|
||||||
LIST_FREE (shifts, first_shift);
|
|
||||||
LIST_FREE (reductions, first_reduction);
|
|
||||||
XFREE (LA);
|
XFREE (LA);
|
||||||
XFREE (LAruleno);
|
XFREE (LAruleno);
|
||||||
|
|
||||||
@@ -910,7 +909,14 @@ output_actions (void)
|
|||||||
output_table ();
|
output_table ();
|
||||||
|
|
||||||
output_check ();
|
output_check ();
|
||||||
LIST_FREE (state_t, first_state);
|
|
||||||
|
for (i = 0; i < nstates; ++i)
|
||||||
|
{
|
||||||
|
XFREE (state_table[i]->shifts);
|
||||||
|
XFREE (state_table[i]->reductions);
|
||||||
|
XFREE (state_table[i]->errs);
|
||||||
|
free (state_table[i]);
|
||||||
|
}
|
||||||
XFREE (state_table);
|
XFREE (state_table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -162,8 +162,6 @@ typedef struct errs
|
|||||||
|
|
||||||
typedef struct reductions
|
typedef struct reductions
|
||||||
{
|
{
|
||||||
struct reductions *next;
|
|
||||||
short number;
|
|
||||||
short nreds;
|
short nreds;
|
||||||
short rules[1];
|
short rules[1];
|
||||||
} reductions;
|
} reductions;
|
||||||
|
|||||||
Reference in New Issue
Block a user