torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
torc::generic::Scanner Class Reference

#include <Scanner.hpp>

+ Inheritance diagram for torc::generic::Scanner:
+ Collaboration diagram for torc::generic::Scanner:

Public Member Functions

 Scanner (std::istream *arg_yyin=0, std::ostream *arg_yyout=0)
 
virtual ~Scanner ()
 
virtual Parser::token_type lex (Parser::semantic_type *yylval, Parser::location_type *yylloc)
 
void set_debug (bool b)
 
bool getIsIdContext () const
 
void setIsIdContext (bool inIsIdContext)
 
void skipThisRule (char *yytext)
 
bool getAppendToBuffer ()
 
void setAppendToBuffer (bool inAppendToBuffer)
 
void resetBuffer ()
 
void addToBuffer (const char *str)
 
std::string getBuffer ()
 
bool getAppendToUserDataBuffer ()
 
void setAppendToUserDataBuffer (bool inAppendToBuffer)
 
void addToUserDataBuffer (const char *str)
 
void resetUserDataBuffer ()
 
std::string getUserDataBuffer ()
 

Private Attributes

bool mIsIdContext
 
bool mAppendToBuffer
 
bool mAppendToUserDataBuffer
 
std::string mBuffer
 
std::string mUserDataBuffer
 
bool mIsIdAlreadyAdded
 

Detailed Description

Scanner is a derived class to add some extra function to the scanner class. Flex itself creates a class named FlexLexer, which is renamed using macros to EdifFlexLexer. 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 EdifFlexLexer has no parameters.

Definition at line 55 of file Scanner.hpp.

Constructor & Destructor Documentation

torc::generic::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 7042 of file Scanner.cc.

7044 : EdifFlexLexer(in, out),
7045  mIsIdContext(false),
7046  mAppendToBuffer(false),
7047  mAppendToUserDataBuffer(false),
7048  mBuffer(),
7049  mUserDataBuffer(),
7050  mIsIdAlreadyAdded(false)
7051 {}
std::string mBuffer
Definition: Scanner.hpp:103
std::string mUserDataBuffer
Definition: Scanner.hpp:104
torc::generic::Scanner::~Scanner ( )
virtual

Required for virtual functions

Definition at line 7053 of file Scanner.cc.

7054 {}

Member Function Documentation

void torc::generic::Scanner::addToBuffer ( const char *  str)

Definition at line 7108 of file Scanner.cc.

7108  {
7109  if(getAppendToBuffer())
7110  {
7111  mBuffer += str;
7112  }
7113 }
std::string mBuffer
Definition: Scanner.hpp:103

+ Here is the call graph for this function:

void torc::generic::Scanner::addToUserDataBuffer ( const char *  str)

Definition at line 7116 of file Scanner.cc.

7116  {
7117  if(getAppendToUserDataBuffer() && (mIsIdAlreadyAdded == false))
7118  {
7119  mUserDataBuffer += str;
7120  }
7121  mIsIdAlreadyAdded = false;
7122 }
std::string mUserDataBuffer
Definition: Scanner.hpp:104
bool getAppendToUserDataBuffer()
Definition: Scanner.hpp:124

+ Here is the call graph for this function:

bool torc::generic::Scanner::getAppendToBuffer ( )
inline

Definition at line 116 of file Scanner.hpp.

116  {
117  return mAppendToBuffer;
118 }

+ Here is the caller graph for this function:

bool torc::generic::Scanner::getAppendToUserDataBuffer ( )
inline

Definition at line 124 of file Scanner.hpp.

124  {
126 }

+ Here is the caller graph for this function:

std::string torc::generic::Scanner::getBuffer ( )
inline

Definition at line 120 of file Scanner.hpp.

120  {
121  return mBuffer;
122 }
std::string mBuffer
Definition: Scanner.hpp:103

+ Here is the caller graph for this function:

bool torc::generic::Scanner::getIsIdContext ( ) const
inline

Definition at line 108 of file Scanner.hpp.

108  {
109  return mIsIdContext;
110 }
std::string torc::generic::Scanner::getUserDataBuffer ( )
inline

Definition at line 128 of file Scanner.hpp.

128  {
129  return mUserDataBuffer;
130 }
std::string mUserDataBuffer
Definition: Scanner.hpp:104

+ Here is the caller graph for this function:

virtual Parser::token_type torc::generic::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 torc::generic::Scanner::resetBuffer ( )

Definition at line 7093 of file Scanner.cc.

7093  {
7094  mBuffer = "";
7095 }
std::string mBuffer
Definition: Scanner.hpp:103

+ Here is the caller graph for this function:

void torc::generic::Scanner::resetUserDataBuffer ( )

Definition at line 7103 of file Scanner.cc.

7103  {
7104  mUserDataBuffer = "";
7105 }
std::string mUserDataBuffer
Definition: Scanner.hpp:104

+ Here is the caller graph for this function:

void torc::generic::Scanner::set_debug ( bool  b)

Enable debug output (via arg_yyout) if compiled into the scanner.

Definition at line 7125 of file Scanner.cc.

7126 {
7127  yy_flex_debug = b;
7128 }

+ Here is the caller graph for this function:

void torc::generic::Scanner::setAppendToBuffer ( bool  inAppendToBuffer)

Definition at line 7088 of file Scanner.cc.

7088  {
7089  mAppendToBuffer = inAppendToBuffer;
7090 }

+ Here is the caller graph for this function:

void torc::generic::Scanner::setAppendToUserDataBuffer ( bool  inAppendToBuffer)

Definition at line 7098 of file Scanner.cc.

7098  {
7099  mAppendToUserDataBuffer = inAppendToBuffer;
7100 }

+ Here is the caller graph for this function:

void torc::generic::Scanner::setIsIdContext ( bool  inIsIdContext)
inline

Definition at line 112 of file Scanner.hpp.

112  {
113  mIsIdContext = inIsIdContext;
114 }

+ Here is the caller graph for this function:

void torc::generic::Scanner::skipThisRule ( char *  yytext)

Definition at line 7057 of file Scanner.cc.

7057  {
7058  unsigned char c;
7059  int scope = 0;
7060  while(true)
7061  {
7062  c=yyinput();
7063  switch(c)
7064  {
7065  case '(':
7066  {
7067  scope++;
7068  break;
7069  }
7070  case ')':
7071  {
7072  if(-1 == scope)
7073  {
7074  yyunput(c, yytext);
7075  return;
7076  }
7077  scope--;
7078  break;
7079  }
7080  default:
7081  {
7082  }
7083  }
7084  }
7085 }

Field Documentation

bool torc::generic::Scanner::mAppendToBuffer
private

Definition at line 101 of file Scanner.hpp.

bool torc::generic::Scanner::mAppendToUserDataBuffer
private

Definition at line 102 of file Scanner.hpp.

std::string torc::generic::Scanner::mBuffer
private

Definition at line 103 of file Scanner.hpp.

bool torc::generic::Scanner::mIsIdAlreadyAdded
private

Definition at line 105 of file Scanner.hpp.

bool torc::generic::Scanner::mIsIdContext
private

Definition at line 100 of file Scanner.hpp.

std::string torc::generic::Scanner::mUserDataBuffer
private

Definition at line 104 of file Scanner.hpp.


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