summaryrefslogtreecommitdiff
path: root/etc/bench.pl.in
diff options
context:
space:
mode:
authorAkim Demaille <akim@betelgeuse.gostai.ensta.fr>2008-10-10 16:56:00 +0200
committerAkim Demaille <demaille@gostai.com>2008-11-15 14:17:15 +0100
commit4fc55348e59ab81573d188c8fd529ed9faf81444 (patch)
treecc3b00f81fc5bd16e460e36542627527552a1a36 /etc/bench.pl.in
parent070e650956e18ab54d949028dd2d0ba47391e1b9 (diff)
downloadbison-4fc55348e59ab81573d188c8fd529ed9faf81444.tar.gz
Simplify code for variants bench marks.
* etc/bench.pl.in (&generate_grammar_list): Define and use location_type. Factor the common code in yylex.
Diffstat (limited to 'etc/bench.pl.in')
-rwxr-xr-xetc/bench.pl.in31
1 files changed, 14 insertions, 17 deletions
diff --git a/etc/bench.pl.in b/etc/bench.pl.in
index 7cab2ebe..a95e646b 100755
--- a/etc/bench.pl.in
+++ b/etc/bench.pl.in
@@ -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
}