+2001-12-29 Akim Demaille <akim@epita.fr>
+
+ * src/lalr.c (lookaheads_print): New.
+ (lalr): Call it when --trace-flag.
+ * tests/sets.at (Nullable): Adjust: when tracing, the lookaheads
+ are dumped.
+
+
2001-12-29 Akim Demaille <akim@epita.fr>
* src/derives.c (print_derives): Be sure to use `>= 0', not `> 0',
tokens they accept. */
#include "system.h"
+#include "reader.h"
#include "types.h"
#include "LR0.h"
#include "gram.h"
}
}
+
+/*---------------------------------------.
+| Output the lookaheads for each state. |
+`---------------------------------------*/
+
+static void
+lookaheads_print (FILE *out)
+{
+ int i, j, k;
+ fprintf (out, "Lookaheads: BEGIN\n");
+ for (i = 0; i < nstates; ++i)
+ {
+ fprintf (out, "State %d: %d lookaheads\n",
+ i, state_table[i]->nlookaheads);
+
+ for (j = 0; j < state_table[i]->nlookaheads; ++j)
+ for (k = 0; k < ntokens; ++k)
+ if (BITISSET (LA (state_table[i]->lookaheadsp + j), j))
+ fprintf (out, " on %d (%s) -> rule %d\n",
+ k, tags[k],
+ -LAruleno[state_table[i]->lookaheadsp + j] - 1);
+ }
+ fprintf (out, "Lookaheads: END\n");
+}
+
void
lalr (void)
{
build_relations ();
compute_FOLLOWS ();
compute_lookaheads ();
+
+ if (trace_flag)
+ lookaheads_print (stderr);
}