[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 04-scanner-epilogue.patch
From: |
Akim Demaille |
Subject: |
Re: 04-scanner-epilogue.patch |
Date: |
12 Nov 2002 09:26:23 +0100 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter) |
I'm installing this modified version of the patch.
Index: ChangeLog
from Akim Demaille <address@hidden>
* src/scan-gram.l, src/reader.h (scanner_last_string_free):
Restore.
* src/scan-gram.l (last_string): Is global to the file, not to
yylex.
* src/parse-gram.y (input): Don't append the epilogue here,
(epilogue.opt): do it here, and free the scanner's obstack.
* src/reader.c (epilogue_set): Rename as...
(epilogue_augment): this.
* data/c.m4 (b4_epilogue): Defaults to empty.
Index: data/c.m4
===================================================================
RCS file: /cvsroot/bison/bison/data/c.m4,v
retrieving revision 1.16
diff -u -u -r1.16 c.m4
--- data/c.m4 12 Nov 2002 07:15:59 -0000 1.16
+++ data/c.m4 12 Nov 2002 08:23:50 -0000
@@ -65,6 +65,14 @@
+## ---------------- ##
+## Default values. ##
+## ---------------- ##
+
+m4_define_default([b4_epilogue], [])
+
+
+
## ------------------------ ##
## Pure/impure interfaces. ##
## ------------------------ ##
Index: src/parse-gram.y
===================================================================
RCS file: /cvsroot/bison/bison/src/parse-gram.y,v
retrieving revision 1.27
diff -u -u -r1.27 parse-gram.y
--- src/parse-gram.y 12 Nov 2002 08:05:59 -0000 1.27
+++ src/parse-gram.y 12 Nov 2002 08:23:50 -0000
@@ -158,7 +158,8 @@
%type <string> STRING string_content
- BRACED_CODE PROLOGUE EPILOGUE epilogue.opt action
+ BRACED_CODE action
+ PROLOGUE EPILOGUE
%type <struniq> TYPE
%type <integer> INT
%type <symbol> ID symbol string_as_id
@@ -170,7 +171,6 @@
declarations "%%" grammar epilogue.opt
{
yycontrol->errcode = 0;
- epilogue_set ($4, @4);
}
;
@@ -418,12 +418,10 @@
epilogue.opt:
/* Nothing. */
- {
- $$ = xstrdup ("");
- }
| "%%" EPILOGUE
{
- $$ = $2;
+ epilogue_augment ($2, @2);
+ scanner_last_string_free ();
}
;
@@ -463,6 +461,10 @@
case PROLOGUE:
case EPILOGUE:
fprintf (file, " = {{ %s }}", value->string);
+ break;
+
+ default:
+ fprintf (file, "unknown token type");
break;
}
}
Index: src/reader.c
===================================================================
RCS file: /cvsroot/bison/bison/src/reader.c,v
retrieving revision 1.221
diff -u -u -r1.221 reader.c
--- src/reader.c 12 Nov 2002 08:05:59 -0000 1.221
+++ src/reader.c 12 Nov 2002 08:23:50 -0000
@@ -84,8 +84,9 @@
`----------------------*/
void
-epilogue_set (const char *epilogue, location_t location)
+epilogue_augment (const char *epilogue, location_t location)
{
+ char *extension = NULL;
obstack_fgrow1 (&muscle_obstack, "]b4_syncline([[%d]], [[",
location.first_line);
MUSCLE_OBSTACK_SGROW (&muscle_obstack,
@@ -93,7 +94,9 @@
obstack_sgrow (&muscle_obstack, "]])[\n");
obstack_sgrow (&muscle_obstack, epilogue);
obstack_1grow (&muscle_obstack, 0);
- muscle_insert ("epilogue", obstack_finish (&muscle_obstack));
+ extension = obstack_finish (&muscle_obstack);
+ muscle_grow ("epilogue", extension, "");
+ obstack_free (&muscle_obstack, extension);
}
Index: src/reader.h
===================================================================
RCS file: /cvsroot/bison/bison/src/reader.h,v
retrieving revision 1.30
diff -u -u -r1.30 reader.h
--- src/reader.h 12 Nov 2002 08:05:59 -0000 1.30
+++ src/reader.h 12 Nov 2002 08:23:50 -0000
@@ -42,6 +42,7 @@
extern int gram__flex_debug;
void scanner_initialize (void);
void scanner_free (void);
+void scanner_last_string_free (void);
# define YY_DECL \
int gram_lex (yystype *yylval, location_t *yylloc, \
@@ -69,7 +70,7 @@
/* From reader.c. */
void grammar_start_symbol_set (symbol_t *s, location_t l);
void prologue_augment (const char *prologue, location_t location);
-void epilogue_set (const char *epilogue, location_t location);
+void epilogue_augment (const char *epilogue, location_t location);
void grammar_symbol_append (symbol_t *s, location_t l);
void grammar_rule_begin (symbol_t *lhs, location_t l);
void grammar_rule_end (location_t l);
Index: src/scan-gram.l
===================================================================
RCS file: /cvsroot/bison/bison/src/scan-gram.l,v
retrieving revision 1.41
diff -u -u -r1.41 scan-gram.l
--- src/scan-gram.l 12 Nov 2002 08:05:59 -0000 1.41
+++ src/scan-gram.l 12 Nov 2002 08:23:50 -0000
@@ -142,6 +142,10 @@
static struct obstack string_obstack;
+/* A string representing the most recently saved token. */
+static char *last_string;
+
+
#define YY_OBS_GROW \
obstack_grow (&string_obstack, yytext, yyleng)
@@ -154,6 +158,11 @@
#define YY_OBS_FREE \
obstack_free (&string_obstack, last_string)
+void
+scanner_last_string_free (void)
+{
+ YY_OBS_FREE;
+}
/* Within well-formed rules, RULE_LENGTH is the number of values in
the current rule so far, which says where to find `$0' with respect
@@ -198,9 +207,6 @@
/* Scanner context when scanning C code. */
int c_context IF_LINT (= 0);
-
- /* A string representing the most recently saved token. */
- char *last_string;
/* At each yylex invocation, mark the current position as the
start of the next token. */