%skeleton "lalr1.cc"
%defines
%define variant
+]m4_bpatsubst([$1], [\\n], [
+])[
%code requires // code for the .hh file
{
%%
result:
- list { std::cout << $][1; }
+ list { std::cout << $][1; }
;
list:
switch (stage)
{
case 0:
- yylval->build<std::string>() = std::string("BEGIN");
+ case 4:
+#ifdef ONE_STAGE_BUILD
+ yylval->build(string_cast(stage));
+#else
+ yylval->build<std::string>() = string_cast(stage);
+#endif
result = yy::parser::token::TEXT;
break;
case 1:
case 2:
case 3:
+#ifdef ONE_STAGE_BUILD
+ yylval->build(stage);
+#else
yylval->build<int>() = stage;
+#endif
result = yy::parser::token::NUMBER;
break;
- case 4:
- yylval->build<std::string>() = std::string("END");
- result = yy::parser::token::TEXT;
- break;
default:
result = yy::parser::token::END_OF_FILE;
break;
return result;
}
-// Mandatory error function
void
yy::parser::error(const yy::parser::location_type& yylloc,
const std::string& message)
std::cerr << yylloc << ": " << message << std::endl;
}
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
yy::parser p;
p.set_debug_level(!!getenv("YYDEBUG"));
}
]])
-AT_BISON_CHECK([-o list.cc list.yy], 0)
+AT_BISON_CHECK([-o list.cc list.yy])
AT_COMPILE_CXX([list])
AT_CHECK([./list], 0,
-[BEGIN
+[0
1
2
3
-END
+4
])
AT_CLEANUP
AT_CHECK_VARIANTS([])
AT_CHECK_VARIANTS([%define assert])
+AT_CHECK_VARIANTS([[%define assert %code {\n#define ONE_STAGE_BUILD\n}]])
## ----------------------- ##