1 |
/* Subroutines for bison |
/* Subroutines for bison |
2 |
Copyright 1984, 1989, 2000 Free Software Foundation, Inc. |
Copyright 1984, 1989, 2000, 2001 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of Bison, the GNU Compiler Compiler. |
This file is part of Bison, the GNU Compiler Compiler. |
5 |
|
|
20 |
|
|
21 |
#include "system.h" |
#include "system.h" |
22 |
#include "gram.h" |
#include "gram.h" |
23 |
|
#include "reader.h" |
24 |
#include "closure.h" |
#include "closure.h" |
25 |
#include "derives.h" |
#include "derives.h" |
26 |
#include "warshall.h" |
#include "warshall.h" |
39 |
/* number of words required to hold a bit for each variable */ |
/* number of words required to hold a bit for each variable */ |
40 |
static int varsetsize; |
static int varsetsize; |
41 |
|
|
42 |
#if DEBUG |
#if TRACE |
43 |
|
|
44 |
/*-----------------. |
/*-----------------. |
45 |
| Debugging code. | |
| Debugging code. | |
50 |
{ |
{ |
51 |
short *isp; |
short *isp; |
52 |
|
|
53 |
printf ("\n\nn = %d\n\n", n); |
fprintf (stderr, "\n\nn = %d\n\n", n); |
54 |
for (isp = itemset; isp < itemsetend; isp++) |
for (isp = itemset; isp < itemsetend; isp++) |
55 |
printf (" %d\n", *isp); |
fprintf (stderr, " %d\n", *isp); |
56 |
} |
} |
57 |
|
|
58 |
|
|
63 |
int j; |
int j; |
64 |
unsigned *rowp; |
unsigned *rowp; |
65 |
|
|
66 |
printf ("\n\n\nFIRSTS\n\n"); |
fprintf (stderr, "\n\n\nFIRSTS\n\n"); |
67 |
|
|
68 |
for (i = ntokens; i < nsyms; i++) |
for (i = ntokens; i < nsyms; i++) |
69 |
{ |
{ |
70 |
printf ("\n\n%s firsts\n\n", tags[i]); |
fprintf (stderr, "\n\n%s firsts\n\n", tags[i]); |
71 |
|
|
72 |
rowp = firsts + ((i - ntokens) * varsetsize); |
rowp = firsts + ((i - ntokens) * varsetsize); |
73 |
|
|
74 |
for (j = 0; j < nvars; j++) |
for (j = 0; j < nvars; j++) |
75 |
if (BITISSET (rowp, j)) |
if (BITISSET (rowp, j)) |
76 |
printf (" %s\n", tags[j + ntokens]); |
fprintf (stderr, " %s\n", tags[j + ntokens]); |
77 |
} |
} |
78 |
} |
} |
79 |
|
|
85 |
int j; |
int j; |
86 |
unsigned *rp; |
unsigned *rp; |
87 |
|
|
88 |
printf ("\n\n\nFDERIVES\n"); |
fprintf (stderr, "\n\n\nFDERIVES\n"); |
89 |
|
|
90 |
for (i = ntokens; i < nsyms; i++) |
for (i = ntokens; i < nsyms; i++) |
91 |
{ |
{ |
92 |
printf ("\n\n%s derives\n\n", tags[i]); |
fprintf (stderr, "\n\n%s derives\n\n", tags[i]); |
93 |
rp = fderives + i * rulesetsize; |
rp = fderives + i * rulesetsize; |
94 |
|
|
95 |
for (j = 0; j <= nrules; j++) |
for (j = 0; j <= nrules; j++) |
96 |
if (BITISSET (rp, j)) |
if (BITISSET (rp, j)) |
97 |
printf (" %d\n", j); |
fprintf (stderr, " %d\n", j); |
98 |
} |
} |
|
|
|
|
fflush (stdout); |
|
99 |
} |
} |
100 |
#endif |
#endif |
101 |
|
|
142 |
|
|
143 |
RTC (firsts, nvars); |
RTC (firsts, nvars); |
144 |
|
|
145 |
#ifdef DEBUG |
#ifdef TRACE |
146 |
print_firsts (); |
print_firsts (); |
147 |
#endif |
#endif |
148 |
} |
} |
203 |
rrow += rulesetsize; |
rrow += rulesetsize; |
204 |
} |
} |
205 |
|
|
206 |
#ifdef DEBUG |
#ifdef TRACE |
207 |
print_fderives (); |
print_fderives (); |
208 |
#endif |
#endif |
209 |
|
|
300 |
while (csp < csend) |
while (csp < csend) |
301 |
*itemsetend++ = *csp++; |
*itemsetend++ = *csp++; |
302 |
|
|
303 |
#if DEBUG |
#if TRACE |
304 |
print_closure (n); |
print_closure (n); |
305 |
#endif |
#endif |
306 |
} |
} |