[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
28-fyi-more-traces.patch
From: |
Akim Demaille |
Subject: |
28-fyi-more-traces.patch |
Date: |
Mon, 19 Nov 2001 10:03:58 +0100 |
Index: ChangeLog
from Akim Demaille <address@hidden>
* src/LR0.c (new_state, get_state): Complete TRACE code.
* src/closure.c: Include `reader.h' to get `tags', needed by the
trace code.
Rename the conditional DEBUG as TRACE.
Output consistently TRACEs to stderr, not stdout.
* src/derives.c: Likewise.
* src/reduce.c: (inaccessable_symbols): Using if is better style
than goto.
Use `#if TRACE' instead of `#if 0' for tracing code.
Index: src/LR0.c
--- src/LR0.c Sat, 17 Nov 2001 17:06:51 +0100 akim
+++ src/LR0.c Sat, 17 Nov 2001 17:31:20 +0100 akim
@@ -198,7 +198,8 @@
core *p;
#if TRACE
- fprintf (stderr, "Entering new_state, symbol = %d\n", symbol);
+ fprintf (stderr, "Entering new_state, state = %d, symbol = %d\n",
+ nstates, symbol);
#endif
if (nstates >= MAXSHORT)
@@ -241,7 +242,8 @@
int n;
#if TRACE
- fprintf (stderr, "Entering get_state, symbol = %d\n", symbol);
+ fprintf (stderr, "Entering get_state, state = %d, symbol = %d\n",
+ nstates, symbol);
#endif
isp1 = kernel_base[symbol];
Index: src/closure.c
--- src/closure.c Fri, 16 Nov 2001 01:00:46 +0100 akim
+++ src/closure.c Sat, 17 Nov 2001 17:15:33 +0100 akim
@@ -1,5 +1,5 @@
/* Subroutines for bison
- 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.
@@ -20,6 +20,7 @@
#include "system.h"
#include "gram.h"
+#include "reader.h"
#include "closure.h"
#include "derives.h"
#include "warshall.h"
@@ -38,7 +39,7 @@
/* number of words required to hold a bit for each variable */
static int varsetsize;
-#if DEBUG
+#if TRACE
/*-----------------.
| Debugging code. |
@@ -49,9 +50,9 @@
{
short *isp;
- printf ("\n\nn = %d\n\n", n);
+ fprintf (stderr, "\n\nn = %d\n\n", n);
for (isp = itemset; isp < itemsetend; isp++)
- printf (" %d\n", *isp);
+ fprintf (stderr, " %d\n", *isp);
}
@@ -62,17 +63,17 @@
int j;
unsigned *rowp;
- printf ("\n\n\nFIRSTS\n\n");
+ fprintf (stderr, "\n\n\nFIRSTS\n\n");
for (i = ntokens; i < nsyms; i++)
{
- printf ("\n\n%s firsts\n\n", tags[i]);
+ fprintf (stderr, "\n\n%s firsts\n\n", tags[i]);
rowp = firsts + ((i - ntokens) * varsetsize);
for (j = 0; j < nvars; j++)
if (BITISSET (rowp, j))
- printf (" %s\n", tags[j + ntokens]);
+ fprintf (stderr, " %s\n", tags[j + ntokens]);
}
}
@@ -84,19 +85,17 @@
int j;
unsigned *rp;
- printf ("\n\n\nFDERIVES\n");
+ fprintf (stderr, "\n\n\nFDERIVES\n");
for (i = ntokens; i < nsyms; i++)
{
- printf ("\n\n%s derives\n\n", tags[i]);
+ fprintf (stderr, "\n\n%s derives\n\n", tags[i]);
rp = fderives + i * rulesetsize;
for (j = 0; j <= nrules; j++)
if (BITISSET (rp, j))
- printf (" %d\n", j);
+ fprintf (stderr, " %d\n", j);
}
-
- fflush (stdout);
}
#endif
@@ -143,7 +142,7 @@
RTC (firsts, nvars);
-#ifdef DEBUG
+#ifdef TRACE
print_firsts ();
#endif
}
@@ -204,7 +203,7 @@
rrow += rulesetsize;
}
-#ifdef DEBUG
+#ifdef TRACE
print_fderives ();
#endif
@@ -301,7 +300,7 @@
while (csp < csend)
*itemsetend++ = *csp++;
-#if DEBUG
+#if TRACE
print_closure (n);
#endif
}
Index: src/derives.c
--- src/derives.c Fri, 16 Nov 2001 01:00:46 +0100 akim
+++ src/derives.c Sat, 17 Nov 2001 17:13:56 +0100 akim
@@ -1,5 +1,5 @@
/* Match rules with nonterminals for bison,
- 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.
@@ -26,12 +26,13 @@
#include "system.h"
#include "types.h"
+#include "reader.h"
#include "gram.h"
#include "derives.h"
short **derives;
-#if DEBUG
+#if TRACE
static void
print_derives (void)
@@ -39,21 +40,17 @@
int i;
short *sp;
- fputs ("\n\n\n", stdout);
- printf (_("DERIVES"));
- fputs ("\n\n", stdout);
+ fputs ("\n\n\nDERIVES\n\n", stderr);
for (i = ntokens; i < nsyms; i++)
{
- printf (_("%s derives"), tags[i]);
+ fprintf (stderr, "%s derives", tags[i]);
for (sp = derives[i]; *sp > 0; sp++)
- {
- printf (" %d", *sp);
- }
- putchar ('\n');
+ fprintf (stderr, " %d", *sp);
+ putc ('\n', stderr);
}
- putchar ('\n');
+ putc ('\n', stderr);
}
#endif
@@ -99,7 +96,7 @@
*q++ = -1;
}
-#if DEBUG
+#if TRACE
print_derives ();
#endif
Index: src/reduce.c
--- src/reduce.c Fri, 16 Nov 2001 01:10:56 +0100 akim
+++ src/reduce.c Sat, 17 Nov 2001 17:21:55 +0100 akim
@@ -200,38 +200,33 @@
Pp = XCALLOC (unsigned, WORDSIZE (nrules + 1));
/* If the start symbol isn't useful, then nothing will be useful. */
- if (!BITISSET (N, start_symbol - ntokens))
- goto end_iteration;
-
- SETBIT (V, start_symbol);
-
- while (1)
+ if (BITISSET (N, start_symbol - ntokens))
{
- for (i = WORDSIZE (nsyms) - 1; i >= 0; i--)
- Vp[i] = V[i];
- for (i = 1; i <= nrules; i++)
+ SETBIT (V, start_symbol);
+
+ while (1)
{
- if (!BITISSET (Pp, i) && BITISSET (P, i) && BITISSET (V,
rule_table[i].lhs))
+ for (i = WORDSIZE (nsyms) - 1; i >= 0; i--)
+ Vp[i] = V[i];
+ for (i = 1; i <= nrules; i++)
{
- for (r = &ritem[rule_table[i].rhs]; *r >= 0; r++)
+ if (!BITISSET (Pp, i)
+ && BITISSET (P, i)
+ && BITISSET (V, rule_table[i].lhs))
{
- if (ISTOKEN (t = *r) || BITISSET (N, t - ntokens))
- {
+ for (r = &ritem[rule_table[i].rhs]; *r >= 0; r++)
+ if (ISTOKEN (t = *r) || BITISSET (N, t - ntokens))
SETBIT (Vp, t);
- }
+ SETBIT (Pp, i);
}
- SETBIT (Pp, i);
}
+ if (bits_equal (V, Vp, WORDSIZE (nsyms)))
+ break;
+ Vs = Vp;
+ Vp = V;
+ V = Vs;
}
- if (bits_equal (V, Vp, WORDSIZE (nsyms)))
- {
- break;
- }
- Vs = Vp;
- Vp = V;
- V = Vs;
}
-end_iteration:
XFREE (V);
V = Vp;
@@ -430,28 +425,27 @@
fprintf (out, _("Useless rules:"));
fprintf (out, "\n\n");
for (i = 1; i <= nrules; i++)
- {
- if (!BITISSET (P, i))
- {
- fprintf (out, "#%-4d ", i);
- fprintf (out, "%s :\t", tags[rule_table[i].lhs]);
- for (r = &ritem[rule_table[i].rhs]; *r >= 0; r++)
- fprintf (out, " %s", tags[*r]);
- fprintf (out, ";\n");
- }
- }
+ if (!BITISSET (P, i))
+ {
+ fprintf (out, "#%-4d ", i);
+ fprintf (out, "%s :\t", tags[rule_table[i].lhs]);
+ for (r = &ritem[rule_table[i].rhs]; *r >= 0; r++)
+ fprintf (out, " %s", tags[*r]);
+ fprintf (out, ";\n");
+ }
}
if (nuseless_nonterminals > 0 || nuseless_productions > 0 || b)
fprintf (out, "\n\n");
}
-#if 0 /* XXX currently unused. */
+#if TRACE
static void
dump_grammar (FILE *out)
{
int i;
rule r;
+ fprintf (out, "REDUCED GRAMMAR\n\n");
fprintf (out,
"ntokens = %d, nvars = %d, nsyms = %d, nrules = %d, nitems = %d\n\n",
ntokens, nvars, nsyms, nrules, nitems);
@@ -545,12 +539,8 @@
tags[start_symbol]);
reduce_grammar_tables ();
-#if 0
- if (verbose_flag)
- {
- fprintf (out, "REDUCED GRAMMAR\n\n");
- dump_grammar ();
- }
+#if TRACE
+ dump_grammar (stderr);
#endif
if (statistics_flag)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- 28-fyi-more-traces.patch,
Akim Demaille <=