mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
* tests/calc.at: Exercise prologue splitting.
* data/bison.simple, data/bison.c++: Use `b4_pre_prologue' and `b4_post_prologue' instead of `b4_prologue'. * src/output.c (prepare): Add the `pre_prologue' and `post_prologue' muscles. (output): Free pre_prologue_obstack and post_prologue_obstack. * src/files.h, src/files.c (attrs_obstack): Remove. (pre_prologue_obstack, post_prologue_obstack): New. * src/reader.c (copy_definition): Add a parameter to specify the obstack to fill, instead of using attrs_obstack unconditionally. (read_declarations): Pass pre_prologue_obstack to copy_definition if `%union' has not yet been seen, pass post_prologue_obstack otherwise.
This commit is contained in:
17
ChangeLog
17
ChangeLog
@@ -1,3 +1,20 @@
|
||||
2002-04-24 Robert Anisko <robert@lrde.epita.fr>
|
||||
|
||||
* tests/calc.at: Exercise prologue splitting.
|
||||
|
||||
* data/bison.simple, data/bison.c++: Use `b4_pre_prologue' and
|
||||
`b4_post_prologue' instead of `b4_prologue'.
|
||||
|
||||
* src/output.c (prepare): Add the `pre_prologue' and `post_prologue'
|
||||
muscles.
|
||||
(output): Free pre_prologue_obstack and post_prologue_obstack.
|
||||
* src/files.h, src/files.c (attrs_obstack): Remove.
|
||||
(pre_prologue_obstack, post_prologue_obstack): New.
|
||||
* src/reader.c (copy_definition): Add a parameter to specify the
|
||||
obstack to fill, instead of using attrs_obstack unconditionally.
|
||||
(read_declarations): Pass pre_prologue_obstack to copy_definition if
|
||||
`%union' has not yet been seen, pass post_prologue_obstack otherwise.
|
||||
|
||||
2002-04-23 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* data/bison.simple: Remove unnecessary commentary and white
|
||||
|
||||
@@ -113,7 +113,8 @@ b4_copyright
|
||||
/* Using locations. */
|
||||
#define YYLSP_NEEDED b4_locations_flag
|
||||
|
||||
b4_prologue
|
||||
/* Copy the first part of user declarations. */
|
||||
b4_pre_prologue
|
||||
|
||||
/* Tokens. */
|
||||
b4_token_defines(b4_tokens)
|
||||
@@ -137,6 +138,9 @@ yystype;
|
||||
# define YYSTYPE yystype
|
||||
#endif
|
||||
|
||||
/* Copy the second part of user declarations. */
|
||||
b4_post_prologue
|
||||
|
||||
#line __oline__ "__ofile__"
|
||||
#ifndef YYLLOC_DEFAULT
|
||||
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||
|
||||
@@ -120,8 +120,8 @@ m4_if(b4_prefix[], [yy], [],
|
||||
#endif
|
||||
])
|
||||
|
||||
/* Copy the user declarations. */
|
||||
b4_prologue
|
||||
/* Copy the first part of user declarations. */
|
||||
b4_pre_prologue
|
||||
|
||||
/* Enabling traces. */
|
||||
#ifndef YYDEBUG
|
||||
@@ -155,6 +155,9 @@ typedef struct yyltype
|
||||
# define YYLTYPE b4_ltype
|
||||
#endif
|
||||
|
||||
/* Copy the second part of user declarations. */
|
||||
b4_post_prologue
|
||||
|
||||
/* Line __line__ of __file__. */
|
||||
#line __oline__ "__ofile__"
|
||||
|
||||
|
||||
@@ -33,8 +33,9 @@ const char *base_name PARAMS ((char const *name));
|
||||
FILE *finput = NULL;
|
||||
|
||||
struct obstack action_obstack;
|
||||
struct obstack attrs_obstack;
|
||||
struct obstack output_obstack;
|
||||
struct obstack pre_prologue_obstack;
|
||||
struct obstack post_prologue_obstack;
|
||||
|
||||
/* Initializing some values below (such SPEC_NAME_PREFIX to `yy') is
|
||||
tempting, but don't do that: for the time being our handling of the
|
||||
|
||||
@@ -50,7 +50,8 @@ extern FILE *finput;
|
||||
extern struct obstack action_obstack;
|
||||
|
||||
/* If semantic parser, output a .h file that defines YYSTYPE... */
|
||||
extern struct obstack attrs_obstack;
|
||||
extern struct obstack pre_prologue_obstack;
|
||||
extern struct obstack post_prologue_obstack;
|
||||
|
||||
/* The verbose output. */
|
||||
extern struct obstack output_obstack;
|
||||
|
||||
@@ -1092,8 +1092,10 @@ prepare (void)
|
||||
MUSCLE_INSERT_INT ("defines_flag", defines_flag);
|
||||
|
||||
/* Copy definitions in directive. */
|
||||
obstack_1grow (&attrs_obstack, 0);
|
||||
muscle_insert ("prologue", obstack_finish (&attrs_obstack));
|
||||
obstack_1grow (&pre_prologue_obstack, 0);
|
||||
obstack_1grow (&post_prologue_obstack, 0);
|
||||
muscle_insert ("pre_prologue", obstack_finish (&pre_prologue_obstack));
|
||||
muscle_insert ("post_prologue", obstack_finish (&post_prologue_obstack));
|
||||
|
||||
/* Find the right skeleton file. */
|
||||
if (!skeleton)
|
||||
@@ -1131,5 +1133,6 @@ output (void)
|
||||
obstack_free (&muscle_obstack, NULL);
|
||||
obstack_free (&format_obstack, NULL);
|
||||
obstack_free (&action_obstack, NULL);
|
||||
obstack_free (&attrs_obstack, NULL);
|
||||
obstack_free (&pre_prologue_obstack, NULL);
|
||||
obstack_free (&post_prologue_obstack, NULL);
|
||||
}
|
||||
|
||||
24
src/reader.c
24
src/reader.c
@@ -591,7 +591,7 @@ copy_dollar (FILE *fin, struct obstack *oout,
|
||||
`-------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
copy_definition (void)
|
||||
copy_definition (struct obstack *oout)
|
||||
{
|
||||
int c;
|
||||
/* -1 while reading a character if prev char was %. */
|
||||
@@ -599,7 +599,7 @@ copy_definition (void)
|
||||
|
||||
if (!no_lines_flag)
|
||||
{
|
||||
obstack_fgrow2 (&attrs_obstack, muscle_find ("linef"),
|
||||
obstack_fgrow2 (oout, muscle_find ("linef"),
|
||||
lineno, quotearg_style (c_quoting_style,
|
||||
muscle_find ("filename")));
|
||||
}
|
||||
@@ -613,7 +613,7 @@ copy_definition (void)
|
||||
switch (c)
|
||||
{
|
||||
case '\n':
|
||||
obstack_1grow (&attrs_obstack, c);
|
||||
obstack_1grow (oout, c);
|
||||
++lineno;
|
||||
break;
|
||||
|
||||
@@ -623,18 +623,18 @@ copy_definition (void)
|
||||
|
||||
case '\'':
|
||||
case '"':
|
||||
copy_string (finput, &attrs_obstack, c);
|
||||
copy_string (finput, oout, c);
|
||||
break;
|
||||
|
||||
case '/':
|
||||
copy_comment (finput, &attrs_obstack);
|
||||
copy_comment (finput, oout);
|
||||
break;
|
||||
|
||||
case EOF:
|
||||
fatal ("%s", _("unterminated `%{' definition"));
|
||||
|
||||
default:
|
||||
obstack_1grow (&attrs_obstack, c);
|
||||
obstack_1grow (oout, c);
|
||||
}
|
||||
|
||||
c = getc (finput);
|
||||
@@ -643,7 +643,7 @@ copy_definition (void)
|
||||
{
|
||||
if (c == '}')
|
||||
return;
|
||||
obstack_1grow (&attrs_obstack, '%');
|
||||
obstack_1grow (oout, '%');
|
||||
}
|
||||
after_percent = 0;
|
||||
}
|
||||
@@ -1154,7 +1154,7 @@ parse_skel_decl (void)
|
||||
/*----------------------------------------------------------------.
|
||||
| Read from finput until `%%' is seen. Discard the `%%'. Handle |
|
||||
| any `%' declarations, and copy the contents of any `%{ ... %}' |
|
||||
| groups to ATTRS_OBSTACK. |
|
||||
| groups to PRE_PROLOGUE_OBSTACK or POST_PROLOGUE_OBSTACK. |
|
||||
`----------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
@@ -1174,7 +1174,10 @@ read_declarations (void)
|
||||
return;
|
||||
|
||||
case tok_percent_left_curly:
|
||||
copy_definition ();
|
||||
if (!typed)
|
||||
copy_definition (&pre_prologue_obstack);
|
||||
else
|
||||
copy_definition (&post_prologue_obstack);
|
||||
break;
|
||||
|
||||
case tok_token:
|
||||
@@ -1854,8 +1857,9 @@ reader (void)
|
||||
|
||||
/* Initialize the obstacks. */
|
||||
obstack_init (&action_obstack);
|
||||
obstack_init (&attrs_obstack);
|
||||
obstack_init (&output_obstack);
|
||||
obstack_init (&pre_prologue_obstack);
|
||||
obstack_init (&post_prologue_obstack);
|
||||
|
||||
finput = xfopen (infile, "r");
|
||||
|
||||
|
||||
@@ -61,14 +61,23 @@ static int yygetc (void);
|
||||
static void yyungetc (int c);
|
||||
|
||||
extern void perror (const char *s);
|
||||
|
||||
/* Exercise pre-prologue dependency to %union. */
|
||||
typedef int value_t;
|
||||
|
||||
%}
|
||||
|
||||
/* Also exercise %union. */
|
||||
%union
|
||||
{
|
||||
int ival; /* A comment to exercise an old bug. */
|
||||
value_t ival; /* A comment to exercise an old bug. */
|
||||
};
|
||||
|
||||
/* Exercise post-prologue dependency to %union. */
|
||||
%{
|
||||
static void id (YYSTYPE *lval);
|
||||
%}
|
||||
|
||||
/* Bison Declarations */
|
||||
%token CALC_EOF 0 "end of file"
|
||||
%token <ival> NUM "number"
|
||||
@@ -236,6 +245,11 @@ power (int base, int exponent)
|
||||
return res;
|
||||
}
|
||||
|
||||
void
|
||||
id (YYSTYPE* lval)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, const char **argv)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user