mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-10 12:53:03 +00:00
Add support for an Autotest test suite for Bison.
* m4/m4.m4, m4/atconfig.m4: New files. * m4/Makefile.am (EXTRA_DIST): Adjust. * tests/suite.m4, tests/Makefile.am, tests/atgeneral.m4: New files. * src/getargs.c: Display a more standard --version message. * src/reader.c (reader): Formatting changes. No longer depend upon VERSION_STRING. * configure.in: No longer use `dnl'. Set up the test suite and the new directory `tests/. (VERSION_STRING): Remove.
This commit is contained in:
@@ -37,7 +37,6 @@ extern int fixed_outfiles;/* for -y */
|
||||
extern char *program_name;
|
||||
|
||||
extern void warns PARAMS((char *, char *)); /* main.c */
|
||||
static void usage PARAMS((FILE *));
|
||||
extern void getargs PARAMS((int argc, char *[]));
|
||||
|
||||
static struct option longopts[] =
|
||||
@@ -63,6 +62,7 @@ static struct option longopts[] =
|
||||
/*---------------------------.
|
||||
| Display the help message. |
|
||||
`---------------------------*/
|
||||
|
||||
static void
|
||||
usage (FILE *stream)
|
||||
{
|
||||
@@ -112,6 +112,37 @@ Output:\n\
|
||||
Report bugs to <bug-bison@gnu.org>.\n"), stream);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------.
|
||||
| Display the version message. |
|
||||
`------------------------------*/
|
||||
|
||||
static void
|
||||
version (FILE *stream)
|
||||
{
|
||||
/* Some efforts were made to ease the translators' task, please
|
||||
continue. */
|
||||
fprintf (stream, _("\
|
||||
bison (GNU Bison) %s"), VERSION);
|
||||
putc ('\n', stream);
|
||||
putc ('\n', stream);
|
||||
|
||||
fputs (_("\
|
||||
Copyright (C) 1984, 1986, 1989, 1992, 2000 Free Software Foundation, Inc.\n"),
|
||||
stream);
|
||||
|
||||
fputs (_("\
|
||||
This is free software; see the source for copying conditions. There is NO\n\
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
|
||||
"),
|
||||
stream);
|
||||
}
|
||||
|
||||
|
||||
/*----------------------.
|
||||
| Process the options. |
|
||||
`----------------------*/
|
||||
|
||||
void
|
||||
getargs (int argc, char *argv[])
|
||||
{
|
||||
@@ -143,7 +174,7 @@ getargs (int argc, char *argv[])
|
||||
exit (0);
|
||||
|
||||
case 'V':
|
||||
printf ("%s\n", VERSION_STRING);
|
||||
version (stdout);
|
||||
exit (0);
|
||||
|
||||
case 'v':
|
||||
@@ -194,12 +225,12 @@ getargs (int argc, char *argv[])
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
fprintf(stderr, _("%s: no grammar file given\n"), program_name);
|
||||
exit(1);
|
||||
fprintf (stderr, _("%s: no grammar file given\n"), program_name);
|
||||
exit (1);
|
||||
}
|
||||
if (optind < argc - 1)
|
||||
fprintf(stderr, _("%s: extra arguments ignored after `%s'\n"),
|
||||
program_name, argv[optind]);
|
||||
fprintf (stderr, _("%s: extra arguments ignored after `%s'\n"),
|
||||
program_name, argv[optind]);
|
||||
|
||||
infile = argv[optind];
|
||||
}
|
||||
|
||||
91
src/reader.c
91
src/reader.c
@@ -283,11 +283,12 @@ reader (void)
|
||||
startval = NULL; /* start symbol not specified yet. */
|
||||
|
||||
#if 0
|
||||
translations = 0; /* initially assume token number translation not needed. */
|
||||
/* initially assume token number translation not needed. */
|
||||
translations = 0;
|
||||
#endif
|
||||
/* Nowadays translations is always set to 1,
|
||||
since we give `error' a user-token-number
|
||||
to satisfy the Posix demand for YYERRCODE==256. */
|
||||
/* Nowadays translations is always set to 1, since we give `error' a
|
||||
user-token-number to satisfy the Posix demand for YYERRCODE==256.
|
||||
*/
|
||||
translations = 1;
|
||||
|
||||
nsyms = 1;
|
||||
@@ -295,7 +296,7 @@ reader (void)
|
||||
nrules = 0;
|
||||
nitems = 0;
|
||||
rline_allocated = 10;
|
||||
rline = NEW2(rline_allocated, short);
|
||||
rline = NEW2 (rline_allocated, short);
|
||||
|
||||
typed = 0;
|
||||
lastprec = 0;
|
||||
@@ -308,50 +309,56 @@ reader (void)
|
||||
|
||||
grammar = NULL;
|
||||
|
||||
init_lex();
|
||||
init_lex ();
|
||||
lineno = 1;
|
||||
|
||||
/* initialize the symbol table. */
|
||||
tabinit();
|
||||
/* construct the error token */
|
||||
errtoken = getsym("error");
|
||||
/* Initialize the symbol table. */
|
||||
tabinit ();
|
||||
/* Construct the error token */
|
||||
errtoken = getsym ("error");
|
||||
errtoken->class = STOKEN;
|
||||
errtoken->user_token_number = 256; /* Value specified by posix. */
|
||||
/* construct a token that represents all undefined literal tokens. */
|
||||
/* it is always token number 2. */
|
||||
undeftoken = getsym("$undefined.");
|
||||
errtoken->user_token_number = 256; /* Value specified by POSIX. */
|
||||
/* Construct a token that represents all undefined literal tokens.
|
||||
It is always token number 2. */
|
||||
undeftoken = getsym ("$undefined.");
|
||||
undeftoken->class = STOKEN;
|
||||
undeftoken->user_token_number = 2;
|
||||
/* Read the declaration section. Copy %{ ... %} groups to ftable and fdefines file.
|
||||
Also notice any %token, %left, etc. found there. */
|
||||
if (noparserflag)
|
||||
fprintf(ftable, "\n/* Bison-generated parse tables, made from %s\n",
|
||||
infile);
|
||||
else
|
||||
fprintf(ftable, "\n/* A Bison parser, made from %s\n", infile);
|
||||
fprintf(ftable, " by %s */\n\n", VERSION_STRING);
|
||||
fprintf(ftable, "#define YYBISON 1 /* Identify Bison output. */\n\n");
|
||||
read_declarations();
|
||||
/* start writing the guard and action files, if they are needed. */
|
||||
output_headers();
|
||||
/* read in the grammar, build grammar in list form. write out guards and actions. */
|
||||
readgram();
|
||||
/* Now we know whether we need the line-number stack.
|
||||
If we do, write its type into the .tab.h file. */
|
||||
|
||||
/* Read the declaration section. Copy %{ ... %} groups to FTABLE
|
||||
and FDEFINES file. Also notice any %token, %left, etc. found
|
||||
there. */
|
||||
putc ('\n', ftable);
|
||||
fprintf (ftable, "\
|
||||
/* %s, made from %s\n\
|
||||
by GNU bison %s. */\n\
|
||||
\n",
|
||||
noparserflag ? "Bison-generated parse tables" : "A Bison parser",
|
||||
infile,
|
||||
VERSION);
|
||||
|
||||
fputs ("#define YYBISON 1 /* Identify Bison output. */\n\n", ftable);
|
||||
read_declarations ();
|
||||
/* Start writing the guard and action files, if they are needed. */
|
||||
output_headers ();
|
||||
/* Read in the grammar, build grammar in list form. Write out
|
||||
guards and actions. */
|
||||
readgram ();
|
||||
/* Now we know whether we need the line-number stack. If we do,
|
||||
write its type into the .tab.h file. */
|
||||
if (fdefines)
|
||||
reader_output_yylsp(fdefines);
|
||||
/* write closing delimiters for actions and guards. */
|
||||
output_trailers();
|
||||
reader_output_yylsp (fdefines);
|
||||
/* Write closing delimiters for actions and guards. */
|
||||
output_trailers ();
|
||||
if (yylsp_needed)
|
||||
fprintf(ftable, "#define YYLSP_NEEDED\n\n");
|
||||
/* assign the symbols their symbol numbers.
|
||||
Write #defines for the token symbols into fdefines if requested. */
|
||||
packsymbols();
|
||||
/* convert the grammar into the format described in gram.h. */
|
||||
packgram();
|
||||
/* free the symbol table data structure
|
||||
since symbols are now all referred to by symbol number. */
|
||||
free_symtab();
|
||||
fprintf ("#define YYLSP_NEEDED\n\n", ftable);
|
||||
/* Assign the symbols their symbol numbers. Write #defines for the
|
||||
token symbols into FDEFINES if requested. */
|
||||
packsymbols ();
|
||||
/* Convert the grammar into the format described in gram.h. */
|
||||
packgram ();
|
||||
/* Free the symbol table data structure since symbols are now all
|
||||
referred to by symbol number. */
|
||||
free_symtab ();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user