* src/LR0.c (set_state_table): state_table holds exactly nstates.
* src/lalr.c (nLA): New.
(initialize_LA, compute_lookaheads, initialize_lookaheads): Use it
instead of lookaheadsp from the pseudo state (nstate + 1).
+2001-12-27 Akim Demaille <akim@epita.fr>
+
+ All the hacks using a final pseudo state are now useless.
+
+ * src/LR0.c (set_state_table): state_table holds exactly nstates.
+ * src/lalr.c (nLA): New.
+ (initialize_LA, compute_lookaheads, initialize_lookaheads): Use it
+ instead of lookaheadsp from the pseudo state (nstate + 1).
+
2001-12-27 Akim Demaille <akim@epita.fr>
* src/output.c (action_row, token_actions): Use a state_t instead
2001-12-27 Akim Demaille <akim@epita.fr>
* src/output.c (action_row, token_actions): Use a state_t instead
static void
set_state_table (void)
{
static void
set_state_table (void)
{
- /* NSTATES + 1 because lookahead for the pseudo state number NSTATES
- might be used (see conflicts.c). It is too opaque for me to
- provide a probably less hacky implementation. --akim */
- state_table = XCALLOC (state_t *, nstates + 1);
+ state_table = XCALLOC (state_t *, nstates);
#include "derives.h"
#include "getargs.h"
#include "derives.h"
#include "getargs.h"
-/* All the decorated states, indexed by the state number. Warning:
- there is a state_TABLE in LR0.c, but it is different and static.
- */
+/* All the decorated states, indexed by the state number. */
state_t **state_table = NULL;
int tokensetsize;
short *LAruleno;
unsigned *LA;
state_t **state_table = NULL;
int tokensetsize;
short *LAruleno;
unsigned *LA;
static int ngotos;
short *goto_map;
static int ngotos;
short *goto_map;
short *np;
reductions *rp;
short *np;
reductions *rp;
- size_t nLA = state_table[nstates]->lookaheadsp;
+ /* Avoid having to special case 0. */
static void
compute_lookaheads (void)
{
static void
compute_lookaheads (void)
{
- for (i = 0; i < state_table[nstates]->lookaheadsp; i++)
+ for (i = 0; i < nLA; i++)
for (sp = lookback[i]; sp; sp = sp->next)
{
int size = LA (i + 1) - LA (i);
for (sp = lookback[i]; sp; sp = sp->next)
{
int size = LA (i + 1) - LA (i);
- for (i = 0; i < state_table[nstates]->lookaheadsp; i++)
+ for (i = 0; i < nLA; i++)
LIST_FREE (shorts, lookback[i]);
XFREE (lookback);
LIST_FREE (shorts, lookback[i]);
XFREE (lookback);
initialize_lookaheads (void)
{
int i;
initialize_lookaheads (void)
{
int i;
for (i = 0; i < nstates; i++)
{
int k;
for (i = 0; i < nstates; i++)
{
int k;
}
state_table[i]->nlookaheads = nlookaheads;
}
state_table[i]->nlookaheads = nlookaheads;
- state_table[i]->lookaheadsp = count;
- count += nlookaheads;
+ state_table[i]->lookaheadsp = nLA;
+ nLA += nlookaheads;
-
- /* Seems to be needed by conflicts.c. */
- state_table[nstates] = STATE_ALLOC (0);
- state_table[nstates]->lookaheadsp = count;