bison-patches
[Top][All Lists]
Advanced

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

03-yy-obs-init.patch


From: Akim Demaille
Subject: 03-yy-obs-init.patch
Date: Tue, 11 Jun 2002 23:40:46 +0200

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        * src/scan-gram.l (YY_OBS_INIT): Remove, replace with...
        [SC_COMMENT,SC_STRING,SC_CHARACTER,SC_BRACED_CODE,SC_PROLOGUE]
        [SC_EPILOGUE]: Output the quadrigraphs only when not in a comment.
        * src/reader.h, src/scan-gram.l (scanner_initialize): this.
        * src/reader.c (reader): Use it.
        
        
Index: src/scan-gram.l
--- src/scan-gram.l Tue, 11 Jun 2002 23:19:19 +0200 akim
+++ src/scan-gram.l Tue, 11 Jun 2002 23:35:59 +0200 akim
@@ -40,18 +40,14 @@
    keep (to construct ID, STRINGS etc.).  Use the following macros to
    use it.
 
-   Use YY_OBS_INIT to initialize a new growing string, YY_OBS_GROW to
-   append what has just been matched, and YY_OBS_FINISH to end the
-   string (it puts the ending 0).  YY_OBS_FINISH also stores this
-   string in LAST_STRING, which can be used, and which is used by
-   YY_OBS_FREE to free the last string.  */
+   Use YY_OBS_GROW to append what has just been matched, and
+   YY_OBS_FINISH to end the string (it puts the ending 0).
+   YY_OBS_FINISH also stores this string in LAST_STRING, which can be
+   used, and which is used by YY_OBS_FREE to free the last string.  */
 
 static struct obstack string_obstack;
 char *last_string;
 
-#define YY_OBS_INIT   \
-  obstack_init (&string_obstack)
-
 #define YY_OBS_GROW   \
   obstack_grow (&string_obstack, yytext, yyleng)
 
@@ -161,24 +157,23 @@
   {int}       yylval->integer = strtol (yytext, 0, 10); return INT;
 
   /* Characters.  We don't check there is only one.  */
-  \'          YY_OBS_INIT; YY_OBS_GROW; yy_push_state (SC_ESCAPED_CHARACTER);
+  \'          YY_OBS_GROW; yy_push_state (SC_ESCAPED_CHARACTER);
 
   /* Strings. */
-  \"          YY_OBS_INIT; YY_OBS_GROW; yy_push_state (SC_ESCAPED_STRING);
+  \"          YY_OBS_GROW; yy_push_state (SC_ESCAPED_STRING);
 
   /* Comments. */
   "/*"        yy_push_state (SC_COMMENT);
   "//".*      YY_STEP;
 
   /* Prologue. */
-  "%{"        YY_OBS_INIT; yy_push_state (SC_PROLOGUE);
+  "%{"        yy_push_state (SC_PROLOGUE);
 
   /* Code in between braces.  */
-  "{"         YY_OBS_INIT; YY_OBS_GROW; ++braces_level; yy_push_state 
(SC_BRACED_CODE);
+  "{"         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;
     yylval->string = last_string;
@@ -208,8 +203,8 @@
 
 <SC_COMMENT,SC_STRING,SC_CHARACTER,SC_BRACED_CODE,SC_PROLOGUE,SC_EPILOGUE>
 {
-  \[          obstack_sgrow (&string_obstack, "@<:@");
-  \]          obstack_sgrow (&string_obstack, "@:>@");
+  \[          if (YY_START != SC_COMMENT) obstack_sgrow (&string_obstack, 
"@<:@");
+  \]          if (YY_START != SC_COMMENT) obstack_sgrow (&string_obstack, 
"@:>@");
 }
 
 
@@ -626,6 +621,13 @@
       complain (_("%s is invalid"), quote (buf));
     }
 }
+
+void
+scanner_initialize (void)
+{
+  obstack_init (&string_obstack);
+}
+
 
 void
 scanner_free (void)
Index: src/reader.c
--- src/reader.c Tue, 11 Jun 2002 21:16:20 +0200 akim
+++ src/reader.c Tue, 11 Jun 2002 23:26:36 +0200 akim
@@ -481,6 +481,7 @@
 
   gram_debug = !!getenv ("parse");
   gram__flex_debug = !!getenv ("scan");
+  scanner_initialize ();
   gram_parse (&gram_control);
 
   /* Grammar has been read.  Do some checking */
Index: src/reader.h
--- src/reader.h Tue, 11 Jun 2002 23:19:19 +0200 akim
+++ src/reader.h Tue, 11 Jun 2002 23:26:20 +0200 akim
@@ -79,6 +79,7 @@
 extern FILE *gram_in;
 extern int gram__flex_debug;
 void scanner_last_string_free PARAMS ((void));
+void scanner_initialize PARAMS ((void));
 void scanner_free PARAMS ((void));
 
 # define YY_DECL \



reply via email to

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