#include <scanner.h>
Public Member Functions | |
Scanner (std::istream *arg_yyin=0, std::ostream *arg_yyout=0) | |
Create a new scanner object. | |
virtual | ~Scanner () |
Required for virtual functions. | |
virtual Parser::token_type | lex (Parser::semantic_type *yylval, Parser::location_type *yylloc) |
This is the main lexing function. | |
void | set_debug (bool b) |
Enable debug output (via arg_yyout) if compiled into the scanner. |
Flex itself creates a class named yyFlexLexer, which is renamed using macros to ExampleFlexLexer. However we change the context of the generated yylex() function to be contained within the Scanner class. This is required because the yylex() defined in ExampleFlexLexer has no parameters.
Definition at line 34 of file scanner.h.
example::Scanner::Scanner | ( | std::istream * | arg_yyin = 0 , |
|
std::ostream * | arg_yyout = 0 | |||
) |
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().
Definition at line 1897 of file scanner.cc.
example::Scanner::~Scanner | ( | ) | [virtual] |
virtual Parser::token_type example::Scanner::lex | ( | Parser::semantic_type * | yylval, | |
Parser::location_type * | yylloc | |||
) | [virtual] |
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.
void example::Scanner::set_debug | ( | bool | b | ) |
Enable debug output (via arg_yyout) if compiled into the scanner.
Definition at line 1907 of file scanner.cc.
References FlexLexer::yy_flex_debug.
Referenced by example::Driver::parse_stream().