]> git.saurik.com Git - bison.git/blobdiff - src/scan-gram.l
Sync with GNU tar.
[bison.git] / src / scan-gram.l
index 02d47e5aeb5ec92f7aacf5a247e0a43083aefdbe..d52984526e661fccb61eb9318f9c2871c0d3f15d 100644 (file)
 #define YY_USER_INIT                           \
 do {                                           \
   LOCATION_RESET (*yylloc);                    \
+  yylloc->file = infile;                       \
    /* This is only to avoid GCC warnings. */   \
   if (yycontrol) {;};                          \
 } while (0)
 
-#define YY_USER_ACTION  LOCATION_COLUMNS (*yylloc, yyleng)
-#define YY_LINES        LOCATION_LINES (*yylloc, yyleng); lineno += yyleng;
-#define YY_STEP         LOCATION_STEP (*yylloc)
-
+#define YY_USER_ACTION  LOCATION_COLUMNS (*yylloc, yyleng);
+#define YY_LINES        LOCATION_LINES (*yylloc, yyleng);
+#define YY_STEP         LOCATION_STEP (*yylloc);
 
 /* STRING_OBSTACK -- Used to store all the characters that we need to
    keep (to construct ID, STRINGS etc.).  Use the following macros to
@@ -90,7 +90,7 @@ static void handle_at PARAMS ((braced_code_t code_kind,
 %x SC_ESCAPED_STRING SC_ESCAPED_CHARACTER
 %x SC_BRACED_CODE SC_PROLOGUE SC_EPILOGUE
 
-id      [.a-zA-Z][.a-zA-Z_0-9]*
+id      [.a-zA-Z_][.a-zA-Z_0-9]*
 int     [0-9]+
 eols     (\n|\r|\n\r|\r\n)+
 blanks   [ \t\f]+
@@ -124,12 +124,15 @@ blanks   [ \t\f]+
   "%define"               return PERCENT_DEFINE;
   "%defines"              return PERCENT_DEFINES;
   "%destructor"           return PERCENT_DESTRUCTOR;
+  "%dprec"               return PERCENT_DPREC;
   "%error"[-_]"verbose"   return PERCENT_ERROR_VERBOSE;
   "%expect"               return PERCENT_EXPECT;
   "%file-prefix"          return PERCENT_FILE_PREFIX;
   "%fixed"[-_]"output"[-_]"files"   return PERCENT_YACC;
+  "%glr"[-_]"parser"     return PERCENT_GLR_PARSER;
   "%left"                 return PERCENT_LEFT;
   "%locations"            return PERCENT_LOCATIONS;
+  "%merge"               return PERCENT_MERGE;
   "%name"[-_]"prefix"     return PERCENT_NAME_PREFIX;
   "%no"[-_]"lines"        return PERCENT_NO_LINES;
   "%nonassoc"             return PERCENT_NONASSOC;
@@ -157,7 +160,7 @@ blanks   [ \t\f]+
   {eols}      YY_LINES; YY_STEP;
   {blanks}    YY_STEP;
   {id}        {
-    yylval->symbol = getsym (yytext, *yylloc);
+    yylval->symbol = symbol_get (yytext, *yylloc);
     return ID;
   }
 
@@ -289,9 +292,10 @@ blanks   [ \t\f]+
     assert (yy_top_state () == INITIAL);
     {
       YY_OBS_FINISH;
-      yylval->symbol = getsym (last_string, *yylloc);
+      yylval->symbol = symbol_get (last_string, *yylloc);
       symbol_class_set (yylval->symbol, token_sym, *yylloc);
-      symbol_user_token_number_set (yylval->symbol, last_string[1], *yylloc);
+      symbol_user_token_number_set (yylval->symbol,
+                                   (unsigned char) last_string[1], *yylloc);
       YY_OBS_FREE;
       yy_pop_state ();
       return ID;
@@ -554,7 +558,7 @@ handle_action_dollar (char *text, location_t location)
        type_name = symbol_list_n_type_name_get (current_rule, location, 0);
       if (!type_name && typed)
        complain_at (location, _("$$ of `%s' has no declared type"),
-                    symbol_tag_get (current_rule->sym));
+                    current_rule->sym->tag);
       if (!type_name)
        type_name = "";
       obstack_fgrow1 (&string_obstack,
@@ -578,7 +582,7 @@ handle_action_dollar (char *text, location_t location)
                                                     n);
          if (!type_name && typed)
            complain_at (location, _("$%d of `%s' has no declared type"),
-                     n, symbol_tag_get (current_rule->sym));
+                     n, current_rule->sym->tag);
          if (!type_name)
            type_name = "";
          obstack_fgrow3 (&string_obstack,
@@ -727,4 +731,6 @@ void
 scanner_free (void)
 {
   obstack_free (&string_obstack, 0);
+  /* Reclaim Flex's buffers.  */
+  yy_delete_buffer (YY_CURRENT_BUFFER);
 }