7 static unsigned *first_derives
;
13 register unsigned *row
;
20 rowsize
= WORDSIZE(nvars
);
21 EFF
= NEW2(nvars
* rowsize
, unsigned);
24 for (i
= start_symbol
; i
< nsyms
; i
++)
27 for (rule
= *sp
; rule
> 0; rule
= *++sp
)
29 symbol
= ritem
[rrhs
[rule
]];
32 symbol
-= start_symbol
;
39 reflexive_transitive_closure(EFF
, nvars
);
49 register unsigned *rrow
;
50 register unsigned *vrow
;
53 register unsigned cword
;
61 rulesetsize
= WORDSIZE(nrules
);
62 varsetsize
= WORDSIZE(nvars
);
63 first_derives
= NEW2(nvars
* rulesetsize
, unsigned) - ntokens
* rulesetsize
;
67 rrow
= first_derives
+ ntokens
* rulesetsize
;
68 for (i
= start_symbol
; i
< nsyms
; i
++)
70 vrow
= EFF
+ ((i
- ntokens
) * varsetsize
);
72 for (j
= start_symbol
; j
< nsyms
; k
++, j
++)
74 if (k
>= BITS_PER_WORD
)
83 while ((rule
= *rp
++) >= 0)
95 print_first_derives();
107 register unsigned word
;
110 register unsigned *dsp
;
111 register unsigned *rsp
;
112 register int rulesetsize
;
119 rulesetsize
= WORDSIZE(nrules
);
121 rsend
= ruleset
+ rulesetsize
;
122 for (rsp
= ruleset
; rsp
< rsend
; rsp
++)
126 for (csp
= nucleus
; csp
< csend
; ++csp
)
128 symbol
= ritem
[*csp
];
131 dsp
= first_derives
+ symbol
* rulesetsize
;
139 itemsetend
= itemset
;
141 for (rsp
= ruleset
; rsp
< rsend
; ++rsp
)
146 for (i
= 0; i
< BITS_PER_WORD
; ++i
)
150 itemno
= rrhs
[ruleno
+i
];
151 while (csp
< csend
&& *csp
< itemno
)
152 *itemsetend
++ = *csp
++;
153 *itemsetend
++ = itemno
;
154 while (csp
< csend
&& *csp
== itemno
)
159 ruleno
+= BITS_PER_WORD
;
163 *itemsetend
++ = *csp
++;
176 FREE(first_derives
+ ntokens
* WORDSIZE(nrules
));
187 printf("\n\nn = %d\n\n", n
);
188 for (isp
= itemset
; isp
< itemsetend
; isp
++)
189 printf(" %d\n", *isp
);
196 register unsigned *rowp
;
197 register unsigned word
;
200 printf("\n\nEpsilon Free Firsts\n");
202 for (i
= start_symbol
; i
< nsyms
; i
++)
204 printf("\n%s", symbol_name
[i
]);
205 rowp
= EFF
+ ((i
- start_symbol
) * WORDSIZE(nvars
));
209 for (j
= 0; j
< nvars
; k
++, j
++)
211 if (k
>= BITS_PER_WORD
)
218 printf(" %s", symbol_name
[start_symbol
+ j
]);
224 print_first_derives()
228 register unsigned *rp
;
229 register unsigned cword
;
232 printf("\n\n\nFirst Derives\n");
234 for (i
= start_symbol
; i
< nsyms
; i
++)
236 printf("\n%s derives\n", symbol_name
[i
]);
237 rp
= first_derives
+ i
* WORDSIZE(nrules
);
239 for (j
= 0; j
<= nrules
; k
++, j
++)
241 if (k
>= BITS_PER_WORD
)
247 if (cword
& (1 << k
))