%skeleton "lalr1.cc" %require "3.0" %defines %define api.value.type variant %define api.parser.class { parser } %define api.namespace { yy } %define api.token.prefix {TOK_} %code requires { #include } %code { #include int scanner_lex(yy::parser::semantic_type* yylval); #undef yylex #define yylex scanner_lex } %token WORD %token NUMBER %token CHAR %% input: /* empty */ | input element ; element: WORD { std::cout << "WORD: " << $1 << "\n"; } | NUMBER { std::cout << "NUMBER\n"; } | CHAR { std::cout << "CHAR\n"; } ; %% namespace yy { void parser::error(const std::string& msg) { std::cerr << "Error: " << msg << "\n"; } }