bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02-yy-obs-finish.patch


From: Akim Demaille
Subject: 02-yy-obs-finish.patch
Date: Tue, 11 Jun 2002 23:40:41 +0200

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        * src/scan-gram.l (YY_OBS_FINISH): Don't set yylval.
        Adjust all callers.
        (scanner_last_string_free): New.
        
        
Index: src/parse-gram.y
--- src/parse-gram.y Tue, 11 Jun 2002 21:16:20 +0200 akim
+++ src/parse-gram.y Tue, 11 Jun 2002 23:11:33 +0200 akim
@@ -120,7 +120,8 @@
 %token PROLOGUE EPILOGUE
 %token BRACED_CODE
 
-%type <string> CHARACTER TYPE BRACED_CODE PROLOGUE EPILOGUE epilogue.opt 
action STRING string_content
+%type <string> CHARACTER TYPE  STRING string_content
+               BRACED_CODE PROLOGUE EPILOGUE epilogue.opt action
 %type <integer> INT
 %type <symbol> ID symbol string_as_id
 %type <assoc> precedence_directive
@@ -140,7 +141,10 @@ directives:
 
 directive:
   grammar_directives
-| PROLOGUE                                 { prologue_augment ($1, 
@1.first_line); }
+| PROLOGUE
+   {
+     prologue_augment ($1, @1.first_line);
+   }
 | "%debug"                                 { debug_flag = 1; }
 | "%define" string_content string_content  { muscle_insert ($2, $3); }
 | "%defines"                               { defines_flag = 1; }
Index: src/scan-gram.l
--- src/scan-gram.l Tue, 11 Jun 2002 22:48:21 +0200 akim
+++ src/scan-gram.l Tue, 11 Jun 2002 23:17:00 +0200 akim
@@ -59,7 +59,6 @@
   do {                                                 \
     obstack_1grow (&string_obstack, '\0');             \
     last_string = obstack_finish (&string_obstack);    \
-    yylval->string = last_string;                      \
   } while (0)
 
 #define YY_OBS_FREE                                            \
@@ -67,6 +66,13 @@
     obstack_free (&string_obstack, last_string);               \
   } while (0)
 
+void
+scanner_last_string_free (void)
+{
+  YY_OBS_FREE;
+}
+
+
 /* This is only to avoid GCC warnings. */
 #define YY_USER_INIT    if (yycontrol) {;};
 
@@ -148,9 +154,7 @@
   {eols}      YY_LINES; YY_STEP;
   {blanks}    YY_STEP;
   {id}        {
-    YY_OBS_INIT; YY_OBS_GROW; YY_OBS_FINISH;
-    yylval->symbol = getsym (last_string);
-    YY_OBS_FREE;
+    yylval->symbol = getsym (yytext);
     return ID;
   }
 
@@ -173,7 +177,14 @@
   "{"         YY_OBS_INIT; YY_OBS_GROW; ++braces_level; yy_push_state 
(SC_BRACED_CODE);
 
   /* A type. */
-  "<"[^>]+">" YY_OBS_INIT; obstack_grow (&string_obstack, yytext + 1, yyleng - 
2); YY_OBS_FINISH; return TYPE;
+  "<"[^>]+">" {
+    YY_OBS_INIT;
+    obstack_grow (&string_obstack, yytext + 1, yyleng - 2);
+    YY_OBS_FINISH;
+    yylval->string = last_string;
+    return TYPE;
+  }
+
 
   "%%"   {
     if (++percent_percent_count == 2)
@@ -244,6 +255,7 @@
     assert (yy_top_state () == INITIAL);
     YY_OBS_GROW;
     YY_OBS_FINISH;
+    yylval->string = last_string;
     yy_pop_state ();
     return STRING;
   }
@@ -257,6 +269,7 @@
     fprintf (stderr, ": unexpected end of file in a string\n");
     assert (yy_top_state () == INITIAL);
     YY_OBS_FINISH;
+    yylval->string = last_string;
     yy_pop_state ();
     return STRING;
   }
@@ -292,6 +305,7 @@
     fprintf (stderr, ": unexpected end of file in a character\n");
     assert (yy_top_state () == INITIAL);
     YY_OBS_FINISH;
+    yylval->string = last_string;
     yy_pop_state ();
     return CHARACTER;
   }
@@ -421,6 +435,7 @@
       {
        yy_pop_state ();
        YY_OBS_FINISH;
+       yylval->string = last_string;
        return BRACED_CODE;
       }
   }
@@ -441,7 +456,8 @@
     fprintf (stderr, ": unexpected end of file in a braced code\n");
     yy_pop_state ();
     YY_OBS_FINISH;
-    return PROLOGUE;
+    yylval->string = last_string;
+    return BRACED_CODE;
   }
 
 }
@@ -456,6 +472,7 @@
   "%}" {
     yy_pop_state ();
     YY_OBS_FINISH;
+    yylval->string = last_string;
     return PROLOGUE;
   }
 
@@ -468,6 +485,7 @@
     fprintf (stderr, ": unexpected end of file in a prologue\n");
     yy_pop_state ();
     YY_OBS_FINISH;
+    yylval->string = last_string;
     return PROLOGUE;
   }
 
@@ -486,6 +504,7 @@
   <<EOF>> {
     yy_pop_state ();
     YY_OBS_FINISH;
+    yylval->string = last_string;
     return EPILOGUE;
   }
 }
@@ -606,4 +625,10 @@
       buf[1] = *cp;
       complain (_("%s is invalid"), quote (buf));
     }
+}
+
+void
+scanner_free (void)
+{
+  obstack_free (&string_obstack, 0);
 }
Index: src/reader.h
--- src/reader.h Tue, 11 Jun 2002 20:25:48 +0200 akim
+++ src/reader.h Tue, 11 Jun 2002 22:59:19 +0200 akim
@@ -78,6 +78,8 @@
 /* From the scanner.  */
 extern FILE *gram_in;
 extern int gram__flex_debug;
+void scanner_last_string_free PARAMS ((void));
+void scanner_free PARAMS ((void));
 
 # define YY_DECL \
   int gram_lex (yystype *yylval, yyltype *yylloc, \



reply via email to

[Prev in Thread] Current Thread [Next in Thread]