/** * @file * @brief definitions of ExampleFlexLexer and example::Lexer. * @since 2011-05-11 */ #ifndef LEXER_H #define LEXER_H // require semantic_type & location_type #include "generated/parser.hpp" // class ExampleFlexLexer #ifndef __FLEX_LEXER_H #define yyFlexLexer ExampleFlexLexer #include #undef yyFlexLexer #endif namespace example { class Lexer : private ExampleFlexLexer { int error_count; public: Lexer(std::istream *arg_yyin = 0, std::ostream *arg_yyout = 0) : ExampleFlexLexer(arg_yyin, arg_yyout) , error_count(0) {} #define EXAMPLE_LEXER_LEXFUN(SCOPE)\ example::Parser::token_type SCOPE lex(\ example::Parser::semantic_type* yylval,\ example::Parser::location_type* yylloc\ ) EXAMPLE_LEXER_LEXFUN(); // implemented in generated/lexer.cpp (YY_DECL) #define EXAMPLE_LEXER_YY_DECL EXAMPLE_LEXER_LEXFUN(example::Lexer::) int lexerror(const example::position &pos, const std::string &msg); int lexerror() const { return error_count;} }; } #endif