bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

30-fyi-option-trace.patch


From: Akim Demaille
Subject: 30-fyi-option-trace.patch
Date: Mon, 19 Nov 2001 10:04:08 +0100

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * src/getargs.c (statistics_flag): Replace with...
        (trace_flag): New.
        (longopts): Accept --trace instead of --statistics.
        * src/getargs.h: Adjust.
        * src/LR0.c, src/closure.c, src/derives.c, src/nullable.c,
        * src/reduce.c: Use trace_flags instead of the CPP conditional TRACE.

Index: src/LR0.c
--- src/LR0.c Sun, 18 Nov 2001 10:22:00 +0100 akim
+++ src/LR0.c Sun, 18 Nov 2001 10:22:27 +0100 akim
@@ -23,6 +23,7 @@
    The entry point is generate_states.  */

 #include "system.h"
+#include "getargs.h"
 #include "gram.h"
 #include "state.h"
 #include "complain.h"
@@ -147,10 +148,8 @@
   int i;
   int shiftcount;

-#if TRACE
-  fprintf (stderr, "Entering new_itemsets, state = %d\n",
-          this_state->number);
-#endif
+  if (trace_flag)
+    fprintf (stderr, "Entering new_itemsets, state = %d\n", nstates);

   for (i = 0; i < nsyms; i++)
     kernel_end[i] = NULL;
@@ -192,10 +191,9 @@
   int n;
   core *p;

-#if TRACE
-  fprintf (stderr, "Entering new_state, state = %d, symbol = %d\n",
-          nstates, symbol);
-#endif
+  if (trace_flag)
+    fprintf (stderr, "Entering new_state, state = %d, symbol = %d\n",
+            nstates, symbol);

   if (nstates >= MAXSHORT)
     fatal (_("too many states (max %d)"), MAXSHORT);
@@ -233,10 +231,9 @@

   int n = kernel_end[symbol] - kernel_base[symbol];

-#if TRACE
-  fprintf (stderr, "Entering get_state, state = %d, symbol = %d\n",
-          nstates, symbol);
-#endif
+  if (trace_flag)
+    fprintf (stderr, "Entering get_state, state = %d, symbol = %d\n",
+            nstates, symbol);

   /* Add up the target state's active item numbers to get a hash key.
      */
@@ -296,9 +293,9 @@
   int j;
   int symbol;

-#if TRACE
-  fprintf (stderr, "Entering append_states\n");
-#endif
+  if (trace_flag)
+    fprintf (stderr, "Entering append_states\n");
+

   /* first sort shift_symbol into increasing order */

Index: src/closure.c
--- src/closure.c Sun, 18 Nov 2001 00:21:17 +0100 akim
+++ src/closure.c Sun, 18 Nov 2001 10:22:27 +0100 akim
@@ -19,6 +19,7 @@
    02111-1307, USA.  */

 #include "system.h"
+#include "getargs.h"
 #include "gram.h"
 #include "reader.h"
 #include "closure.h"
@@ -39,7 +40,6 @@
 /* number of words required to hold a bit for each variable */
 static int varsetsize;
 
-#if TRACE

 /*-----------------.
 | Debugging code.  |
@@ -97,7 +97,6 @@
          fprintf (stderr, "   %d\n", j);
     }
 }
-#endif
 
 /*-------------------------------------------------------------------.
 | Set FIRSTS to be an NVARS by NVARS bit matrix indicating which     |
@@ -142,9 +141,8 @@

   RTC (firsts, nvars);

-#ifdef TRACE
-  print_firsts ();
-#endif
+  if (trace_flag)
+    print_firsts ();
 }

 /*-------------------------------------------------------------------.
@@ -203,9 +201,8 @@
       rrow += rulesetsize;
     }

-#ifdef TRACE
-  print_fderives ();
-#endif
+  if (trace_flag)
+    print_fderives ();

   XFREE (firsts);
 }
@@ -300,9 +297,8 @@
   while (csp < csend)
     *itemsetend++ = *csp++;

-#if TRACE
-  print_closure (n);
-#endif
+  if (trace_flag)
+    print_closure (n);
 }


Index: src/derives.c
--- src/derives.c Sun, 18 Nov 2001 00:21:17 +0100 akim
+++ src/derives.c Sun, 18 Nov 2001 10:22:27 +0100 akim
@@ -25,6 +25,7 @@
    */

 #include "system.h"
+#include "getargs.h"
 #include "types.h"
 #include "reader.h"
 #include "gram.h"
@@ -32,7 +33,6 @@

 short **derives;

-#if TRACE

 static void
 print_derives (void)
@@ -53,7 +53,6 @@
   putc ('\n', stderr);
 }

-#endif

 void
 set_derives (void)
@@ -96,9 +95,8 @@
       *q++ = -1;
     }

-#if TRACE
-  print_derives ();
-#endif
+  if (trace_flag)
+    print_derives ();

   XFREE (dset + ntokens);
   XFREE (delts);
Index: src/getargs.c
--- src/getargs.c Sun, 04 Nov 2001 17:13:49 +0100 akim
+++ src/getargs.c Sun, 18 Nov 2001 10:22:27 +0100 akim
@@ -32,9 +32,9 @@
 int no_parser_flag = 0;
 int token_table_flag = 0;
 int verbose_flag = 0;
-int statistics_flag = 0;
 int yacc_flag = 0;     /* for -y */
 int graph_flag = 0;
+int trace_flag = 0;

 const char *skeleton = NULL;

@@ -68,7 +68,7 @@
   {"graph",            optional_argument,      0, 'g'},

   /* Hidden. */
-  {"statistics",       no_argument,    &statistics_flag, 1},
+  {"trace",            no_argument,    &trace_flag, 1},
   {0, 0, 0, 0}
 };

Index: src/getargs.h
--- src/getargs.h Wed, 15 Aug 2001 18:38:02 +0200 akim
+++ src/getargs.h Sun, 18 Nov 2001 10:22:27 +0100 akim
@@ -31,11 +31,11 @@
 extern int locations_flag;
 extern int no_lines_flag;      /* for -l */
 extern int no_parser_flag;     /* for -n */
-extern int statistics_flag;
 extern int token_table_flag;           /* for -k */
 extern int verbose_flag;       /* for -v */
 extern int graph_flag;         /* for -g */
 extern int yacc_flag;                  /* for -y */
+extern int trace_flag;

 void getargs PARAMS ((int argc, char *argv[]));

Index: src/nullable.c
--- src/nullable.c Sat, 17 Nov 2001 16:51:03 +0100 akim
+++ src/nullable.c Sun, 18 Nov 2001 10:22:27 +0100 akim
@@ -1,5 +1,5 @@
 /* Part of the bison parser generator,
-   Copyright 1984, 1989, 2000 Free Software Foundation, Inc.
+   Copyright 1984, 1989, 2000, 2001 Free Software Foundation, Inc.

    This file is part of Bison, the GNU Compiler Compiler.

@@ -24,6 +24,7 @@
    do so.  */

 #include "system.h"
+#include "getargs.h"
 #include "types.h"
 #include "gram.h"
 #include "nullable.h"
@@ -47,9 +48,8 @@
   char any_tokens;
   short *r1;

-#ifdef TRACE
-  fprintf (stderr, _("Entering set_nullable"));
-#endif
+  if (trace_flag)
+    fprintf (stderr, "Entering set_nullable");

   nullable = XCALLOC (char, nvars) - ntokens;

Index: src/reduce.c
--- src/reduce.c Sun, 18 Nov 2001 00:21:17 +0100 akim
+++ src/reduce.c Sun, 18 Nov 2001 10:22:27 +0100 akim
@@ -438,7 +438,6 @@
     fprintf (out, "\n\n");
 }
 
-#if TRACE
 static void
 dump_grammar (FILE *out)
 {
@@ -478,7 +477,6 @@
     }
   fprintf (out, "\n\n");
 }
-#endif



@@ -539,20 +537,15 @@
           tags[start_symbol]);

   reduce_grammar_tables ();
-#if TRACE
-  dump_grammar (stderr);
-#endif
-
-  if (statistics_flag)
-    fprintf (stderr, _("reduced %s defines %d terminal%s, %d nonterminal%s\
-, and %d production%s.\n"),
-            infile,
-            ntokens,
-            (ntokens == 1 ? "" : "s"),
-            nvars,
-            (nvars == 1 ? "" : "s"),
-            nrules,
-            (nrules == 1 ? "" : "s"));
+
+  if (trace_flag)
+    {
+      dump_grammar (stderr);
+
+      fprintf (stderr, "reduced %s defines %d terminals, %d nonterminals\
+, and %d productions.\n",
+              infile, ntokens, nvars, nrules);
+    }
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]