mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
New experimental feature: if --verbose --trace output all the
items of a state, not only its kernel. * src/print.c (print_core): If `trace_flag', then invoke closure before outputting the items of the state (print_core is no longer a correct name them). (print_results): Invoke new_closure/free_closure if needed.
This commit is contained in:
10
ChangeLog
10
ChangeLog
@@ -1,3 +1,13 @@
|
||||
2001-12-05 Akim Demaille <akim@epita.fr>
|
||||
|
||||
New experimental feature: if --verbose --trace output all the
|
||||
items of a state, not only its kernel.
|
||||
|
||||
* src/print.c (print_core): If `trace_flag', then invoke closure
|
||||
before outputting the items of the state (print_core is no longer
|
||||
a correct name them).
|
||||
(print_results): Invoke new_closure/free_closure if needed.
|
||||
|
||||
2001-12-05 Akim Demaille <akim@epita.fr>
|
||||
|
||||
* src/LR0.c (new_itemsets): Use nshifts only, not shiftcount.
|
||||
|
||||
74
src/print.c
74
src/print.c
@@ -30,6 +30,7 @@
|
||||
#include "reader.h"
|
||||
#include "print.h"
|
||||
#include "reduce.h"
|
||||
#include "closure.h"
|
||||
|
||||
#if 0
|
||||
static void
|
||||
@@ -48,38 +49,48 @@ static void
|
||||
print_core (FILE *out, int state)
|
||||
{
|
||||
int i;
|
||||
core *statep = state_table[state].state;
|
||||
short *sitems = state_table[state].state->items;
|
||||
int snitems = state_table[state].state->nitems;
|
||||
|
||||
if (!statep->nitems)
|
||||
return;
|
||||
|
||||
for (i = 0; i < statep->nitems; i++)
|
||||
/* New experimental feature: if TRACE_FLAGS output all the items of
|
||||
a state, not only its kernel. */
|
||||
if (trace_flag)
|
||||
{
|
||||
short *sp;
|
||||
short *sp1;
|
||||
int rule;
|
||||
|
||||
sp1 = sp = ritem + statep->items[i];
|
||||
|
||||
while (*sp > 0)
|
||||
sp++;
|
||||
|
||||
rule = -(*sp);
|
||||
fprintf (out, " %s -> ", tags[rule_table[rule].lhs]);
|
||||
|
||||
for (sp = ritem + rule_table[rule].rhs; sp < sp1; sp++)
|
||||
fprintf (out, "%s ", tags[*sp]);
|
||||
|
||||
fputc ('.', out);
|
||||
|
||||
for (/* Nothing */; *sp > 0; ++sp)
|
||||
fprintf (out, " %s", tags[*sp]);
|
||||
|
||||
fprintf (out, _(" (rule %d)"), rule);
|
||||
fputc ('\n', out);
|
||||
closure (sitems, snitems);
|
||||
sitems = itemset;
|
||||
snitems = nitemset;
|
||||
}
|
||||
|
||||
fputc ('\n', out);
|
||||
if (snitems)
|
||||
{
|
||||
for (i = 0; i < snitems; i++)
|
||||
{
|
||||
short *sp;
|
||||
short *sp1;
|
||||
int rule;
|
||||
|
||||
sp1 = sp = ritem + sitems[i];
|
||||
|
||||
while (*sp > 0)
|
||||
sp++;
|
||||
|
||||
rule = -(*sp);
|
||||
fprintf (out, " %s -> ", tags[rule_table[rule].lhs]);
|
||||
|
||||
for (sp = ritem + rule_table[rule].rhs; sp < sp1; sp++)
|
||||
fprintf (out, "%s ", tags[*sp]);
|
||||
|
||||
fputc ('.', out);
|
||||
|
||||
for (/* Nothing */; *sp > 0; ++sp)
|
||||
fprintf (out, " %s", tags[*sp]);
|
||||
|
||||
fprintf (out, _(" (rule %d)"), rule);
|
||||
fputc ('\n', out);
|
||||
}
|
||||
|
||||
fputc ('\n', out);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -321,8 +332,15 @@ print_results (void)
|
||||
|
||||
print_grammar (out);
|
||||
|
||||
/* New experimental feature: output all the items of a state,
|
||||
not only its kernel. Requires to run closure, which need
|
||||
memory allocation/deallocation. */
|
||||
if (trace_flag)
|
||||
new_closure (nitems);
|
||||
for (i = 0; i < nstates; i++)
|
||||
print_state (out, i);
|
||||
if (trace_flag)
|
||||
free_closure ();
|
||||
|
||||
xfclose (out);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user