mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-17 16:23:04 +00:00
Let the handling of the skeleton files be local to the procedures
that use it. * src/files.c (xfopen, xfclose, skeleton_find, guardfile): No longer static. (fparser, open_extra_files): Remove. (open_files, output_files): Don't take care of fparser. * src/files.h: Adjust. * src/output.c (output_parser): Open and close the file to the skeleton. * src/reader.c (read_declarations): When %semantic_parser, open fguard.
This commit is contained in:
15
ChangeLog
15
ChangeLog
@@ -1,3 +1,18 @@
|
|||||||
|
2000-12-19 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
Let the handling of the skeleton files be local to the procedures
|
||||||
|
that use it.
|
||||||
|
|
||||||
|
* src/files.c (xfopen, xfclose, skeleton_find, guardfile): No
|
||||||
|
longer static.
|
||||||
|
(fparser, open_extra_files): Remove.
|
||||||
|
(open_files, output_files): Don't take care of fparser.
|
||||||
|
* src/files.h: Adjust.
|
||||||
|
* src/output.c (output_parser): Open and close the file to the
|
||||||
|
skeleton.
|
||||||
|
* src/reader.c (read_declarations): When %semantic_parser, open
|
||||||
|
fguard.
|
||||||
|
|
||||||
2000-12-19 Akim Demaille <akim@epita.fr>
|
2000-12-19 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* src/file.h (BISON_SIMPLE, BISON_HAIRY): Move from here...
|
* src/file.h (BISON_SIMPLE, BISON_HAIRY): Move from here...
|
||||||
|
|||||||
34
src/files.c
34
src/files.c
@@ -29,7 +29,6 @@
|
|||||||
FILE *finput = NULL;
|
FILE *finput = NULL;
|
||||||
FILE *foutput = NULL;
|
FILE *foutput = NULL;
|
||||||
FILE *fguard = NULL;
|
FILE *fguard = NULL;
|
||||||
FILE *fparser = NULL;
|
|
||||||
|
|
||||||
struct obstack action_obstack;
|
struct obstack action_obstack;
|
||||||
struct obstack attrs_obstack;
|
struct obstack attrs_obstack;
|
||||||
@@ -41,11 +40,11 @@ char *spec_outfile;
|
|||||||
|
|
||||||
char *infile;
|
char *infile;
|
||||||
char *attrsfile;
|
char *attrsfile;
|
||||||
|
char *guardfile;
|
||||||
|
|
||||||
static char *outfile;
|
static char *outfile;
|
||||||
static char *defsfile;
|
static char *defsfile;
|
||||||
static char *tabfile;
|
static char *tabfile;
|
||||||
static char *guardfile;
|
|
||||||
static char *actfile;
|
static char *actfile;
|
||||||
|
|
||||||
/*-----------------------------------------------------------------.
|
/*-----------------------------------------------------------------.
|
||||||
@@ -85,7 +84,7 @@ stringappend (const char *string1, int end1, const char *string2)
|
|||||||
| if fails. |
|
| if fails. |
|
||||||
`-----------------------------------------------------------------*/
|
`-----------------------------------------------------------------*/
|
||||||
|
|
||||||
static FILE *
|
FILE *
|
||||||
xfopen (const char *name, const char *mode)
|
xfopen (const char *name, const char *mode)
|
||||||
{
|
{
|
||||||
FILE *ptr;
|
FILE *ptr;
|
||||||
@@ -101,7 +100,7 @@ xfopen (const char *name, const char *mode)
|
|||||||
| Try to close file PTR, and print an error message if fails. |
|
| Try to close file PTR, and print an error message if fails. |
|
||||||
`-------------------------------------------------------------*/
|
`-------------------------------------------------------------*/
|
||||||
|
|
||||||
static int
|
int
|
||||||
xfclose (FILE *ptr)
|
xfclose (FILE *ptr)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
@@ -130,7 +129,12 @@ obstack_save (struct obstack *obs, const char *filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *
|
/*------------------------------------------------------------------.
|
||||||
|
| Return the path to the skeleton which locaction might be given in |
|
||||||
|
| ENVVAR, otherwise return SKELETON. |
|
||||||
|
`------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
const char *
|
||||||
skeleton_find (const char *envvar, const char *skeleton)
|
skeleton_find (const char *envvar, const char *skeleton)
|
||||||
{
|
{
|
||||||
const char *res = getenv (envvar);
|
const char *res = getenv (envvar);
|
||||||
@@ -221,9 +225,6 @@ open_files (void)
|
|||||||
|
|
||||||
finput = xfopen (infile, "r");
|
finput = xfopen (infile, "r");
|
||||||
|
|
||||||
if (!no_parser_flag)
|
|
||||||
fparser = xfopen (skeleton_find ("BISON_SIMPLE", BISON_SIMPLE), "r");
|
|
||||||
|
|
||||||
if (verbose_flag)
|
if (verbose_flag)
|
||||||
{
|
{
|
||||||
/* We used to use just .out if spec_name_prefix (-p) was used,
|
/* We used to use just .out if spec_name_prefix (-p) was used,
|
||||||
@@ -261,22 +262,6 @@ open_files (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------.
|
|
||||||
| Open the output files needed only for the semantic parser. This |
|
|
||||||
| is done when %semantic_parser is seen in the declarations section. |
|
|
||||||
`--------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
void
|
|
||||||
open_extra_files (void)
|
|
||||||
{
|
|
||||||
xfclose (fparser);
|
|
||||||
|
|
||||||
if (!no_parser_flag)
|
|
||||||
fparser = xfopen (skeleton_find ("BISON_HAIRY", BISON_HAIRY), "r");
|
|
||||||
fguard = xfopen (guardfile, "w");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------.
|
/*-----------------------------------------------------.
|
||||||
| Close the open files, produce all the output files. |
|
| Close the open files, produce all the output files. |
|
||||||
`-----------------------------------------------------*/
|
`-----------------------------------------------------*/
|
||||||
@@ -286,7 +271,6 @@ output_files (void)
|
|||||||
{
|
{
|
||||||
xfclose (fguard);
|
xfclose (fguard);
|
||||||
xfclose (finput);
|
xfclose (finput);
|
||||||
xfclose (fparser);
|
|
||||||
xfclose (foutput);
|
xfclose (foutput);
|
||||||
|
|
||||||
/* Output the main file. */
|
/* Output the main file. */
|
||||||
|
|||||||
14
src/files.h
14
src/files.h
@@ -43,9 +43,6 @@ extern FILE *foutput;
|
|||||||
/* If semantic parser, output yyguard, containing all the guard code. */
|
/* If semantic parser, output yyguard, containing all the guard code. */
|
||||||
extern FILE *fguard;
|
extern FILE *fguard;
|
||||||
|
|
||||||
/* Read the parser to copy into TABLE_OBSTACK. */
|
|
||||||
extern FILE *fparser;
|
|
||||||
|
|
||||||
|
|
||||||
/* Output all the action code; precise form depends on which parser. */
|
/* Output all the action code; precise form depends on which parser. */
|
||||||
extern struct obstack action_obstack;
|
extern struct obstack action_obstack;
|
||||||
@@ -62,16 +59,15 @@ extern struct obstack defines_obstack;
|
|||||||
|
|
||||||
|
|
||||||
extern char *infile;
|
extern char *infile;
|
||||||
extern int lineno;
|
|
||||||
extern char *outfile;
|
|
||||||
extern char *defsfile;
|
|
||||||
extern char *tabfile;
|
|
||||||
extern char *attrsfile;
|
extern char *attrsfile;
|
||||||
extern char *guardfile;
|
extern char *guardfile;
|
||||||
extern char *actfile;
|
|
||||||
|
|
||||||
void open_files PARAMS((void));
|
void open_files PARAMS((void));
|
||||||
void open_extra_files PARAMS((void));
|
|
||||||
|
|
||||||
void output_files PARAMS((void));
|
void output_files PARAMS((void));
|
||||||
|
|
||||||
|
FILE *xfopen PARAMS ((const char *name, const char *mode));
|
||||||
|
int xfclose PARAMS ((FILE *ptr));
|
||||||
|
|
||||||
|
const char *skeleton_find PARAMS ((const char *envvar, const char *skeleton));
|
||||||
#endif /* !FILES_H_ */
|
#endif /* !FILES_H_ */
|
||||||
|
|||||||
36
src/output.c
36
src/output.c
@@ -1153,54 +1153,47 @@ output_actions (void)
|
|||||||
output_check ();
|
output_check ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy the parser code into the ftable file at the end. */
|
/*------------------------------------------.
|
||||||
|
| Copy the parser code into TABLE_OBSTACK. |
|
||||||
|
`------------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
output_parser (void)
|
output_parser (void)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
static int number_of_dollar_signs = 0;
|
static int number_of_dollar_signs = 0;
|
||||||
#ifdef DONTDEF
|
FILE *fskel;
|
||||||
FILE *fpars;
|
|
||||||
#else
|
|
||||||
#define fpars fparser
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (pure_parser)
|
if (pure_parser)
|
||||||
obstack_grow_literal_string (&table_obstack, "#define YYPURE 1\n\n");
|
obstack_grow_literal_string (&table_obstack, "#define YYPURE 1\n\n");
|
||||||
|
|
||||||
#ifdef DONTDEF
|
|
||||||
/* JF no longer needed 'cuz open_extra_files changes the currently
|
|
||||||
open parser from bison.simple to bison.hairy */
|
|
||||||
if (semantic_parser)
|
|
||||||
fpars = fparser;
|
|
||||||
else
|
|
||||||
fpars = fparser1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Loop over lines in the standard parser file. */
|
/* Loop over lines in the standard parser file. */
|
||||||
|
if (semantic_parser)
|
||||||
|
fskel = xfopen (skeleton_find ("BISON_HAIRY", BISON_HAIRY), "r");
|
||||||
|
else
|
||||||
|
fskel = xfopen (skeleton_find ("BISON_SIMPLE", BISON_SIMPLE), "r");
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
int write_line = 1;
|
int write_line = 1;
|
||||||
|
|
||||||
c = getc (fpars);
|
c = getc (fskel);
|
||||||
|
|
||||||
/* See if the line starts with `#line.
|
/* See if the line starts with `#line.
|
||||||
If so, set write_line to 0. */
|
If so, set write_line to 0. */
|
||||||
if (no_lines_flag)
|
if (no_lines_flag)
|
||||||
if (c == '#')
|
if (c == '#')
|
||||||
{
|
{
|
||||||
c = getc (fpars);
|
c = getc (fskel);
|
||||||
if (c == 'l')
|
if (c == 'l')
|
||||||
{
|
{
|
||||||
c = getc (fpars);
|
c = getc (fskel);
|
||||||
if (c == 'i')
|
if (c == 'i')
|
||||||
{
|
{
|
||||||
c = getc (fpars);
|
c = getc (fskel);
|
||||||
if (c == 'n')
|
if (c == 'n')
|
||||||
{
|
{
|
||||||
c = getc (fpars);
|
c = getc (fskel);
|
||||||
if (c == 'e')
|
if (c == 'e')
|
||||||
write_line = 0;
|
write_line = 0;
|
||||||
else
|
else
|
||||||
@@ -1217,7 +1210,7 @@ output_parser (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* now write out the line... */
|
/* now write out the line... */
|
||||||
for (; c != '\n' && c != EOF; c = getc (fpars))
|
for (; c != '\n' && c != EOF; c = getc (fskel))
|
||||||
if (write_line)
|
if (write_line)
|
||||||
{
|
{
|
||||||
/* `$' in the parser file indicates where to put the
|
/* `$' in the parser file indicates where to put the
|
||||||
@@ -1243,6 +1236,7 @@ output_parser (void)
|
|||||||
obstack_1grow (&table_obstack, c);
|
obstack_1grow (&table_obstack, c);
|
||||||
}
|
}
|
||||||
assert (number_of_dollar_signs == 1);
|
assert (number_of_dollar_signs == 1);
|
||||||
|
xfclose (fskel);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -1002,11 +1002,9 @@ read_declarations (void)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SEMANTIC_PARSER:
|
case SEMANTIC_PARSER:
|
||||||
if (semantic_parser == 0)
|
if (!semantic_parser)
|
||||||
{
|
fguard = xfopen (guardfile, "w");
|
||||||
semantic_parser = 1;
|
semantic_parser = 1;
|
||||||
open_extra_files ();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PURE_PARSER:
|
case PURE_PARSER:
|
||||||
|
|||||||
Reference in New Issue
Block a user