]> git.saurik.com Git - bison.git/blobdiff - src/lex.c
* tests/sets.at (Broken Closure): Add the ending `;'.
[bison.git] / src / lex.c
index deb6eb7af47374fd303b83ac865b2c7fdb059d4f..5b77f2485513fe19d7ad6279199e01f81de51f41 100644 (file)
--- a/src/lex.c
+++ b/src/lex.c
@@ -482,43 +482,50 @@ parse_percent_token (void)
   size_t arg_offset = 0;
 
   int c = getc (finput);
+  obstack_1grow (&token_obstack, '%');
+  obstack_1grow (&token_obstack, c);
 
-  switch (c)
+  if (!isalpha (c))
     {
-    case '%':
-      return tok_two_percents;
+      obstack_1grow (&token_obstack, '\0');
+      token_buffer = obstack_finish (&token_obstack);
 
-    case '{':
-      return tok_percent_left_curly;
+      switch (c)
+       {
+       case '%':
+         return tok_two_percents;
 
-      /* FIXME: Who the heck are those 5 guys!?! `%<' = `%left'!!!
-        Let's ask for there removal.  */
-    case '<':
-      return tok_left;
+       case '{':
+         return tok_percent_left_curly;
 
-    case '>':
-      return tok_right;
+         /* The following guys are here for backward compatibility with
+            very ancient Yacc versions.  The paper of Johnson mentions
+            them (as ancient :).  */
+       case '<':
+         return tok_left;
 
-    case '2':
-      return tok_nonassoc;
+       case '>':
+         return tok_right;
 
-    case '0':
-      return tok_token;
+       case '2':
+         return tok_nonassoc;
 
-    case '=':
-      return tok_prec;
-    }
+       case '0':
+         return tok_token;
 
-  if (!isalpha (c))
-    return tok_illegal;
+       case '=':
+         return tok_prec;
 
-  obstack_1grow (&token_obstack, '%');
-  while (isalpha (c) || c == '_' || c == '-')
+       default:
+         return tok_illegal;
+       }
+    }
+
+  while (c = getc (finput), isalpha (c) || c == '_' || c == '-')
     {
       if (c == '_')
        c = '-';
       obstack_1grow (&token_obstack, c);
-      c = getc (finput);
     }
 
   /* %DIRECTIVE="ARG".  Separate into