94 |
#include "obstack.h" |
#include "obstack.h" |
95 |
#include "quotearg.h" |
#include "quotearg.h" |
96 |
#include "getargs.h" |
#include "getargs.h" |
|
#include "xalloc.h" |
|
97 |
#include "files.h" |
#include "files.h" |
98 |
#include "gram.h" |
#include "gram.h" |
99 |
#include "LR0.h" |
#include "LR0.h" |
108 |
|
|
109 |
static int nvectors; |
static int nvectors; |
110 |
static int nentries; |
static int nentries; |
111 |
static short **froms; |
static short **froms = NULL; |
112 |
static short **tos; |
static short **tos = NULL; |
113 |
static short *tally; |
static short *tally = NULL; |
114 |
static short *width; |
static short *width = NULL; |
115 |
static short *actrow; |
static short *actrow = NULL; |
116 |
static short *state_count; |
static short *state_count = NULL; |
117 |
static short *order; |
static short *order = NULL; |
118 |
static short *base; |
static short *base = NULL; |
119 |
static short *pos; |
static short *pos = NULL; |
120 |
static short *table; |
static short *table = NULL; |
121 |
static short *check; |
static short *check = NULL; |
122 |
static int lowzero; |
static int lowzero; |
123 |
static int high; |
static int high; |
124 |
|
|
128 |
/* FIXME. */ |
/* FIXME. */ |
129 |
|
|
130 |
static inline void |
static inline void |
131 |
output_table_data (struct obstack *oout, |
output_table_data (struct obstack *oout, |
132 |
short *table_data, |
short *table_data, |
133 |
short first, |
short first, |
134 |
short begin, |
short begin, |
135 |
short end) |
short end) |
136 |
{ |
{ |
137 |
int i; |
int i; |
138 |
int j = 1; |
int j = 1; |
139 |
|
|
140 |
obstack_fgrow1 (oout, "%6d", first); |
obstack_fgrow1 (oout, "%6d", first); |
141 |
for (i = begin; i < end; ++i) |
for (i = begin; i < end; ++i) |
142 |
{ |
{ |
157 |
static void |
static void |
158 |
output_token_translations (void) |
output_token_translations (void) |
159 |
{ |
{ |
160 |
output_table_data (&output_obstack, token_translations, |
output_table_data (&output_obstack, token_translations, |
161 |
0, 1, max_user_token_number + 1); |
0, 1, max_user_token_number + 1); |
162 |
muscle_insert ("translate", obstack_finish (&output_obstack)); |
muscle_insert ("translate", obstack_finish (&output_obstack)); |
163 |
|
XFREE (token_translations); |
164 |
} |
} |
165 |
|
|
166 |
|
|
167 |
static void |
static void |
168 |
output_gram (void) |
output_gram (void) |
169 |
{ |
{ |
170 |
output_table_data (&output_obstack, rrhs, |
output_table_data (&output_obstack, rrhs, |
171 |
0, 1, nrules + 1); |
0, 1, nrules + 1); |
172 |
muscle_insert ("prhs", obstack_finish (&output_obstack)); |
muscle_insert ("prhs", obstack_finish (&output_obstack)); |
173 |
|
|
174 |
{ |
{ |
175 |
size_t yyrhs_size = 1; |
size_t yyrhs_size = 1; |
176 |
short *yyrhs, *sp; |
short *yyrhs, *sp; |
183 |
for (sp = ritem + 1, i = 1; *sp; ++sp, ++i) |
for (sp = ritem + 1, i = 1; *sp; ++sp, ++i) |
184 |
yyrhs[i] = *sp > 0 ? *sp : 0; |
yyrhs[i] = *sp > 0 ? *sp : 0; |
185 |
|
|
186 |
output_table_data (&output_obstack, yyrhs, |
output_table_data (&output_obstack, yyrhs, |
187 |
ritem[0], 1, yyrhs_size); |
ritem[0], 1, yyrhs_size); |
188 |
muscle_insert ("rhs", obstack_finish (&output_obstack)); |
muscle_insert ("rhs", obstack_finish (&output_obstack)); |
189 |
|
|
200 |
static void |
static void |
201 |
output_stos (void) |
output_stos (void) |
202 |
{ |
{ |
203 |
output_table_data (&output_obstack, accessing_symbol, |
output_table_data (&output_obstack, accessing_symbol, |
204 |
0, 1, nstates); |
0, 1, nstates); |
205 |
muscle_insert ("stos", obstack_finish (&output_obstack)); |
muscle_insert ("stos", obstack_finish (&output_obstack)); |
206 |
} |
} |
275 |
muscle_insert ("toknum", obstack_finish (&output_obstack)); |
muscle_insert ("toknum", obstack_finish (&output_obstack)); |
276 |
|
|
277 |
/* Output YYR1. */ |
/* Output YYR1. */ |
278 |
output_table_data (&output_obstack, rlhs, |
output_table_data (&output_obstack, rlhs, |
279 |
0, 1, nrules + 1); |
0, 1, nrules + 1); |
280 |
muscle_insert ("r1", obstack_finish (&output_obstack)); |
muscle_insert ("r1", obstack_finish (&output_obstack)); |
281 |
XFREE (rlhs + 1); |
XFREE (rlhs + 1); |
285 |
for (i = 1; i < nrules; i++) |
for (i = 1; i < nrules; i++) |
286 |
short_tab[i] = rrhs[i + 1] - rrhs[i] - 1; |
short_tab[i] = rrhs[i + 1] - rrhs[i] - 1; |
287 |
short_tab[nrules] = nitems - rrhs[nrules] - 1; |
short_tab[nrules] = nitems - rrhs[nrules] - 1; |
288 |
output_table_data (&output_obstack, short_tab, |
output_table_data (&output_obstack, short_tab, |
289 |
0, 1, nrules + 1); |
0, 1, nrules + 1); |
290 |
muscle_insert ("r2", obstack_finish (&output_obstack)); |
muscle_insert ("r2", obstack_finish (&output_obstack)); |
291 |
XFREE (short_tab); |
XFREE (short_tab); |
534 |
save_row (i); |
save_row (i); |
535 |
} |
} |
536 |
|
|
537 |
output_table_data (&output_obstack, yydefact, |
output_table_data (&output_obstack, yydefact, |
538 |
yydefact[0], 1, nstates); |
yydefact[0], 1, nstates); |
539 |
muscle_insert ("defact", obstack_finish (&output_obstack)); |
muscle_insert ("defact", obstack_finish (&output_obstack)); |
540 |
|
|
541 |
XFREE (actrow); |
XFREE (actrow); |
542 |
XFREE (yydefact); |
XFREE (yydefact); |
543 |
} |
} |
675 |
yydefgoto[i - ntokens] = default_state; |
yydefgoto[i - ntokens] = default_state; |
676 |
} |
} |
677 |
|
|
678 |
output_table_data (&output_obstack, yydefgoto, |
output_table_data (&output_obstack, yydefgoto, |
679 |
yydefgoto[0], 1, nsyms - ntokens); |
yydefgoto[0], 1, nsyms - ntokens); |
680 |
muscle_insert ("defgoto", obstack_finish (&output_obstack)); |
muscle_insert ("defgoto", obstack_finish (&output_obstack)); |
681 |
|
|
880 |
output_base (void) |
output_base (void) |
881 |
{ |
{ |
882 |
/* Output pact. */ |
/* Output pact. */ |
883 |
output_table_data (&output_obstack, base, |
output_table_data (&output_obstack, base, |
884 |
base[0], 1, nstates); |
base[0], 1, nstates); |
885 |
muscle_insert ("pact", obstack_finish (&output_obstack)); |
muscle_insert ("pact", obstack_finish (&output_obstack)); |
886 |
|
|
887 |
/* Output pgoto. */ |
/* Output pgoto. */ |
888 |
output_table_data (&output_obstack, base, |
output_table_data (&output_obstack, base, |
889 |
base[nstates], nstates + 1, nvectors); |
base[nstates], nstates + 1, nvectors); |
890 |
muscle_insert ("pgoto", obstack_finish (&output_obstack)); |
muscle_insert ("pgoto", obstack_finish (&output_obstack)); |
891 |
|
|
896 |
static void |
static void |
897 |
output_table (void) |
output_table (void) |
898 |
{ |
{ |
899 |
output_table_data (&output_obstack, table, |
output_table_data (&output_obstack, table, |
900 |
table[0], 1, high + 1); |
table[0], 1, high + 1); |
901 |
muscle_insert ("table", obstack_finish (&output_obstack)); |
muscle_insert ("table", obstack_finish (&output_obstack)); |
902 |
XFREE (table); |
XFREE (table); |
906 |
static void |
static void |
907 |
output_check (void) |
output_check (void) |
908 |
{ |
{ |
909 |
output_table_data (&output_obstack, check, |
output_table_data (&output_obstack, check, |
910 |
check[0], 1, high + 1); |
check[0], 1, high + 1); |
911 |
muscle_insert ("check", obstack_finish (&output_obstack)); |
muscle_insert ("check", obstack_finish (&output_obstack)); |
912 |
XFREE (check); |
XFREE (check); |
1109 |
output_stos (); |
output_stos (); |
1110 |
output_rule_data (); |
output_rule_data (); |
1111 |
output_actions (); |
output_actions (); |
1112 |
|
|
1113 |
#if 0 |
#if 0 |
1114 |
if (!no_parser_flag) */ |
if (!no_parser_flag) */ |
1115 |
#endif |
#endif |