example::Scanner Class Reference

Scanner is a derived class to add some extra function to the scanner class. More...

#include <scanner.h>

Inheritance diagram for example::Scanner:

ExampleFlexLexer FlexLexer

List of all members.

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.


Detailed Description

Scanner 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 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.


Constructor & Destructor Documentation

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 1910 of file scanner.cc.

example::Scanner::~Scanner (  )  [virtual]

Required for virtual functions.

Definition at line 1916 of file scanner.cc.


Member Function Documentation

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 1920 of file scanner.cc.

References FlexLexer::yy_flex_debug.

Referenced by example::Driver::parse_stream().


The documentation for this class was generated from the following files:

Generated on Thu Oct 23 11:13:54 2008 for Flex Bison C++ Example by  doxygen 1.5.6