33 |
#include "derives.h" |
#include "derives.h" |
34 |
#include "getargs.h" |
#include "getargs.h" |
35 |
|
|
36 |
/* All the decorated states, indexed by the state number. Warning: |
/* All the decorated states, indexed by the state number. */ |
|
there is a state_TABLE in LR0.c, but it is different and static. |
|
|
*/ |
|
37 |
state_t **state_table = NULL; |
state_t **state_table = NULL; |
38 |
|
|
39 |
int tokensetsize; |
int tokensetsize; |
40 |
short *LAruleno; |
short *LAruleno; |
41 |
unsigned *LA; |
unsigned *LA; |
42 |
|
size_t nLA; |
43 |
|
|
44 |
static int ngotos; |
static int ngotos; |
45 |
short *goto_map; |
short *goto_map; |
139 |
short *np; |
short *np; |
140 |
reductions *rp; |
reductions *rp; |
141 |
|
|
142 |
size_t nLA = state_table[nstates]->lookaheadsp; |
/* Avoid having to special case 0. */ |
143 |
if (!nLA) |
if (!nLA) |
144 |
nLA = 1; |
nLA = 1; |
145 |
|
|
503 |
static void |
static void |
504 |
compute_lookaheads (void) |
compute_lookaheads (void) |
505 |
{ |
{ |
506 |
int i; |
size_t i; |
507 |
shorts *sp; |
shorts *sp; |
508 |
|
|
509 |
for (i = 0; i < state_table[nstates]->lookaheadsp; i++) |
for (i = 0; i < nLA; i++) |
510 |
for (sp = lookback[i]; sp; sp = sp->next) |
for (sp = lookback[i]; sp; sp = sp->next) |
511 |
{ |
{ |
512 |
int size = LA (i + 1) - LA (i); |
int size = LA (i + 1) - LA (i); |
516 |
} |
} |
517 |
|
|
518 |
/* Free LOOKBACK. */ |
/* Free LOOKBACK. */ |
519 |
for (i = 0; i < state_table[nstates]->lookaheadsp; i++) |
for (i = 0; i < nLA; i++) |
520 |
LIST_FREE (shorts, lookback[i]); |
LIST_FREE (shorts, lookback[i]); |
521 |
|
|
522 |
XFREE (lookback); |
XFREE (lookback); |
532 |
initialize_lookaheads (void) |
initialize_lookaheads (void) |
533 |
{ |
{ |
534 |
int i; |
int i; |
535 |
int count = 0; |
nLA = 0; |
536 |
for (i = 0; i < nstates; i++) |
for (i = 0; i < nstates; i++) |
537 |
{ |
{ |
538 |
int k; |
int k; |
554 |
} |
} |
555 |
|
|
556 |
state_table[i]->nlookaheads = nlookaheads; |
state_table[i]->nlookaheads = nlookaheads; |
557 |
state_table[i]->lookaheadsp = count; |
state_table[i]->lookaheadsp = nLA; |
558 |
count += nlookaheads; |
nLA += nlookaheads; |
559 |
} |
} |
|
|
|
|
/* Seems to be needed by conflicts.c. */ |
|
|
state_table[nstates] = STATE_ALLOC (0); |
|
|
state_table[nstates]->lookaheadsp = count; |
|
560 |
} |
} |
561 |
|
|
562 |
void |
void |