1 #define LLALT 9999 /* Alternative is following */
3 #define LLTERMINAL 1 /* Symbol is a terminal */
4 #define LLNONTERMINAL 2 /* Symbol is a nonterminal */
5 #define LLEORULE 0 /* No more alternatives */
8 struct lhs { /* LHS of a rule */
9 int nr; /* Nr of the nonterminal */
10 struct symbol *rhs; /* Pointer to RHS */
11 char first[LLSETSIZE]; /* First set */
12 char follow[LLSETSIZE]; /* Follow set */
13 char empty; /* Set if nonterminal produces empty */
16 struct symbol { /* Symbol in the RHS of a rule */
17 int x; /* LLTERMINAL or LLNONTERMINAL */
18 int nr; /* Nr of the symbol */
19 struct symbol *link; /* Ptr to next rule with this symbol */
20 struct symbol *next; /* Ptr to next symbol in this rule */
21 struct lhs *lhs; /* Ptr to LHS */
24 struct terminal { /* Array with links to terminals in a */
25 struct symbol *link; /* rule */
28 struct nonterminal { /* Array with links to nt's in a rule */
29 struct symbol *link; /* and pointer to LHS's */
33 struct stack_elt { /* Stack element */
34 int flags; /* Some flags */
35 int nr; /* Nr of symbol */
36 int ref_count; /* Nr of predecessors */
37 int hyp_ref_count; /* Temporary nr of predecessors */
38 int matched; /* Nr of LHS trying to match */
39 int nr_nexts; /* Nr of successors */
40 struct edge *edges; /* Array of edges to other stack elt's*/
43 /* Possible flags in a stack element */
44 #define LLHEAD 1 /* Stack element is a head */
45 #define LLDUMMY 2 /* Stack element is substituted */
46 #define LLGEN_SEARCH 8 /* Set by 'generate_heads()' */
49 struct edge { /* Edges of a stack element */
50 char flags; /* Some flags */
51 struct stack_elt *ptr; /* Array with pointers to stack elt's */
54 /* Possible flags in an edge */
55 #define LLLOOP 1 /* Belongs to a loop */
56 #define LLLOOP_SEARCH 2 /* Used by 'loop()' */
57 #define LLHYP_SEARCH 4 /* Used by 'hyp_run()' */
58 #define PRINT_SEARCH 8 /* DEBUG */
59 #define LLMARK_SEARCH 16 /* Used by 'mark_loop()' */
63 #define LLEOSTACK -1 /* Indicates last element of a stack */
64 #define LLHEADS_BUF_INCR 10 /* Nr of elements the buffer will be */
65 #define LLCLEANUP_BUF_INCR 25 /* increased by */
66 #define LL_VIS_INCR 200
68 /* Macro's to manipulate bit sets */
69 #define LLIN(a, i) ((a)[(i)/8] & (1 << ((i) % 8)))
70 #define LLPUTIN(a, i) ((a)[(i)/8] |= (1 << ((i) % 8)))