#include "system.h"
-#include "alloc.h"
+#include "xalloc.h"
#include "files.h"
#include "gram.h"
+#include "LR0.h"
+#include "lalr.h"
+#include "conflicts.h"
+#include "getargs.h"
#include "state.h"
+#include "reader.h"
+#include "print.h"
-
-extern char **tags;
-extern int nstates;
-extern short *accessing_symbol;
-extern core **state_table;
-extern shifts **shift_table;
-extern errs **err_table;
-extern reductions **reduction_table;
-extern char *consistent;
-extern char any_conflicts;
-extern char *conflicts;
-extern int final_state;
-
-extern void conflict_log PARAMS ((void));
-extern void verbose_conflict_log PARAMS ((void));
-extern void print_reductions PARAMS ((int));
-
-extern void terse PARAMS ((void));
-extern void verbose PARAMS ((void));
-
-#if 0 /* XXX currently unused. */
-static void print_token PARAMS ((int, int));
-#endif
-
-static void print_state PARAMS ((int));
-static void print_core PARAMS ((int));
-static void print_actions PARAMS ((int));
-static void print_grammar PARAMS ((void));
-
-void
-terse (void)
-{
- if (any_conflicts)
- conflict_log ();
-}
-
-
-void
-verbose (void)
-{
- int i;
-
- if (any_conflicts)
- verbose_conflict_log ();
-
- print_grammar ();
-
- for (i = 0; i < nstates; i++)
- print_state (i);
-}
-
-
-#if 0 /* XXX currently unused. */
+#if 0
static void
print_token (int extnum, int token)
{
}
#endif
-
-static void
-print_state (int state)
-{
- fprintf (foutput, _("\n\nstate %d\n\n"), state);
- print_core (state);
- print_actions (state);
-}
-
+\f
+/*================================\
+| Report information on a state. |
+\================================*/
static void
print_core (int state)
putc ('\n', foutput);
}
-
static void
print_actions (int state)
{
}
}
+static void
+print_state (int state)
+{
+ fputs ("\n\n", foutput);
+ fprintf (foutput, _("state %d"), state);
+ fputs ("\n\n", foutput);
+ print_core (state);
+ print_actions (state);
+}
+\f
+/*-----------------------------------------.
+| Print information on the whole grammar. |
+`-----------------------------------------*/
+
#define END_TEST(end) \
do { \
if (column + strlen(buffer) > (end)) { \
} \
} while (0)
+
static void
print_grammar (void)
{
int column = 0;
/* rule # : LHS -> RHS */
- fputs (_("\nGrammar\n"), foutput);
+ putc ('\n', foutput);
+ fputs (_("Grammar"), foutput);
+ putc ('\n', foutput);
for (i = 1; i <= nrules; i++)
/* Don't print rules disabled in reduce_grammar_tables. */
if (rlhs[i] >= 0)
}
/* TERMINAL (type #) : rule #s terminal is on RHS */
- fputs (_("\nTerminals, with rules where they appear\n\n"), foutput);
+ fputs ("\n", foutput);
+ fputs (_("Terminals, with rules where they appear"), foutput);
+ fputs ("\n\n", foutput);
fprintf (foutput, "%s (-1)\n", tags[0]);
if (translations)
{
fprintf (foutput, "%s\n", buffer);
}
- fputs (_("\nNonterminals, with rules where they appear\n\n"), foutput);
+ fputs ("\n", foutput);
+ fputs (_("Nonterminals, with rules where they appear"), foutput);
+ fputs ("\n\n", foutput);
for (i = ntokens; i <= nsyms - 1; i++)
{
int left_count = 0, right_count = 0;
fprintf (foutput, "%s\n", buffer);
}
}
+\f
+void
+print_results (void)
+{
+ int i;
+
+ if (any_conflicts)
+ print_conflicts ();
+
+ if (verbose_flag)
+ print_grammar ();
+
+ if (verbose_flag)
+ for (i = 0; i < nstates; i++)
+ print_state (i);
+}