* src/print.h: New file.
authorAkim Demaille <akim@epita.fr>
Mon, 2 Oct 2000 08:10:26 +0000 (08:10 +0000)
committerAkim Demaille <akim@epita.fr>
Mon, 2 Oct 2000 08:10:26 +0000 (08:10 +0000)
Propagate its use.
* src/print.c: Formatting and ordering changes.
(verbose, terse): Replace with...
(print_results): this new function.
Adjust dependencies.

ChangeLog
src/Makefile.am
src/getargs.h
src/main.c
src/print.c
src/print.h [new file with mode: 0644]

index 8430f5c..5876dad 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2000-10-02  Akim Demaille  <akim@epita.fr>
 
+       * src/print.h: New file.
+       Propagate its use.
+       * src/print.c: Formatting and ordering changes.
+       (verbose, terse): Replace with...
+       (print_results): this new function.
+       Adjust dependencies.
+
+       
+2000-10-02  Akim Demaille  <akim@epita.fr>
+
        * src/conflicts.c (conflict_report): New function.
        (conflict_log, verbose_conflict_log): Replace with...
        (print_conflicts): this function.
index cebc1fd..4919ddb 100644 (file)
@@ -22,7 +22,7 @@ noinst_HEADERS = alloc.h closure.h complain.h conflicts.h \
  derives.h \
  files.h getargs.h gram.h lalr.h lex.h nullable.h \
  output.h state.h      \
- reader.h reduce.h symtab.h system.h types.h
print.h reader.h reduce.h symtab.h system.h types.h
 
 data_DATA = bison.simple bison.hairy
 
index a0180d7..3b9e299 100644 (file)
@@ -29,6 +29,6 @@ extern int nolinesflag;       /* for -l */
 extern int noparserflag;       /* for -n */
 extern int rawtoknumflag;      /* for -r */
 extern int toknumflag;         /* for -k */
-extern int verboseflag;        /* for -v */
+extern int verboseflag;                /* for -v */
 
 void getargs PARAMS ((int argc, char *argv[]));
index 4dff4de..248bcd8 100644 (file)
@@ -30,6 +30,7 @@
 #include "lalr.h"
 #include "reduce.h"
 #include "nullable.h"
+#include "print.h"
 
 #if 0                          /* XXX currently unused.  */
 /* Nonzero means failure has been detected; don't write a parser file.  */
@@ -46,8 +47,6 @@ extern char *printable_version PARAMS ((int));
 extern void generate_states PARAMS ((void));
 extern void initialize_conflicts PARAMS ((void));
 extern void finalize_conflicts PARAMS ((void));
-extern void verbose PARAMS ((void));
-extern void terse PARAMS ((void));
 
 
 /* VMS complained about using `int'.  */
@@ -96,12 +95,8 @@ main (int argc, char *argv[])
      declarations.  */
   initialize_conflicts ();
 
-  /* Print information about results, if requested.  In file print.
-     */
-  if (verboseflag)
-    verbose ();
-  else
-    terse ();
+  /* Print information about results, if requested.  */
+  print_results ();
 
   /* Output the tables and the parser to ftable.  In file output.  */
   output ();
index 061a0fe..bf3fce8 100644 (file)
 #include "state.h"
 #include "lalr.h"
 #include "conflicts.h"
+#include "getargs.h"
+#include "state.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 +40,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 +91,6 @@ print_core (int state)
   putc ('\n', foutput);
 }
 
-
 static void
 print_actions (int state)
 {
@@ -232,6 +192,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 +213,7 @@ print_actions (int state)
     }                                          \
   } while (0)
 
+
 static void
 print_grammar (void)
 {
@@ -370,3 +343,19 @@ print_grammar (void)
       fprintf (foutput, "%s\n", buffer);
     }
 }
+\f
+void
+print_results (void)
+{
+  int i;
+
+  if (any_conflicts)
+    print_conflicts ();
+
+  if (verboseflag)
+    print_grammar ();
+
+  if (verboseflag)
+    for (i = 0; i < nstates; i++)
+      print_state (i);
+}
diff --git a/src/print.h b/src/print.h
new file mode 100644 (file)
index 0000000..5fa82b1
--- /dev/null
@@ -0,0 +1,26 @@
+/* Print information on generated parser, for bison,
+   Copyright (C) 2000 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   Bison is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#ifndef PRINT_H_
+# define PRINT_H_
+
+void print_results PARAMS ((void));
+
+#endif /* !PRINT_H_ */