mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 17:23:02 +00:00
* 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.
This commit is contained in:
@@ -1,3 +1,12 @@
|
|||||||
|
2001-11-19 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2001-11-19 Akim Demaille <akim@epita.fr>
|
2001-11-19 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* src/LR0.c (new_itemsets, get_state): Use more arrays and less
|
* src/LR0.c (new_itemsets, get_state): Use more arrays and less
|
||||||
|
|||||||
27
src/LR0.c
27
src/LR0.c
@@ -23,6 +23,7 @@
|
|||||||
The entry point is generate_states. */
|
The entry point is generate_states. */
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
#include "getargs.h"
|
||||||
#include "gram.h"
|
#include "gram.h"
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
#include "complain.h"
|
#include "complain.h"
|
||||||
@@ -147,10 +148,8 @@ new_itemsets (void)
|
|||||||
int i;
|
int i;
|
||||||
int shiftcount;
|
int shiftcount;
|
||||||
|
|
||||||
#if TRACE
|
if (trace_flag)
|
||||||
fprintf (stderr, "Entering new_itemsets, state = %d\n",
|
fprintf (stderr, "Entering new_itemsets, state = %d\n", nstates);
|
||||||
this_state->number);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0; i < nsyms; i++)
|
for (i = 0; i < nsyms; i++)
|
||||||
kernel_end[i] = NULL;
|
kernel_end[i] = NULL;
|
||||||
@@ -192,10 +191,9 @@ new_state (int symbol)
|
|||||||
int n;
|
int n;
|
||||||
core *p;
|
core *p;
|
||||||
|
|
||||||
#if TRACE
|
if (trace_flag)
|
||||||
fprintf (stderr, "Entering new_state, symbol = %d, state = %d\n",
|
fprintf (stderr, "Entering new_state, state = %d, symbol = %d\n",
|
||||||
symbol, nstates);
|
nstates, symbol);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (nstates >= MAXSHORT)
|
if (nstates >= MAXSHORT)
|
||||||
fatal (_("too many states (max %d)"), MAXSHORT);
|
fatal (_("too many states (max %d)"), MAXSHORT);
|
||||||
@@ -233,10 +231,9 @@ get_state (int symbol)
|
|||||||
|
|
||||||
int n = kernel_end[symbol] - kernel_base[symbol];
|
int n = kernel_end[symbol] - kernel_base[symbol];
|
||||||
|
|
||||||
#if TRACE
|
if (trace_flag)
|
||||||
fprintf (stderr, "Entering get_state, state = %d, symbol = %d\n",
|
fprintf (stderr, "Entering get_state, state = %d, symbol = %d\n",
|
||||||
nstates, symbol);
|
nstates, symbol);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Add up the target state's active item numbers to get a hash key.
|
/* Add up the target state's active item numbers to get a hash key.
|
||||||
*/
|
*/
|
||||||
@@ -296,9 +293,9 @@ append_states (void)
|
|||||||
int j;
|
int j;
|
||||||
int symbol;
|
int symbol;
|
||||||
|
|
||||||
#if TRACE
|
if (trace_flag)
|
||||||
fprintf (stderr, "Entering append_states\n");
|
fprintf (stderr, "Entering append_states\n");
|
||||||
#endif
|
|
||||||
|
|
||||||
/* first sort shift_symbol into increasing order */
|
/* first sort shift_symbol into increasing order */
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
02111-1307, USA. */
|
02111-1307, USA. */
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
#include "getargs.h"
|
||||||
#include "gram.h"
|
#include "gram.h"
|
||||||
#include "reader.h"
|
#include "reader.h"
|
||||||
#include "closure.h"
|
#include "closure.h"
|
||||||
@@ -39,7 +40,6 @@ static int rulesetsize;
|
|||||||
/* number of words required to hold a bit for each variable */
|
/* number of words required to hold a bit for each variable */
|
||||||
static int varsetsize;
|
static int varsetsize;
|
||||||
|
|
||||||
#if TRACE
|
|
||||||
|
|
||||||
/*-----------------.
|
/*-----------------.
|
||||||
| Debugging code. |
|
| Debugging code. |
|
||||||
@@ -97,7 +97,6 @@ print_fderives (void)
|
|||||||
fprintf (stderr, " %d\n", j);
|
fprintf (stderr, " %d\n", j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------------.
|
/*-------------------------------------------------------------------.
|
||||||
| Set FIRSTS to be an NVARS by NVARS bit matrix indicating which |
|
| Set FIRSTS to be an NVARS by NVARS bit matrix indicating which |
|
||||||
@@ -142,9 +141,8 @@ set_firsts (void)
|
|||||||
|
|
||||||
RTC (firsts, nvars);
|
RTC (firsts, nvars);
|
||||||
|
|
||||||
#ifdef TRACE
|
if (trace_flag)
|
||||||
print_firsts ();
|
print_firsts ();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------.
|
/*-------------------------------------------------------------------.
|
||||||
@@ -203,9 +201,8 @@ set_fderives (void)
|
|||||||
rrow += rulesetsize;
|
rrow += rulesetsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TRACE
|
if (trace_flag)
|
||||||
print_fderives ();
|
print_fderives ();
|
||||||
#endif
|
|
||||||
|
|
||||||
XFREE (firsts);
|
XFREE (firsts);
|
||||||
}
|
}
|
||||||
@@ -300,9 +297,8 @@ closure (short *core, int n)
|
|||||||
while (csp < csend)
|
while (csp < csend)
|
||||||
*itemsetend++ = *csp++;
|
*itemsetend++ = *csp++;
|
||||||
|
|
||||||
#if TRACE
|
if (trace_flag)
|
||||||
print_closure (n);
|
print_closure (n);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
#include "getargs.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "reader.h"
|
#include "reader.h"
|
||||||
#include "gram.h"
|
#include "gram.h"
|
||||||
@@ -32,7 +33,6 @@
|
|||||||
|
|
||||||
short **derives;
|
short **derives;
|
||||||
|
|
||||||
#if TRACE
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_derives (void)
|
print_derives (void)
|
||||||
@@ -53,7 +53,6 @@ print_derives (void)
|
|||||||
putc ('\n', stderr);
|
putc ('\n', stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
void
|
||||||
set_derives (void)
|
set_derives (void)
|
||||||
@@ -96,9 +95,8 @@ set_derives (void)
|
|||||||
*q++ = -1;
|
*q++ = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TRACE
|
if (trace_flag)
|
||||||
print_derives ();
|
print_derives ();
|
||||||
#endif
|
|
||||||
|
|
||||||
XFREE (dset + ntokens);
|
XFREE (dset + ntokens);
|
||||||
XFREE (delts);
|
XFREE (delts);
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ int no_lines_flag = 0;
|
|||||||
int no_parser_flag = 0;
|
int no_parser_flag = 0;
|
||||||
int token_table_flag = 0;
|
int token_table_flag = 0;
|
||||||
int verbose_flag = 0;
|
int verbose_flag = 0;
|
||||||
int statistics_flag = 0;
|
|
||||||
int yacc_flag = 0; /* for -y */
|
int yacc_flag = 0; /* for -y */
|
||||||
int graph_flag = 0;
|
int graph_flag = 0;
|
||||||
|
int trace_flag = 0;
|
||||||
|
|
||||||
const char *skeleton = NULL;
|
const char *skeleton = NULL;
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ static struct option longopts[] =
|
|||||||
{"graph", optional_argument, 0, 'g'},
|
{"graph", optional_argument, 0, 'g'},
|
||||||
|
|
||||||
/* Hidden. */
|
/* Hidden. */
|
||||||
{"statistics", no_argument, &statistics_flag, 1},
|
{"trace", no_argument, &trace_flag, 1},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -31,11 +31,11 @@ extern int defines_flag; /* for -d */
|
|||||||
extern int locations_flag;
|
extern int locations_flag;
|
||||||
extern int no_lines_flag; /* for -l */
|
extern int no_lines_flag; /* for -l */
|
||||||
extern int no_parser_flag; /* for -n */
|
extern int no_parser_flag; /* for -n */
|
||||||
extern int statistics_flag;
|
|
||||||
extern int token_table_flag; /* for -k */
|
extern int token_table_flag; /* for -k */
|
||||||
extern int verbose_flag; /* for -v */
|
extern int verbose_flag; /* for -v */
|
||||||
extern int graph_flag; /* for -g */
|
extern int graph_flag; /* for -g */
|
||||||
extern int yacc_flag; /* for -y */
|
extern int yacc_flag; /* for -y */
|
||||||
|
extern int trace_flag;
|
||||||
|
|
||||||
void getargs PARAMS ((int argc, char *argv[]));
|
void getargs PARAMS ((int argc, char *argv[]));
|
||||||
|
|
||||||
|
|||||||
23
src/reduce.c
23
src/reduce.c
@@ -438,7 +438,6 @@ reduce_output (FILE *out)
|
|||||||
fprintf (out, "\n\n");
|
fprintf (out, "\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TRACE
|
|
||||||
static void
|
static void
|
||||||
dump_grammar (FILE *out)
|
dump_grammar (FILE *out)
|
||||||
{
|
{
|
||||||
@@ -478,7 +477,6 @@ dump_grammar (FILE *out)
|
|||||||
}
|
}
|
||||||
fprintf (out, "\n\n");
|
fprintf (out, "\n\n");
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -539,20 +537,15 @@ reduce_grammar (void)
|
|||||||
tags[start_symbol]);
|
tags[start_symbol]);
|
||||||
|
|
||||||
reduce_grammar_tables ();
|
reduce_grammar_tables ();
|
||||||
#if TRACE
|
|
||||||
dump_grammar (stderr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (statistics_flag)
|
if (trace_flag)
|
||||||
fprintf (stderr, _("reduced %s defines %d terminal%s, %d nonterminal%s\
|
{
|
||||||
, and %d production%s.\n"),
|
dump_grammar (stderr);
|
||||||
infile,
|
|
||||||
ntokens,
|
fprintf (stderr, "reduced %s defines %d terminals, %d nonterminals\
|
||||||
(ntokens == 1 ? "" : "s"),
|
, and %d productions.\n",
|
||||||
nvars,
|
infile, ntokens, nvars, nrules);
|
||||||
(nvars == 1 ? "" : "s"),
|
}
|
||||||
nrules,
|
|
||||||
(nrules == 1 ? "" : "s"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user