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>
+
+ 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>
* src/file.h (BISON_SIMPLE, BISON_HAIRY): Move from here...
FILE *finput = NULL;
FILE *foutput = NULL;
FILE *fguard = NULL;
-FILE *fparser = NULL;
struct obstack action_obstack;
struct obstack attrs_obstack;
char *infile;
char *attrsfile;
+char *guardfile;
static char *outfile;
static char *defsfile;
static char *tabfile;
-static char *guardfile;
static char *actfile;
\f
/*-----------------------------------------------------------------.
| if fails. |
`-----------------------------------------------------------------*/
-static FILE *
+FILE *
xfopen (const char *name, const char *mode)
{
FILE *ptr;
| Try to close file PTR, and print an error message if fails. |
`-------------------------------------------------------------*/
-static int
+int
xfclose (FILE *ptr)
{
int result;
}
-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)
{
const char *res = getenv (envvar);
finput = xfopen (infile, "r");
- if (!no_parser_flag)
- fparser = xfopen (skeleton_find ("BISON_SIMPLE", BISON_SIMPLE), "r");
-
if (verbose_flag)
{
/* We used to use just .out if spec_name_prefix (-p) was used,
-/*--------------------------------------------------------------------.
-| 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. |
`-----------------------------------------------------*/
{
xfclose (fguard);
xfclose (finput);
- xfclose (fparser);
xfclose (foutput);
/* Output the main file. */
/* If semantic parser, output yyguard, containing all the guard code. */
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. */
extern struct obstack action_obstack;
extern char *infile;
-extern int lineno;
-extern char *outfile;
-extern char *defsfile;
-extern char *tabfile;
extern char *attrsfile;
extern char *guardfile;
-extern char *actfile;
void open_files PARAMS((void));
-void open_extra_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_ */
output_check ();
}
-/* copy the parser code into the ftable file at the end. */
+/*------------------------------------------.
+| Copy the parser code into TABLE_OBSTACK. |
+`------------------------------------------*/
static void
output_parser (void)
{
int c;
static int number_of_dollar_signs = 0;
-#ifdef DONTDEF
- FILE *fpars;
-#else
-#define fpars fparser
-#endif
+ FILE *fskel;
if (pure_parser)
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 */
+ /* Loop over lines in the standard parser file. */
if (semantic_parser)
- fpars = fparser;
+ fskel = xfopen (skeleton_find ("BISON_HAIRY", BISON_HAIRY), "r");
else
- fpars = fparser1;
-#endif
-
- /* Loop over lines in the standard parser file. */
+ fskel = xfopen (skeleton_find ("BISON_SIMPLE", BISON_SIMPLE), "r");
while (1)
{
int write_line = 1;
- c = getc (fpars);
+ c = getc (fskel);
/* See if the line starts with `#line.
If so, set write_line to 0. */
if (no_lines_flag)
if (c == '#')
{
- c = getc (fpars);
+ c = getc (fskel);
if (c == 'l')
{
- c = getc (fpars);
+ c = getc (fskel);
if (c == 'i')
{
- c = getc (fpars);
+ c = getc (fskel);
if (c == 'n')
{
- c = getc (fpars);
+ c = getc (fskel);
if (c == 'e')
write_line = 0;
else
}
/* now write out the line... */
- for (; c != '\n' && c != EOF; c = getc (fpars))
+ for (; c != '\n' && c != EOF; c = getc (fskel))
if (write_line)
{
/* `$' in the parser file indicates where to put the
obstack_1grow (&table_obstack, c);
}
assert (number_of_dollar_signs == 1);
+ xfclose (fskel);
}
static void
break;
case SEMANTIC_PARSER:
- if (semantic_parser == 0)
- {
- semantic_parser = 1;
- open_extra_files ();
- }
+ if (!semantic_parser)
+ fguard = xfopen (guardfile, "w");
+ semantic_parser = 1;
break;
case PURE_PARSER: