mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-11 05:13:04 +00:00
The location tracking mechanism is precious for parse error
messages. Nevertheless, it is enabled only when `@n' is used in the grammar, which is a different issue (you can use it in error message, but not in the grammar per se). Therefore, there should be another means to enable it. * src/getargs.c (getargs): Support `--locations'. (usage): Report it. * src/getargs.h (locationsflag): Export it. * src/lex.c (percent_table): Support `%locations'. * src/reader.c (yylsp_needed): Remove this variable, now replaced with `locationsflag'. * doc/bison.texinfo: Document `--locations' and `%locations'. Sort the options. * tests/calc.m4: Test it. For regularity of the names, replace each (nolineflag, toknumflag, rawtokenumflag, noparserflag): with... (no_lineflag, token_tableflag, rawflag, no_parserflag): this. In addition replace each `flag' with `_flag'.
This commit is contained in:
@@ -45,7 +45,7 @@ static int rrc_count;
|
||||
static inline void
|
||||
log_resolution (int state, int LAno, int token, char *resolution)
|
||||
{
|
||||
if (verboseflag)
|
||||
if (verbose_flag)
|
||||
fprintf (foutput,
|
||||
_("\
|
||||
Conflict in state %d between rule %d and token %s resolved as %s.\n"),
|
||||
@@ -456,7 +456,7 @@ print_conflicts (void)
|
||||
src_total += src_count;
|
||||
rrc_total += rrc_count;
|
||||
|
||||
if (verboseflag)
|
||||
if (verbose_flag)
|
||||
{
|
||||
fprintf (foutput, _("State %d contains"), i);
|
||||
conflict_report (foutput, src_count, rrc_count);
|
||||
@@ -465,7 +465,7 @@ print_conflicts (void)
|
||||
}
|
||||
|
||||
/* Report the total number of conflicts on STDERR. */
|
||||
if (yaccflag)
|
||||
if (yacc_flag)
|
||||
{
|
||||
/* If invoked with `--yacc', use the output format specified by
|
||||
POSIX. */
|
||||
|
||||
26
src/files.c
26
src/files.c
@@ -232,7 +232,7 @@ open_files (void)
|
||||
|
||||
static char FIXED_NAME_BASE[] = "y.y";
|
||||
|
||||
name_base = yaccflag ? FIXED_NAME_BASE : infile;
|
||||
name_base = yacc_flag ? FIXED_NAME_BASE : infile;
|
||||
|
||||
/* BASE_LENGTH gets length of NAME_BASE, sans ".y" suffix if any. */
|
||||
|
||||
@@ -255,7 +255,7 @@ open_files (void)
|
||||
|
||||
finput = xfopen (infile, "r");
|
||||
|
||||
if (!noparserflag)
|
||||
if (!no_parser_flag)
|
||||
{
|
||||
filename = getenv ("BISON_SIMPLE");
|
||||
#ifdef MSDOS
|
||||
@@ -273,7 +273,7 @@ open_files (void)
|
||||
fparser = xfopen (filename ? filename : PFILE, "r");
|
||||
}
|
||||
|
||||
if (verboseflag)
|
||||
if (verbose_flag)
|
||||
{
|
||||
#ifdef MSDOS
|
||||
outfile = stringappend (name_base, short_base_length, ".out");
|
||||
@@ -285,7 +285,7 @@ open_files (void)
|
||||
foutput = xfopen (outfile, "w");
|
||||
}
|
||||
|
||||
if (noparserflag)
|
||||
if (no_parser_flag)
|
||||
{
|
||||
/* use permanent name for actions file */
|
||||
actfile = stringappend (name_base, short_base_length, ".act");
|
||||
@@ -293,32 +293,32 @@ open_files (void)
|
||||
}
|
||||
|
||||
#ifdef MSDOS
|
||||
if (!noparserflag)
|
||||
if (!no_parser_flag)
|
||||
actfile = mktemp (stringappend (tmp_base, tmp_len, "acXXXXXX"));
|
||||
tmpattrsfile = mktemp (stringappend (tmp_base, tmp_len, "atXXXXXX"));
|
||||
tmptabfile = mktemp (stringappend (tmp_base, tmp_len, "taXXXXXX"));
|
||||
tmpdefsfile = mktemp (stringappend (tmp_base, tmp_len, "deXXXXXX"));
|
||||
#else
|
||||
if (!noparserflag)
|
||||
if (!no_parser_flag)
|
||||
actfile = mktemp (stringappend (tmp_base, tmp_len, "act.XXXXXX"));
|
||||
tmpattrsfile = mktemp (stringappend (tmp_base, tmp_len, "attrs.XXXXXX"));
|
||||
tmptabfile = mktemp (stringappend (tmp_base, tmp_len, "tab.XXXXXX"));
|
||||
tmpdefsfile = mktemp (stringappend (tmp_base, tmp_len, "defs.XXXXXX"));
|
||||
#endif /* not MSDOS */
|
||||
|
||||
if (!noparserflag)
|
||||
if (!no_parser_flag)
|
||||
faction = xfopen (actfile, "w+");
|
||||
fattrs = xfopen (tmpattrsfile, "w+");
|
||||
ftable = xfopen (tmptabfile, "w+");
|
||||
|
||||
if (definesflag)
|
||||
if (defines_flag)
|
||||
{
|
||||
defsfile = stringappend (name_base, base_length, ".h");
|
||||
fdefines = xfopen (tmpdefsfile, "w+");
|
||||
}
|
||||
|
||||
#if !(defined (MSDOS) || (defined(_WIN32) && !defined(__CYGWIN32__)))
|
||||
if (!noparserflag)
|
||||
if (!no_parser_flag)
|
||||
unlink (actfile);
|
||||
unlink (tmpattrsfile);
|
||||
unlink (tmptabfile);
|
||||
@@ -364,7 +364,7 @@ open_extra_files (void)
|
||||
|
||||
xfclose (fparser);
|
||||
|
||||
if (!noparserflag)
|
||||
if (!no_parser_flag)
|
||||
{
|
||||
filename = (char *) getenv ("BISON_HAIRY");
|
||||
#ifdef MSDOS
|
||||
@@ -417,7 +417,7 @@ done (void)
|
||||
xfclose (ftmp);
|
||||
xfclose (ftable);
|
||||
|
||||
if (definesflag)
|
||||
if (defines_flag)
|
||||
{
|
||||
ftmp = xfopen (defsfile, "w");
|
||||
fflush (fdefines);
|
||||
@@ -430,7 +430,7 @@ done (void)
|
||||
}
|
||||
|
||||
#if defined (VMS) & !defined (__VMS_POSIX)
|
||||
if (faction && !noparserflag)
|
||||
if (faction && !no_parser_flag)
|
||||
delete (actfile);
|
||||
if (fattrs)
|
||||
delete (tmpattrsfile);
|
||||
@@ -442,7 +442,7 @@ done (void)
|
||||
sys$exit(SS$_ABORT); */
|
||||
#else
|
||||
#if (defined (MSDOS) || (defined(_WIN32) && !defined(__CYGWIN32__)))
|
||||
if (actfile && !noparserflag)
|
||||
if (actfile && !no_parser_flag)
|
||||
unlink (actfile);
|
||||
if (tmpattrsfile)
|
||||
unlink (tmpattrsfile);
|
||||
|
||||
@@ -27,36 +27,38 @@
|
||||
char *spec_file_prefix; /* for -b. */
|
||||
char *spec_name_prefix; /* for -p. */
|
||||
|
||||
int debugflag = 0;
|
||||
int definesflag = 0;
|
||||
int nolinesflag = 0;
|
||||
int noparserflag = 0;
|
||||
int rawtoknumflag = 0;
|
||||
int toknumflag = 0;
|
||||
int verboseflag = 0;
|
||||
int statisticsflag = 0;
|
||||
int yaccflag = 0; /* for -y */
|
||||
int debug_flag = 0;
|
||||
int defines_flag = 0;
|
||||
int locations_flag = 0;
|
||||
int no_lines_flag = 0;
|
||||
int no_parser_flag = 0;
|
||||
int raw_flag = 0;
|
||||
int token_table_flag = 0;
|
||||
int verbose_flag = 0;
|
||||
int statistics_flag = 0;
|
||||
int yacc_flag = 0; /* for -y */
|
||||
|
||||
extern char *program_name;
|
||||
|
||||
static struct option longopts[] =
|
||||
{
|
||||
{"debug", 0, &debugflag, 1},
|
||||
{"defines", 0, &definesflag, 1},
|
||||
{"debug", 0, &debug_flag, 1},
|
||||
{"defines", 0, &defines_flag, 1},
|
||||
{"file-prefix", 1, 0, 'b'},
|
||||
{"fixed-output-files", 0, &yaccflag, 1},
|
||||
{"fixed-output-files", 0, &yacc_flag, 1},
|
||||
{"help", 0, 0, 'h'},
|
||||
{"name-prefix", 1, 0, 'p'}, /* was 'a'; apparently unused -wjh */
|
||||
{"no-lines", 0, &nolinesflag, 1},
|
||||
{"no-parser", 0, &noparserflag, 1},
|
||||
{"locations", 0, &locations_flag, 1},
|
||||
{"no-lines", 0, &no_lines_flag, 1},
|
||||
{"no-parser", 0, &no_parser_flag, 1},
|
||||
{"output", 1, 0, 'o'},
|
||||
{"output-file", 1, 0, 'o'},
|
||||
{"raw", 0, &rawtoknumflag, 1},
|
||||
{"token-table", 0, &toknumflag, 1},
|
||||
{"verbose", 0, &verboseflag, 1},
|
||||
{"raw", 0, &raw_flag, 1},
|
||||
{"statistics", 0, &statistics_flag, 1},
|
||||
{"token-table", 0, &token_table_flag, 1},
|
||||
{"verbose", 0, &verbose_flag, 1},
|
||||
{"version", 0, 0, 'V'},
|
||||
{"yacc", 0, &yaccflag, 1},
|
||||
{"statistics", 0, &statisticsflag, 1},
|
||||
{"yacc", 0, &yacc_flag, 1},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -93,6 +95,7 @@ Operation modes:\n\
|
||||
fputs (_("\
|
||||
Parser:\n\
|
||||
-t, --debug instrument the parser for debugging\n\
|
||||
--locations enable locations computation\n\
|
||||
-p, --name-prefix=PREFIX prepend PREFIX to the external symbols\n\
|
||||
-l, --no-lines don't generate `#line' directives\n\
|
||||
-n, --no-parser generate the tables only\n\
|
||||
@@ -159,7 +162,7 @@ getargs (int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
yaccflag = 1;
|
||||
yacc_flag = 1;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
@@ -171,31 +174,31 @@ getargs (int argc, char *argv[])
|
||||
exit (0);
|
||||
|
||||
case 'v':
|
||||
verboseflag = 1;
|
||||
verbose_flag = 1;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
definesflag = 1;
|
||||
defines_flag = 1;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
nolinesflag = 1;
|
||||
no_lines_flag = 1;
|
||||
break;
|
||||
|
||||
case 'k':
|
||||
toknumflag = 1;
|
||||
token_table_flag = 1;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
rawtoknumflag = 1;
|
||||
raw_flag = 1;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
noparserflag = 1;
|
||||
no_parser_flag = 1;
|
||||
break;
|
||||
|
||||
case 't':
|
||||
debugflag = 1;
|
||||
debug_flag = 1;
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
|
||||
@@ -25,15 +25,16 @@
|
||||
extern char *spec_file_prefix; /* for -b */
|
||||
extern char *spec_name_prefix; /* for -p */
|
||||
|
||||
extern int debugflag; /* for -t */
|
||||
extern int definesflag; /* for -d */
|
||||
extern int nolinesflag; /* for -l */
|
||||
extern int noparserflag; /* for -n */
|
||||
extern int rawtoknumflag; /* for -r */
|
||||
extern int statisticsflag;
|
||||
extern int toknumflag; /* for -k */
|
||||
extern int verboseflag; /* for -v */
|
||||
extern int yaccflag; /* for -y */
|
||||
extern int debug_flag; /* for -t */
|
||||
extern int defines_flag; /* for -d */
|
||||
extern int locations_flag;
|
||||
extern int no_lines_flag; /* for -l */
|
||||
extern int no_parser_flag; /* for -n */
|
||||
extern int raw_flag; /* for -r */
|
||||
extern int statistics_flag;
|
||||
extern int token_table_flag; /* for -k */
|
||||
extern int verbose_flag; /* for -v */
|
||||
extern int yacc_flag; /* for -y */
|
||||
|
||||
void getargs PARAMS ((int argc, char *argv[]));
|
||||
|
||||
|
||||
29
src/lex.c
29
src/lex.c
@@ -513,12 +513,12 @@ lex (void)
|
||||
}
|
||||
|
||||
/* the following table dictates the action taken for the various %
|
||||
directives. A setflag value causes the named flag to be set. A
|
||||
directives. A set_flag value causes the named flag to be set. A
|
||||
retval action returns the code. */
|
||||
struct percent_table_struct
|
||||
{
|
||||
const char *name;
|
||||
void *setflag;
|
||||
void *set_flag;
|
||||
int retval;
|
||||
}
|
||||
percent_table[] =
|
||||
@@ -539,25 +539,26 @@ percent_table[] =
|
||||
{ "semantic_parser", NULL, SEMANTIC_PARSER },
|
||||
{ "pure_parser", NULL, PURE_PARSER },
|
||||
{ "prec", NULL, PREC },
|
||||
{ "no_lines", &nolinesflag, NOOP}, /* -l */
|
||||
{ "raw", &rawtoknumflag, NOOP }, /* -r */
|
||||
{ "token_table", &toknumflag, NOOP}, /* -k */
|
||||
{ "locations", &locations_flag, NOOP}, /* -l */
|
||||
{ "no_lines", &no_lines_flag, NOOP}, /* -l */
|
||||
{ "raw", &raw_flag, NOOP }, /* -r */
|
||||
{ "token_table", &token_table_flag, NOOP}, /* -k */
|
||||
#if 0
|
||||
/* These can be utilized after main is reoganized so
|
||||
open_files() is deferred 'til after read_declarations().
|
||||
But %{ and %union both put information into files
|
||||
that have to be opened before read_declarations().
|
||||
*/
|
||||
{ "yacc", &yaccflag, NOOP}, /* -y */
|
||||
{ "fixed_output_files", &yaccflag, NOOP}, /* -y */
|
||||
{ "defines", &definesflag, NOOP}, /* -d */
|
||||
{ "no_parser", &noparserflag, NOOP}, /* -n */
|
||||
{ "yacc", &yacc_flag, NOOP}, /* -y */
|
||||
{ "fixed_output_files", &yacc_flag, NOOP}, /* -y */
|
||||
{ "defines", &defines_flag, NOOP}, /* -d */
|
||||
{ "no_parser", &no_parser_flag, NOOP}, /* -n */
|
||||
{ "output_file", &spec_outfile, SETOPT}, /* -o */
|
||||
{ "file_prefix", &spec_file_prefix, SETOPT}, /* -b */
|
||||
{ "name_prefix", &spec_name_prefix, SETOPT}, /* -p */
|
||||
/* These would be acceptable, but they do not affect processing */
|
||||
{ "verbose", &verboseflag, NOOP}, /* -v */
|
||||
{ "debug", &debugflag, NOOP}, /* -t */
|
||||
{ "verbose", &verbose_flag, NOOP}, /* -v */
|
||||
{ "debug", &debug_flag, NOOP}, /* -t */
|
||||
/* {"help", <print usage stmt>, NOOP}, *//* -h */
|
||||
/* {"version", <print version number> , NOOP}, *//* -V */
|
||||
#endif
|
||||
@@ -629,12 +630,12 @@ parse_percent_token (void)
|
||||
break;
|
||||
if (tx->retval == SETOPT)
|
||||
{
|
||||
*((char **) (tx->setflag)) = optarg;
|
||||
*((char **) (tx->set_flag)) = optarg;
|
||||
return NOOP;
|
||||
}
|
||||
if (tx->setflag)
|
||||
if (tx->set_flag)
|
||||
{
|
||||
*((int *) (tx->setflag)) = 1;
|
||||
*((int *) (tx->set_flag)) = 1;
|
||||
return NOOP;
|
||||
}
|
||||
return tx->retval;
|
||||
|
||||
28
src/output.c
28
src/output.c
@@ -203,7 +203,7 @@ output_headers (void)
|
||||
if (semantic_parser)
|
||||
fprintf (fguard, GUARDSTR, attrsfile);
|
||||
|
||||
if (noparserflag)
|
||||
if (no_parser_flag)
|
||||
return;
|
||||
|
||||
fprintf (faction, (semantic_parser ? ACTSTR : ACTSTR_SIMPLE), attrsfile);
|
||||
@@ -238,7 +238,7 @@ output_trailers (void)
|
||||
|
||||
fprintf (faction, "\n");
|
||||
|
||||
if (noparserflag)
|
||||
if (no_parser_flag)
|
||||
return;
|
||||
|
||||
if (semantic_parser)
|
||||
@@ -300,8 +300,8 @@ output_gram (void)
|
||||
|
||||
/* With the ordinary parser,
|
||||
yyprhs and yyrhs are needed only for yydebug. */
|
||||
/* With the noparser option, all tables are generated */
|
||||
if (!semantic_parser && !noparserflag)
|
||||
/* With the no_parser option, all tables are generated */
|
||||
if (!semantic_parser && !no_parser_flag)
|
||||
fprintf (ftable, "\n#if YYDEBUG != 0\n");
|
||||
|
||||
output_short_table (ftable, "yyprhs", rrhs,
|
||||
@@ -332,7 +332,7 @@ output_gram (void)
|
||||
|
||||
fprintf (ftable, "\n};\n");
|
||||
|
||||
if (!semantic_parser && !noparserflag)
|
||||
if (!semantic_parser && !no_parser_flag)
|
||||
fprintf (ftable, "\n#endif\n");
|
||||
}
|
||||
|
||||
@@ -361,7 +361,7 @@ output_rule_data (void)
|
||||
|
||||
fputs ("#endif\n\n", ftable);
|
||||
|
||||
if (toknumflag || noparserflag)
|
||||
if (token_table_flag || no_parser_flag)
|
||||
{
|
||||
fprintf (ftable, "#define YYNTOKENS %d\n", ntokens);
|
||||
fprintf (ftable, "#define YYNNTS %d\n", nvars);
|
||||
@@ -370,7 +370,7 @@ output_rule_data (void)
|
||||
fprintf (ftable, "#define YYMAXUTOK %d\n\n", max_user_token_number);
|
||||
}
|
||||
|
||||
if (!toknumflag && !noparserflag)
|
||||
if (!token_table_flag && !no_parser_flag)
|
||||
fprintf (ftable, "\n#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)\n\n");
|
||||
|
||||
/* Output the table of symbol names. */
|
||||
@@ -436,11 +436,11 @@ output_rule_data (void)
|
||||
/* add a NULL entry to list of tokens */
|
||||
fprintf (ftable, ", NULL\n};\n");
|
||||
|
||||
if (!toknumflag && !noparserflag)
|
||||
if (!token_table_flag && !no_parser_flag)
|
||||
fprintf (ftable, "#endif\n\n");
|
||||
|
||||
/* Output YYTOKNUM. */
|
||||
if (toknumflag)
|
||||
if (token_table_flag)
|
||||
{
|
||||
output_short_table (ftable, "yytoknum", user_toknums,
|
||||
0, 1, ntokens + 1);
|
||||
@@ -1195,7 +1195,7 @@ output_parser (void)
|
||||
|
||||
/* See if the line starts with `#line.
|
||||
If so, set write_line to 0. */
|
||||
if (nolinesflag)
|
||||
if (no_lines_flag)
|
||||
if (c == '#')
|
||||
{
|
||||
c = getc (fpars);
|
||||
@@ -1254,7 +1254,7 @@ output_program (void)
|
||||
{
|
||||
int c;
|
||||
|
||||
if (!nolinesflag)
|
||||
if (!no_lines_flag)
|
||||
fprintf (ftable, "#line %d \"%s\"\n", lineno, infile);
|
||||
|
||||
c = getc (finput);
|
||||
@@ -1298,7 +1298,7 @@ output (void)
|
||||
putc (c, ftable);
|
||||
}
|
||||
reader_output_yylsp (ftable);
|
||||
if (debugflag)
|
||||
if (debug_flag)
|
||||
fputs ("\
|
||||
#ifndef YYDEBUG\n\
|
||||
# define YYDEBUG 1\n\
|
||||
@@ -1309,7 +1309,7 @@ output (void)
|
||||
if (semantic_parser)
|
||||
fprintf (ftable, "#include \"%s\"\n", attrsfile);
|
||||
|
||||
if (!noparserflag)
|
||||
if (!no_parser_flag)
|
||||
fprintf (ftable, "#include <stdio.h>\n\n");
|
||||
|
||||
/* Make "const" do nothing if not in ANSI C. */
|
||||
@@ -1333,7 +1333,7 @@ output (void)
|
||||
output_stos ();
|
||||
output_rule_data ();
|
||||
output_actions ();
|
||||
if (!noparserflag)
|
||||
if (!no_parser_flag)
|
||||
output_parser ();
|
||||
output_program ();
|
||||
}
|
||||
|
||||
@@ -351,10 +351,10 @@ print_results (void)
|
||||
if (any_conflicts)
|
||||
print_conflicts ();
|
||||
|
||||
if (verboseflag)
|
||||
if (verbose_flag)
|
||||
print_grammar ();
|
||||
|
||||
if (verboseflag)
|
||||
if (verbose_flag)
|
||||
for (i = 0; i < nstates; i++)
|
||||
print_state (i);
|
||||
}
|
||||
|
||||
64
src/reader.c
64
src/reader.c
@@ -67,9 +67,6 @@ static int gensym_count;
|
||||
|
||||
static bucket *errtoken;
|
||||
static bucket *undeftoken;
|
||||
|
||||
/* Nonzero if any action or guard uses the @n construct. */
|
||||
static int yylsp_needed;
|
||||
|
||||
|
||||
/*===================\
|
||||
@@ -256,7 +253,7 @@ copy_at (FILE *fin, FILE *fout, int stack_offset)
|
||||
if (c == '$')
|
||||
{
|
||||
fprintf (fout, "yyloc");
|
||||
yylsp_needed = 1;
|
||||
locations_flag = 1;
|
||||
}
|
||||
else if (isdigit (c) || c == '-')
|
||||
{
|
||||
@@ -266,7 +263,7 @@ copy_at (FILE *fin, FILE *fout, int stack_offset)
|
||||
n = read_signed_integer (fin);
|
||||
|
||||
fprintf (fout, "yylsp[%d]", n - stack_offset);
|
||||
yylsp_needed = 1;
|
||||
locations_flag = 1;
|
||||
}
|
||||
else
|
||||
complain (_("@%s is invalid"), printable_version (c));
|
||||
@@ -284,7 +281,7 @@ copy_definition (void)
|
||||
/* -1 while reading a character if prev char was %. */
|
||||
int after_percent;
|
||||
|
||||
if (!nolinesflag)
|
||||
if (!no_lines_flag)
|
||||
fprintf (fattrs, "#line %d \"%s\"\n", lineno, infile);
|
||||
|
||||
after_percent = 0;
|
||||
@@ -631,7 +628,7 @@ parse_union_decl (void)
|
||||
|
||||
typed = 1;
|
||||
|
||||
if (!nolinesflag)
|
||||
if (!no_lines_flag)
|
||||
fprintf (fattrs, "\n#line %d \"%s\"\n", lineno, infile);
|
||||
else
|
||||
fprintf (fattrs, "\n");
|
||||
@@ -919,7 +916,7 @@ copy_action (symbol_list * rule, int stack_offset)
|
||||
stack_offset = 0;
|
||||
|
||||
fprintf (faction, "\ncase %d:\n", nrules);
|
||||
if (!nolinesflag)
|
||||
if (!no_lines_flag)
|
||||
fprintf (faction, "#line %d \"%s\"\n", lineno, infile);
|
||||
putc ('{', faction);
|
||||
|
||||
@@ -1058,7 +1055,7 @@ copy_guard (symbol_list * rule, int stack_offset)
|
||||
stack_offset = 0;
|
||||
|
||||
fprintf (fguard, "\ncase %d:\n", nrules);
|
||||
if (!nolinesflag)
|
||||
if (!no_lines_flag)
|
||||
fprintf (fguard, "#line %d \"%s\"\n", lineno, infile);
|
||||
putc ('{', fguard);
|
||||
|
||||
@@ -1303,7 +1300,7 @@ readgram (void)
|
||||
{
|
||||
if (t == IDENTIFIER || t == BAR)
|
||||
{
|
||||
int actionflag = 0;
|
||||
int action_flag = 0;
|
||||
int rulelength = 0; /* number of symbols in rhs of this rule so far */
|
||||
int xactions = 0; /* JF for error checking */
|
||||
bucket *first_rhs = 0;
|
||||
@@ -1399,7 +1396,7 @@ readgram (void)
|
||||
/* If we just passed an action, that action was in the middle
|
||||
of a rule, so make a dummy rule to reduce it to a
|
||||
non-terminal. */
|
||||
if (actionflag)
|
||||
if (action_flag)
|
||||
{
|
||||
bucket *sdummy;
|
||||
|
||||
@@ -1433,7 +1430,7 @@ readgram (void)
|
||||
p1->next = p;
|
||||
p1 = p;
|
||||
|
||||
actionflag = 0;
|
||||
action_flag = 0;
|
||||
}
|
||||
|
||||
if (t == IDENTIFIER)
|
||||
@@ -1447,7 +1444,7 @@ readgram (void)
|
||||
else /* handle an action. */
|
||||
{
|
||||
copy_action (crule, rulelength);
|
||||
actionflag = 1;
|
||||
action_flag = 1;
|
||||
xactions++; /* JF */
|
||||
}
|
||||
rulelength++;
|
||||
@@ -1478,10 +1475,10 @@ readgram (void)
|
||||
else if (t == LEFT_CURLY)
|
||||
{
|
||||
/* This case never occurs -wjh */
|
||||
if (actionflag)
|
||||
if (action_flag)
|
||||
complain (_("two actions at end of one rule"));
|
||||
copy_action (crule, rulelength);
|
||||
actionflag = 1;
|
||||
action_flag = 1;
|
||||
xactions++; /* -wjh */
|
||||
t = lex ();
|
||||
}
|
||||
@@ -1622,7 +1619,7 @@ output_token_defines (FILE *file)
|
||||
continue;
|
||||
|
||||
fprintf (file, "#define\t%s\t%d\n", symbol,
|
||||
((translations && !rawtoknumflag)
|
||||
((translations && !raw_flag)
|
||||
? bp->user_token_number : bp->value));
|
||||
if (semantic_parser)
|
||||
fprintf (file, "#define\tT%s\t%d\n", symbol, bp->value);
|
||||
@@ -1750,7 +1747,7 @@ packsymbols (void)
|
||||
|
||||
error_token_number = errtoken->value;
|
||||
|
||||
if (!noparserflag)
|
||||
if (!no_parser_flag)
|
||||
output_token_defines (ftable);
|
||||
|
||||
if (startval->class == unknown_sym)
|
||||
@@ -1760,7 +1757,7 @@ packsymbols (void)
|
||||
|
||||
start_symbol = startval->value;
|
||||
|
||||
if (definesflag)
|
||||
if (defines_flag)
|
||||
{
|
||||
output_token_defines (fdefines);
|
||||
|
||||
@@ -1892,7 +1889,6 @@ reader (void)
|
||||
|
||||
semantic_parser = 0;
|
||||
pure_parser = 0;
|
||||
yylsp_needed = 0;
|
||||
|
||||
grammar = NULL;
|
||||
|
||||
@@ -1918,7 +1914,7 @@ reader (void)
|
||||
fprintf (ftable, "\
|
||||
/* %s, made from %s\n\
|
||||
by GNU bison %s. */\n\
|
||||
\n", noparserflag ? "Bison-generated parse tables" : "A Bison parser", infile, VERSION);
|
||||
\n", no_parser_flag ? "Bison-generated parse tables" : "A Bison parser", infile, VERSION);
|
||||
|
||||
fputs ("#define YYBISON 1 /* Identify Bison output. */\n\n", ftable);
|
||||
read_declarations ();
|
||||
@@ -1933,7 +1929,7 @@ reader (void)
|
||||
reader_output_yylsp (fdefines);
|
||||
/* Write closing delimiters for actions and guards. */
|
||||
output_trailers ();
|
||||
if (yylsp_needed)
|
||||
if (locations_flag)
|
||||
fputs ("#define YYLSP_NEEDED\n\n", ftable);
|
||||
/* Assign the symbols their symbol numbers. Write #defines for the
|
||||
token symbols into FDEFINES if requested. */
|
||||
@@ -1949,26 +1945,22 @@ reader (void)
|
||||
void
|
||||
reader_output_yylsp (FILE *f)
|
||||
{
|
||||
if (yylsp_needed)
|
||||
if (locations_flag)
|
||||
fputs ("\
|
||||
\n\
|
||||
#ifndef YYLTYPE\n\
|
||||
typedef\n\
|
||||
struct yyltype\n\
|
||||
\
|
||||
{\n\
|
||||
int timestamp;\n\
|
||||
int first_line;\n\
|
||||
int first_column;\
|
||||
typedef struct yyltype\n\
|
||||
{\n\
|
||||
int timestamp;\n\
|
||||
int first_line;\n\
|
||||
int first_column;\
|
||||
\n\
|
||||
int last_line;\n\
|
||||
int last_column;\n\
|
||||
char *text;\n\
|
||||
}\n\
|
||||
\
|
||||
yyltype;\n\
|
||||
int last_line;\n\
|
||||
int last_column;\n\
|
||||
char *text;\n\
|
||||
} yyltype;\n\
|
||||
\n\
|
||||
#define YYLTYPE yyltype\n\
|
||||
# define YYLTYPE yyltype\n\
|
||||
#endif\n\
|
||||
\n",
|
||||
f);
|
||||
|
||||
@@ -483,7 +483,7 @@ dump_grammar (void)
|
||||
static void
|
||||
print_notices (void)
|
||||
{
|
||||
if (yaccflag && nuseless_productions)
|
||||
if (yacc_flag && nuseless_productions)
|
||||
fprintf (stderr, _("%d rules never reduced\n"), nuseless_productions);
|
||||
|
||||
fprintf (stderr, _("%s contains "), infile);
|
||||
@@ -523,7 +523,7 @@ reduce_grammar (void)
|
||||
|
||||
reduced = (bool) (nuseless_nonterminals + nuseless_productions > 0);
|
||||
|
||||
if (verboseflag)
|
||||
if (verbose_flag)
|
||||
print_results ();
|
||||
|
||||
if (reduced == FALSE)
|
||||
@@ -537,14 +537,14 @@ reduce_grammar (void)
|
||||
|
||||
reduce_grammar_tables ();
|
||||
#if 0
|
||||
if (verboseflag)
|
||||
if (verbose_flag)
|
||||
{
|
||||
fprintf (foutput, "REDUCED GRAMMAR\n\n");
|
||||
dump_grammar ();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (statisticsflag)
|
||||
if (statistics_flag)
|
||||
fprintf (stderr, _("reduced %s defines %d terminal%s, %d nonterminal%s\
|
||||
, and %d production%s.\n"),
|
||||
infile,
|
||||
|
||||
@@ -27,14 +27,14 @@ Boston, MA 02111-1307, USA. */
|
||||
* VMS version of getargs: Uses DCL command parsing
|
||||
* (argc and argv are ignored)
|
||||
*/
|
||||
int verboseflag;
|
||||
int definesflag;
|
||||
int debugflag;
|
||||
int nolinesflag;
|
||||
extern int noparserflag;
|
||||
extern int toknumflag;
|
||||
extern int rawtoknumflag;
|
||||
extern int yaccflag;
|
||||
int verbose_flag;
|
||||
int defines_flag;
|
||||
int debug_flag;
|
||||
int no_lines_flag;
|
||||
extern int no_parser_flag;
|
||||
extern int token_table_flag;
|
||||
extern int raw_flag;
|
||||
extern int yacc_flag;
|
||||
extern char * version_string;
|
||||
|
||||
/* Allocate storgate and initialize, since bison uses them elsewhere. */
|
||||
@@ -50,27 +50,27 @@ getargs(argc,argv)
|
||||
static char output_spec[256], name_prefix_spec[256], file_prefix_spec[256];
|
||||
extern char *infile;
|
||||
|
||||
verboseflag = 0;
|
||||
definesflag = 0;
|
||||
debugflag = 0;
|
||||
yaccflag = 0;
|
||||
nolinesflag = 0;
|
||||
noparserflag = 0;
|
||||
toknumflag = 0;
|
||||
rawtoknumflag = 0;
|
||||
verbose_flag = 0;
|
||||
defines_flag = 0;
|
||||
debug_flag = 0;
|
||||
yacc_flag = 0;
|
||||
no_lines_flag = 0;
|
||||
no_parser_flag = 0;
|
||||
token_table_flag = 0;
|
||||
raw_flag = 0;
|
||||
/*
|
||||
* Check for /VERBOSE qualifier
|
||||
*/
|
||||
if (cli_present("BISON$VERBOSE")) verboseflag = 1;
|
||||
if (cli_present("BISON$VERBOSE")) verbose_flag = 1;
|
||||
/*
|
||||
* Check for /DEFINES qualifier
|
||||
*/
|
||||
if (cli_present("BISON$DEFINES")) definesflag = 1;
|
||||
if (cli_present("BISON$DEFINES")) defines_flag = 1;
|
||||
/*
|
||||
* Check for /FIXED_OUTFILES qualifier
|
||||
*/
|
||||
if (cli_present("BISON$FIXED_OUTFILES")) yaccflag = 1;
|
||||
if (cli_present("BISON$YACC")) yaccflag = 1;
|
||||
if (cli_present("BISON$FIXED_OUTFILES")) yacc_flag = 1;
|
||||
if (cli_present("BISON$YACC")) yacc_flag = 1;
|
||||
/*
|
||||
* Check for /VERSION qualifier
|
||||
*/
|
||||
@@ -78,23 +78,23 @@ getargs(argc,argv)
|
||||
/*
|
||||
* Check for /NOLINES qualifier
|
||||
*/
|
||||
if (cli_present("BISON$NOLINES")) nolinesflag = 1;
|
||||
if (cli_present("BISON$NOLINES")) no_lines_flag = 1;
|
||||
/*
|
||||
* Check for /NOPARSER qualifier
|
||||
*/
|
||||
if (cli_present("BISON$NOPARSER")) noparserflag = 1;
|
||||
if (cli_present("BISON$NOPARSER")) no_parser_flag = 1;
|
||||
/*
|
||||
* Check for /RAW qualifier
|
||||
*/
|
||||
if (cli_present("BISON$RAW")) rawtoknumflag = 1;
|
||||
if (cli_present("BISON$RAW")) raw_flag = 1;
|
||||
/*
|
||||
* Check for /TOKEN_TABLE qualifier
|
||||
*/
|
||||
if (cli_present("BISON$TOKEN_TABLE")) toknumflag = 1;
|
||||
if (cli_present("BISON$TOKEN_TABLE")) token_table_flag = 1;
|
||||
/*
|
||||
* Check for /DEBUG qualifier
|
||||
*/
|
||||
if (cli_present("BISON$DEBUG")) debugflag = 1;
|
||||
if (cli_present("BISON$DEBUG")) debug_flag = 1;
|
||||
/*
|
||||
* Get the filename
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user