Main Page | Class Hierarchy | Class List | Directories | File List | Class Members

CxxScanner Class Reference

This wraps the scanner that flex produces. More...

#include <cxxScanner.h>

List of all members.

Public Types

enum  { HSIZE = 128, HMASK = 127 }

Public Member Functions

 CxxScanner (const char *fileName)
 ~CxxScanner ()
Token read (const char *errStr=0)
void pushBack (Token &t)
Token prevToken (int i)

Static Public Member Functions

static const char * filename ()
 current filename.
static int lineNo ()
 current line number (1 based).
static int column (int icol)
 current column (1 based);

Private Attributes

int m_current
 Current indx for m_tokens.
std::vector< Tokenm_tokens
 Current tokens.
int m_stackCnt
 Push back stack counter.
int m_stdin
 True when using standard in as input.
Obstack m_s

Static Private Attributes

static char * mp_fileName
 Current file name.


Detailed Description

This wraps the scanner that flex produces.

Description
This class encapsulates the data that the scanner produces. It has the following features.
  • You can push back one token without going to the Flex push back
  • It keeps track of the input file line numbers.
  • It remembers the previous 128 non-white space tokens
Design Considerations
This class is designed for speed. The read function is written carefully to take advantage of Return Value Optimization. (RVO). The recording of the previous tokens is implemented as a circular buffer for speed. The input line numbers are counted so that if there is a problem then the error can be reported directly to the input line that fails.


Constructor & Destructor Documentation

CxxScanner::CxxScanner const char *  fileName  ) 
 

This ctor opens the input file (or sets yyin to stdin) and sets up the circular buffer and initializes the line counter.

CxxScanner::~CxxScanner  ) 
 

This closes the input file and delete mp_fileName.


Member Function Documentation

Token CxxScanner::prevToken int  i  ) 
 

Extract the i'th previous non space token.

void CxxScanner::pushBack Token t  ) 
 

Save away the current token and move the circular buffer back one if it is not a space.

Token CxxScanner::read const char *  errStr = 0  ) 
 

Description
If there is something on the stack (1 deep) use it. Otherwise ask yylex to get the next token. Then for any non white space token add it to the circular buffer.


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



Project Hosted By:
SourceForge.net Logo