]> git.saurik.com Git - bison.git/blobdiff - src/print.c
The location tracking mechanism is precious for parse error
[bison.git] / src / print.c
index 061a0fee9aa2d96ec37d448d018b88c68436e1b0..f187b05b27d82aae2ce1f11e4a3b71120978fc92 100644 (file)
 
 
 #include "system.h"
-#include "alloc.h"
+#include "xalloc.h"
 #include "files.h"
 #include "gram.h"
-#include "state.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 int final_state;
-
-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)
-    print_conflicts ();
-}
-
-
-void
-verbose (void)
-{
-  int i;
-
-  if (any_conflicts)
-    print_conflicts ();
-
-  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)
 {
@@ -74,15 +39,10 @@ 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)
@@ -130,7 +90,6 @@ print_core (int state)
   putc ('\n', foutput);
 }
 
-
 static void
 print_actions (int state)
 {
@@ -232,6 +191,18 @@ print_actions (int state)
     }
 }
 
+static void
+print_state (int state)
+{
+  fprintf (foutput, _("\n\nstate %d\n\n"), state);
+  print_core (state);
+  print_actions (state);
+}
+\f
+/*-----------------------------------------.
+| Print information on the whole grammar.  |
+`-----------------------------------------*/
+
 #define END_TEST(end)                          \
   do {                                         \
     if (column + strlen(buffer) > (end)) {     \
@@ -241,6 +212,7 @@ print_actions (int state)
     }                                          \
   } while (0)
 
+
 static void
 print_grammar (void)
 {
@@ -370,3 +342,19 @@ print_grammar (void)
       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);
+}