-#include "derives.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.
- */
-state_t *state_table = NULL;
-
-int tokensetsize;
-short *LAruleno;
-unsigned *LA;
-
-short *goto_map;
-short *from_state;
-short *to_state;
-
-extern void berror PARAMS ((const char *));
-
-static int infinity;
-static int ngotos;
-
-/* And for the famous F variable, which name is so descriptive that a
- comment is hardly needed. <grin>. */
-static unsigned *F = NULL;
-#define F(Rule) (F + (Rule) * tokensetsize)
-
-static short **includes;
-static shorts **lookback;
-static short **R;
-static short *INDEX;
-static short *VERTICES;
-static int top;
-
-
-static void
-traverse (int i)
-{
- int j;
- size_t k;
- int height;
- size_t size = F (i + 1) - F(i);
-
- VERTICES[++top] = i;
- INDEX[i] = height = top;
-
- if (R[i])
- for (j = 0; R[i][j] >= 0; ++j)
- {
- if (INDEX[R[i][j]] == 0)
- traverse (R[i][j]);
-
- if (INDEX[i] > INDEX[R[i][j]])
- INDEX[i] = INDEX[R[i][j]];
-
- for (k = 0; k < size; ++k)
- F (i)[k] |= F (R[i][j])[k];
- }
-
- if (INDEX[i] == height)
- for (;;)
- {
- j = VERTICES[top--];
- INDEX[j] = infinity;
-
- if (i == j)
- break;
-
- for (k = 0; k < size; ++k)
- F (i)[k] = F (j)[k];
- }
-}
-
-
-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);
-}
-