[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[FYI] split-prolog.patch
From: |
Robert Anisko |
Subject: |
[FYI] split-prolog.patch |
Date: |
Wed, 24 Apr 2002 18:32:36 +0200 (CEST) |
Index: ChangeLog
===================================================================
RCS file: /cvsroot/bison/bison/ChangeLog,v
retrieving revision 1.643
diff -u -r1.643 ChangeLog
--- ChangeLog 24 Apr 2002 05:56:13 -0000 1.643
+++ ChangeLog 24 Apr 2002 16:21:48 -0000
@@ -1,3 +1,20 @@
+2002-04-24 Robert Anisko <address@hidden>
+
+ * 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 <address@hidden>
* data/bison.simple: Remove unnecessary commentary and white
Index: data/bison.c++
===================================================================
RCS file: /cvsroot/bison/bison/data/bison.c++,v
retrieving revision 1.23
diff -u -r1.23 bison.c++
--- data/bison.c++ 22 Apr 2002 08:22:22 -0000 1.23
+++ data/bison.c++ 24 Apr 2002 16:21:48 -0000
@@ -113,7 +113,8 @@
/* 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)
@@ -136,6 +137,9 @@
yystype;
# define YYSTYPE yystype
#endif
+
+/* Copy the second part of user declarations. */
+b4_post_prologue
#line __oline__ "__ofile__"
#ifndef YYLLOC_DEFAULT
Index: data/bison.simple
===================================================================
RCS file: /cvsroot/bison/bison/data/bison.simple,v
retrieving revision 1.13
diff -u -r1.13 bison.simple
--- data/bison.simple 24 Apr 2002 05:55:48 -0000 1.13
+++ data/bison.simple 24 Apr 2002 16:21:49 -0000
@@ -120,8 +120,8 @@
#endif
])
-/* Copy the user declarations. */
-b4_prologue
+/* Copy the first part of user declarations. */
+b4_pre_prologue
/* Enabling traces. */
#ifndef YYDEBUG
@@ -154,6 +154,9 @@
} yyltype;
# define YYLTYPE b4_ltype
#endif
+
+/* Copy the second part of user declarations. */
+b4_post_prologue
/* Line __line__ of __file__. */
#line __oline__ "__ofile__"
Index: src/files.c
===================================================================
RCS file: /cvsroot/bison/bison/src/files.c,v
retrieving revision 1.70
diff -u -r1.70 files.c
--- src/files.c 21 Jan 2002 15:50:39 -0000 1.70
+++ src/files.c 24 Apr 2002 16:21:49 -0000
@@ -33,8 +33,9 @@
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
Index: src/files.h
===================================================================
RCS file: /cvsroot/bison/bison/src/files.h,v
retrieving revision 1.27
diff -u -r1.27 files.h
--- src/files.h 9 Jan 2002 13:03:45 -0000 1.27
+++ src/files.h 24 Apr 2002 16:21:49 -0000
@@ -50,7 +50,8 @@
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;
Index: src/output.c
===================================================================
RCS file: /cvsroot/bison/bison/src/output.c,v
retrieving revision 1.147
diff -u -r1.147 output.c
--- src/output.c 22 Apr 2002 08:22:39 -0000 1.147
+++ src/output.c 24 Apr 2002 16:21:49 -0000
@@ -1092,8 +1092,10 @@
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 @@
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);
}
Index: src/reader.c
===================================================================
RCS file: /cvsroot/bison/bison/src/reader.c,v
retrieving revision 1.168
diff -u -r1.168 reader.c
--- src/reader.c 22 Apr 2002 08:22:11 -0000 1.168
+++ src/reader.c 24 Apr 2002 16:21:49 -0000
@@ -591,7 +591,7 @@
`-------------------------------------------------------------------*/
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 @@
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 @@
switch (c)
{
case '\n':
- obstack_1grow (&attrs_obstack, c);
+ obstack_1grow (oout, c);
++lineno;
break;
@@ -623,18 +623,18 @@
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 @@
{
if (c == '}')
return;
- obstack_1grow (&attrs_obstack, '%');
+ obstack_1grow (oout, '%');
}
after_percent = 0;
}
@@ -1154,7 +1154,7 @@
/*----------------------------------------------------------------.
| 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 @@
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 @@
/* 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");
Index: tests/calc.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/calc.at,v
retrieving revision 1.19
diff -u -r1.19 calc.at
--- tests/calc.at 9 Apr 2002 19:20:10 -0000 1.19
+++ tests/calc.at 24 Apr 2002 16:21:49 -0000
@@ -61,14 +61,23 @@
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"
@@ -234,6 +243,11 @@
for (/* Niente */; exponent; --exponent)
res *= base;
return res;
+}
+
+void
+id (YYSTYPE* lval)
+{
}
int
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [FYI] split-prolog.patch,
Robert Anisko <=