-#include "derives.h"
-
-int tokensetsize;
-short *lookaheads;
-short *LAruleno;
-unsigned *LA;
-short *accessing_symbol;
-char *consistent;
-core **state_table;
-shifts **shift_table;
-reductions **reduction_table;
-short *goto_map;
-short *from_state;
-short *to_state;
-
-extern void berror PARAMS ((const char *));
-
-static int infinity;
-static int maxrhs;
-static int ngotos;
-static unsigned *F;
-static short **includes;
-static shorts **lookback;
-static short **R;
-static short *INDEX;
-static short *VERTICES;
-static int top;
-
-
-static void
-traverse (int i)
-{
- unsigned *fp1;
- unsigned *fp2;
- unsigned *fp3;
- int j;
- short *rp;
-
- int height;
- unsigned *base;
-
- VERTICES[++top] = i;
- INDEX[i] = height = top;
-
- base = F + i * tokensetsize;
- fp3 = base + tokensetsize;
-
- rp = R[i];
- if (rp)
- {
- while ((j = *rp++) >= 0)
- {
- if (INDEX[j] == 0)
- traverse (j);
-
- if (INDEX[i] > INDEX[j])
- INDEX[i] = INDEX[j];
-
- fp1 = base;
- fp2 = F + j * tokensetsize;
-
- while (fp1 < fp3)
- *fp1++ |= *fp2++;
- }
- }
-
- if (INDEX[i] == height)
- {
- for (;;)
- {
- j = VERTICES[top--];
- INDEX[j] = infinity;
-
- if (i == j)
- break;
-
- fp1 = base;
- fp2 = F + j * tokensetsize;
-
- while (fp1 < fp3)
- *fp2++ = *fp1++;
- }
- }
-}
-
-
-static void
-digraph (short **relation)
-{
- int i;
-
- infinity = ngotos + 2;
- INDEX = XCALLOC (short, ngotos + 1);
- VERTICES = XCALLOC (short, ngotos + 1);
- top = 0;
-
- R = relation;
-
- for (i = 0; i < ngotos; i++)
- INDEX[i] = 0;
-
- for (i = 0; i < ngotos; i++)
- {
- if (INDEX[i] == 0 && R[i])
- traverse (i);
- }
-
- XFREE (INDEX);
- XFREE (VERTICES);
-}
-
-static void
-set_state_table (void)
-{
- core *sp;
-
- state_table = XCALLOC (core *, nstates);
-
- for (sp = first_state; sp; sp = sp->next)
- state_table[sp->number] = sp;
-}
-
-
-static void
-set_accessing_symbol (void)
-{
- core *sp;
-
- accessing_symbol = XCALLOC (short, nstates);
-
- for (sp = first_state; sp; sp = sp->next)
- accessing_symbol[sp->number] = sp->accessing_symbol;
-}