// $Id: Langname_Scanner.hh,v 1.1 2008/04/06 17:10:46 eric Exp $ #ifndef SPARQLScanner_H #define SPARQLScanner_H // Flex expects the signature of yylex to be defined in the macro YY_DECL, and // the C++ parser expects it to be declared. We can factor both as follows. #ifndef YY_DECL #define YY_DECL \ SPARQLNS::SPARQLParser::token_type \ SPARQLNS::SPARQLScanner::lex( \ SPARQLNS::SPARQLParser::semantic_type* yylval, \ SPARQLNS::SPARQLParser::location_type* yylloc \ ) #endif #ifndef __FLEX_LEXER_H #define yyFlexLexer SPARQLFlexLexer #include "FlexLexer.h" #undef yyFlexLexer #endif #include "SPARQLParser.hh" namespace SPARQLNS { /** SPARQLScanner is a derived class to add some extra function to the scanner * class. Flex itself creates a class named yyFlexLexer, which is renamed using * macros to SPARQLFlexLexer. However we change the context of the generated * yylex() function to be contained within the SPARQLScanner class. This is required * because the yylex() defined in SPARQLFlexLexer has no parameters. */ class SPARQLScanner : public SPARQLFlexLexer { public: /** Create a new scanner object. The streams arg_yyin and arg_yyout default * to cin and cout, but that assignment is only made when initializing in * yylex(). */ SPARQLScanner(std::istream* arg_yyin = 0, std::ostream* arg_yyout = 0); /** Required for virtual functions */ virtual ~SPARQLScanner(); /** This is the main lexing function. It is generated by flex according to * the macro declaration YY_DECL above. The generated bison parser then * calls this virtual function to fetch new tokens. */ virtual SPARQLParser::token_type lex( SPARQLParser::semantic_type* yylval, SPARQLParser::location_type* yylloc ); /** Enable debug output (via arg_yyout) if compiled into the scanner. */ void set_debug(bool b); }; } // namespace SPARQLNS #endif // SPARQLScanner_H