New experimental feature: display the lookaheads in the report and

graph.
* src/print (print_core): When --trace-flag, display the rules
lookaheads.
* src/print_graph.c (print_core): Likewise.
Swap the arguments.
Adjust caller.
This commit is contained in:
Akim Demaille
2002-05-05 11:56:49 +00:00
parent 39ceb25bdb
commit d4e7d3a191
4 changed files with 175 additions and 8 deletions

View File

@@ -105,6 +105,32 @@ print_core (FILE *out, state_t *state)
for (/* Nothing */; *sp >= 0; ++sp)
fprintf (out, " %s", escape (symbols[*sp]->tag));
/* Experimental feature: display the lookaheads. */
if (trace_flag && state->nlookaheads)
{
int j, k;
int nlookaheads = 0;
/* Look for lookaheads corresponding to this rule. */
for (j = 0; j < state->nlookaheads; ++j)
for (k = 0; k < ntokens; ++k)
if (bitset_test (LA[state->lookaheadsp + j], k)
&& LArule[state->lookaheadsp + j]->number == rule)
nlookaheads++;
if (nlookaheads)
{
fprintf (out, " [");
for (j = 0; j < state->nlookaheads; ++j)
for (k = 0; k < ntokens; ++k)
if (bitset_test (LA[state->lookaheadsp + j], k)
&& LArule[state->lookaheadsp + j]->number == rule)
fprintf (out, "%s%s",
quotearg_style (escape_quoting_style,
symbols[k]->tag),
--nlookaheads ? ", " : "");
fprintf (out, "]");
}
}
fprintf (out, _(" (rule %d)"), rule - 1);
fputc ('\n', out);
}