20 |
|
|
21 |
|
|
22 |
#include "system.h" |
#include "system.h" |
23 |
|
#include "quotearg.h" |
24 |
#include "files.h" |
#include "files.h" |
25 |
#include "gram.h" |
#include "gram.h" |
26 |
#include "LR0.h" |
#include "LR0.h" |
44 |
} |
} |
45 |
#endif |
#endif |
46 |
|
|
47 |
|
static inline const char * |
48 |
|
escape (const char *s) |
49 |
|
{ |
50 |
|
return quotearg_n_style (1, escape_quoting_style, s); |
51 |
|
} |
52 |
|
|
53 |
|
/* Be cautious not to use twice the same slot in a single expression. */ |
54 |
|
static inline const char * |
55 |
|
escape2 (const char *s) |
56 |
|
{ |
57 |
|
return quotearg_n_style (2, escape_quoting_style, s); |
58 |
|
} |
59 |
|
|
60 |
|
|
61 |
/*--------------------------------. |
/*--------------------------------. |
62 |
| Report information on a state. | |
| Report information on a state. | |
92 |
sp++; |
sp++; |
93 |
|
|
94 |
rule = -(*sp); |
rule = -(*sp); |
95 |
fprintf (out, " %s -> ", tags[rule_table[rule].lhs]); |
fprintf (out, " %s -> ", escape (tags[rule_table[rule].lhs])); |
96 |
|
|
97 |
for (sp = ritem + rule_table[rule].rhs; sp < sp1; sp++) |
for (sp = ritem + rule_table[rule].rhs; sp < sp1; sp++) |
98 |
fprintf (out, "%s ", tags[*sp]); |
fprintf (out, "%s ", escape (tags[*sp])); |
99 |
|
|
100 |
fputc ('.', out); |
fputc ('.', out); |
101 |
|
|
102 |
for (/* Nothing */; *sp > 0; ++sp) |
for (/* Nothing */; *sp > 0; ++sp) |
103 |
fprintf (out, " %s", tags[*sp]); |
fprintf (out, " %s", escape (tags[*sp])); |
104 |
|
|
105 |
fprintf (out, _(" (rule %d)"), rule); |
fprintf (out, _(" (rule %d)"), rule); |
106 |
fputc ('\n', out); |
fputc ('\n', out); |
124 |
int symbol = state_table[state1]->accessing_symbol; |
int symbol = state_table[state1]->accessing_symbol; |
125 |
fprintf (out, |
fprintf (out, |
126 |
_(" %-4s\tshift, and go to state %d\n"), |
_(" %-4s\tshift, and go to state %d\n"), |
127 |
tags[symbol], state1); |
escape (tags[symbol]), state1); |
128 |
} |
} |
129 |
|
|
130 |
if (i > 0) |
if (i > 0) |
141 |
for (i = 0; i < errp->nerrs; ++i) |
for (i = 0; i < errp->nerrs; ++i) |
142 |
if (errp->errs[i]) |
if (errp->errs[i]) |
143 |
fprintf (out, _(" %-4s\terror (nonassociative)\n"), |
fprintf (out, _(" %-4s\terror (nonassociative)\n"), |
144 |
tags[errp->errs[i]]); |
escape (tags[errp->errs[i]])); |
145 |
|
|
146 |
if (i > 0) |
if (i > 0) |
147 |
fputc ('\n', out); |
fputc ('\n', out); |
165 |
int state1 = shiftp->shifts[i]; |
int state1 = shiftp->shifts[i]; |
166 |
int symbol = state_table[state1]->accessing_symbol; |
int symbol = state_table[state1]->accessing_symbol; |
167 |
fprintf (out, _(" %-4s\tgo to state %d\n"), |
fprintf (out, _(" %-4s\tgo to state %d\n"), |
168 |
tags[symbol], state1); |
escape (tags[symbol]), state1); |
169 |
} |
} |
170 |
|
|
171 |
fputc ('\n', out); |
fputc ('\n', out); |
189 |
int rule = redp->rules[0]; |
int rule = redp->rules[0]; |
190 |
int symbol = rule_table[rule].lhs; |
int symbol = rule_table[rule].lhs; |
191 |
fprintf (out, _(" $default\treduce using rule %d (%s)\n\n"), |
fprintf (out, _(" $default\treduce using rule %d (%s)\n\n"), |
192 |
rule, tags[symbol]); |
rule, escape (tags[symbol])); |
193 |
return; |
return; |
194 |
} |
} |
195 |
|
|
221 |
for (i = 0; i < ntokens; i++) |
for (i = 0; i < ntokens; i++) |
222 |
if (BITISSET (lookaheadset, i)) |
if (BITISSET (lookaheadset, i)) |
223 |
fprintf (out, _(" %-4s\t[reduce using rule %d (%s)]\n"), |
fprintf (out, _(" %-4s\t[reduce using rule %d (%s)]\n"), |
224 |
tags[i], default_rule, |
escape (tags[i]), default_rule, |
225 |
tags[rule_table[default_rule].lhs]); |
escape2 (tags[rule_table[default_rule].lhs])); |
226 |
|
|
227 |
fprintf (out, _(" $default\treduce using rule %d (%s)\n\n"), |
fprintf (out, _(" $default\treduce using rule %d (%s)\n\n"), |
228 |
default_rule, tags[rule_table[default_rule].lhs]); |
default_rule, escape (tags[rule_table[default_rule].lhs])); |
229 |
} |
} |
230 |
else if (state->nlookaheads >= 1) |
else if (state->nlookaheads >= 1) |
231 |
{ |
{ |
279 |
if (state->lookaheadsp + j != default_LA) |
if (state->lookaheadsp + j != default_LA) |
280 |
fprintf (out, |
fprintf (out, |
281 |
_(" %-4s\treduce using rule %d (%s)\n"), |
_(" %-4s\treduce using rule %d (%s)\n"), |
282 |
tags[i], |
escape (tags[i]), |
283 |
LAruleno[state->lookaheadsp + j], |
LAruleno[state->lookaheadsp + j], |
284 |
tags[rule_table[LAruleno[state->lookaheadsp + j]].lhs]); |
escape2 (tags[rule_table[LAruleno[state->lookaheadsp + j]].lhs])); |
285 |
else |
else |
286 |
defaulted = 1; |
defaulted = 1; |
287 |
|
|
292 |
if (defaulted) |
if (defaulted) |
293 |
fprintf (out, |
fprintf (out, |
294 |
_(" %-4s\treduce using rule %d (%s)\n"), |
_(" %-4s\treduce using rule %d (%s)\n"), |
295 |
tags[i], |
escape (tags[i]), |
296 |
LAruleno[default_LA], |
LAruleno[default_LA], |
297 |
tags[rule_table[LAruleno[default_LA]].lhs]); |
escape2 (tags[rule_table[LAruleno[default_LA]].lhs])); |
298 |
defaulted = 0; |
defaulted = 0; |
299 |
fprintf (out, |
fprintf (out, |
300 |
_(" %-4s\t[reduce using rule %d (%s)]\n"), |
_(" %-4s\t[reduce using rule %d (%s)]\n"), |
301 |
tags[i], |
escape (tags[i]), |
302 |
LAruleno[state->lookaheadsp + j], |
LAruleno[state->lookaheadsp + j], |
303 |
tags[rule_table[LAruleno[state->lookaheadsp + j]].lhs]); |
escape2 (tags[rule_table[LAruleno[state->lookaheadsp + j]].lhs])); |
304 |
} |
} |
305 |
} |
} |
306 |
} |
} |
308 |
|
|
309 |
if (default_LA >= 0) |
if (default_LA >= 0) |
310 |
fprintf (out, _(" $default\treduce using rule %d (%s)\n"), |
fprintf (out, _(" $default\treduce using rule %d (%s)\n"), |
311 |
default_rule, tags[rule_table[default_rule].lhs]); |
default_rule, escape (tags[rule_table[default_rule].lhs])); |
312 |
} |
} |
313 |
} |
} |
314 |
|
|
375 |
if (rule_table[i].useful) |
if (rule_table[i].useful) |
376 |
{ |
{ |
377 |
fprintf (out, _(" %3d %3d %s ->"), |
fprintf (out, _(" %3d %3d %s ->"), |
378 |
i, rule_table[i].line, tags[rule_table[i].lhs]); |
i, rule_table[i].line, escape (tags[rule_table[i].lhs])); |
379 |
rule = &ritem[rule_table[i].rhs]; |
rule = &ritem[rule_table[i].rhs]; |
380 |
if (*rule > 0) |
if (*rule > 0) |
381 |
while (*rule > 0) |
while (*rule > 0) |
382 |
fprintf (out, " %s", tags[*rule++]); |
fprintf (out, " %s", escape (tags[*rule++])); |
383 |
else |
else |
384 |
fprintf (out, " /* %s */", _("empty")); |
fprintf (out, " /* %s */", _("empty")); |
385 |
fputc ('\n', out); |
fputc ('\n', out); |
389 |
|
|
390 |
/* TERMINAL (type #) : rule #s terminal is on RHS */ |
/* TERMINAL (type #) : rule #s terminal is on RHS */ |
391 |
fprintf (out, "%s\n\n", _("Terminals, with rules where they appear")); |
fprintf (out, "%s\n\n", _("Terminals, with rules where they appear")); |
392 |
fprintf (out, "%s (-1)\n", tags[0]); |
fprintf (out, "%s (-1)\n", escape (tags[0])); |
393 |
|
|
394 |
for (i = 0; i <= max_user_token_number; i++) |
for (i = 0; i <= max_user_token_number; i++) |
395 |
if (token_translations[i] != 2) |
if (token_translations[i] != 2) |
396 |
{ |
{ |
397 |
buffer[0] = 0; |
buffer[0] = 0; |
398 |
column = strlen (tags[token_translations[i]]); |
column = strlen (escape (tags[token_translations[i]])); |
399 |
fputs (tags[token_translations[i]], out); |
fputs (escape (tags[token_translations[i]]), out); |
400 |
END_TEST (50); |
END_TEST (50); |
401 |
sprintf (buffer, " (%d)", i); |
sprintf (buffer, " (%d)", i); |
402 |
|
|
431 |
} |
} |
432 |
|
|
433 |
buffer[0] = 0; |
buffer[0] = 0; |
434 |
fputs (tags[i], out); |
fputs (escape (tags[i]), out); |
435 |
column = strlen (tags[i]); |
column = strlen (escape (tags[i])); |
436 |
sprintf (buffer, " (%d)", i); |
sprintf (buffer, " (%d)", i); |
437 |
END_TEST (0); |
END_TEST (0); |
438 |
|
|