]> git.saurik.com Git - bison.git/commitdiff
Simplify code for variants bench marks.
authorAkim Demaille <akim@betelgeuse.gostai.ensta.fr>
Fri, 10 Oct 2008 14:56:00 +0000 (16:56 +0200)
committerAkim Demaille <demaille@gostai.com>
Sat, 15 Nov 2008 13:17:15 +0000 (14:17 +0100)
* etc/bench.pl.in (&generate_grammar_list): Define and use
location_type.
Factor the common code in yylex.

ChangeLog
etc/bench.pl.in

index 6364361c1429d4fee9c13b49f9e29a50e4bf8dc5..3b8e4c4b02d371a9daa5dfaf3e8271f3b94f5d03 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-11-15  Akim Demaille  <akim@betelgeuse.gostai.ensta.fr>
+
+       Simplify code for variants bench marks.
+       * etc/bench.pl.in (&generate_grammar_list): Define and use
+       location_type.
+       Factor the common code in yylex.
+
 2008-11-15  Akim Demaille  <demaille@gostai.com>
 
        Better error message.
index 7cab2ebec0381347c4cd3a8a131d5c20591fd82b..a95e646b56a62ac4e6ccb8bdab8d58a63efeec36 100755 (executable)
@@ -686,6 +686,7 @@ yy::parser::token_type yylex(yy::parser::semantic_type* yylval,
                              yy::parser::location_type* yylloc)
 #endif
 {
+  typedef yy::parser::location_type location_type;
   typedef yy::parser::token token;
   static int stage = -1;
   ++stage;
@@ -694,7 +695,7 @@ yy::parser::token_type yylex(yy::parser::semantic_type* yylval,
 #if USE_LEX_SYMBOL
       return yy::parser::make_END_OF_FILE (yy::location());
 #else
-      *yylloc = yy::location ();
+      *yylloc = location_type ();
       return token::END_OF_FILE;
 #endif
     }
@@ -702,17 +703,15 @@ yy::parser::token_type yylex(yy::parser::semantic_type* yylval,
     {
 #if USE_LEX_SYMBOL
       return yy::parser::make_NUMBER (stage, yy::location());
-#elif defined ONE_STAGE_BUILD
+#else
+# if defined ONE_STAGE_BUILD
       yylval->build(stage);
-      *yylloc = yy::location ();
-      return token::NUMBER;
-#elif USE_VARIANTS
+# elif USE_VARIANTS
       yylval->build<int>() = stage;
-      *yylloc = yy::location ();
-      return token::NUMBER;
-#else
+# else
       yylval->ival = stage;
-      *yylloc = yy::location ();
+# endif
+      *yylloc = location_type ();
       return token::NUMBER;
 #endif
     }
@@ -720,17 +719,15 @@ yy::parser::token_type yylex(yy::parser::semantic_type* yylval,
     {
 #if USE_LEX_SYMBOL
       return yy::parser::make_TEXT ("A string.", yy::location());
-#elif defined ONE_STAGE_BUILD
+#else
+# if defined ONE_STAGE_BUILD
       yylval->build(std::string("A string."));
-      *yylloc = yy::location ();
-      return token::TEXT;
-#elif USE_VARIANTS
+# elif USE_VARIANTS
       yylval->build<std::string>() = std::string("A string.");
-      *yylloc = yy::location ();
-      return token::TEXT;
-#else
+# else
       yylval->sval = new std::string("A string.");
-      *yylloc = yy::location ();
+# endif
+      *yylloc = location_type ();
       return token::TEXT;
 #endif
     }