OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Token Class Reference

Representation of a single input token. More...

#include <Token.h>

Public Types

enum  Type {
  IS_DELIMITER, IS_EOF, IS_ERROR, IS_INTEGER,
  IS_REAL, IS_WORD, IS_STRING
}
 Possible token types. More...
 

Public Member Functions

 Token ()
 Constructor. More...
 
 Token (const std::string &file, int line, Type type, char c)
 Constructor. More...
 
 Token (const std::string &file, int line, Type type, const char *s)
 Constructor. More...
 
 Token (const std::string &file, int line, Type type, const std::string &lex)
 Constructor. More...
 
 Token (const std::string &file, int line, const std::string &lex, double value)
 Constructor. More...
 
 Token (const std::string &file, int line, const std::string &lex, int value)
 Constructor. More...
 
 Token (const Token &)
 
 ~Token ()
 
const Tokenoperator= (const Token &)
 
bool isDel (char del) const
 Test for delimiter. More...
 
bool isDel (const char *del) const
 Test for delimiter. More...
 
bool isDel () const
 Test for any delimiter. More...
 
bool isEOF () const
 Test for end of file. More...
 
bool isError () const
 Test for error. More...
 
bool isInteger () const
 Test for integer. More...
 
bool isReal () const
 Test for real number. More...
 
bool isWord () const
 Test for word. More...
 
bool isString () const
 Test for string. More...
 
bool isKey (const char *key) const
 Test for keyword. More...
 
bool getBool () const
 Return boolean value. More...
 
int getInteger () const
 Return integer value. More...
 
double getReal () const
 Return real value. More...
 
std::string getString () const
 Return string value. More...
 
std::string getWord () const
 Return word value. More...
 
const std::string & getLex () const
 Return the lexeme. More...
 
Type getType () const
 Return the token type. More...
 
const std::string & getFile () const
 Return the token's file name. More...
 
int getLine () const
 Return the token's line number. More...
 

Private Member Functions

void invalid (const char *) const
 

Private Attributes

std::string file
 
int line
 
Type type
 
std::string lexeme
 
double d_value
 
int i_value
 
char c_value
 

Detailed Description

Representation of a single input token.

Definition at line 33 of file Token.h.

Member Enumeration Documentation

Possible token types.

Enumerator
IS_DELIMITER 
IS_EOF 
IS_ERROR 
IS_INTEGER 
IS_REAL 
IS_WORD 
IS_STRING 

Definition at line 38 of file Token.h.

Constructor & Destructor Documentation

Token::Token ( )

Constructor.

Definition at line 31 of file Token.cpp.

Token::Token ( const std::string &  file,
int  line,
Type  type,
char  c 
)

Constructor.

Definition at line 43 of file Token.cpp.

Token::Token ( const std::string &  file,
int  line,
Type  type,
const char *  s 
)

Constructor.

Definition at line 49 of file Token.cpp.

Token::Token ( const std::string &  file,
int  line,
Type  type,
const std::string &  lex 
)

Constructor.

Definition at line 56 of file Token.cpp.

Token::Token ( const std::string &  file,
int  line,
const std::string &  lex,
double  value 
)

Constructor.

Definition at line 63 of file Token.cpp.

Token::Token ( const std::string &  file,
int  line,
const std::string &  lex,
int  value 
)

Constructor.

Definition at line 70 of file Token.cpp.

Token::Token ( const Token rhs)

Definition at line 37 of file Token.cpp.

Token::~Token ( )

Definition at line 76 of file Token.cpp.

Member Function Documentation

bool Token::getBool ( ) const

Return boolean value.

Definition at line 142 of file Token.cpp.

References invalid(), IS_WORD, lexeme, and type.

Here is the call graph for this function:

const std::string & Token::getFile ( ) const

Return the token's file name.

Definition at line 210 of file Token.cpp.

References file.

Referenced by CompoundStatement::CompoundStatement(), and OpalParser::readStatement().

int Token::getInteger ( ) const

Return integer value.

Definition at line 156 of file Token.cpp.

References d_value, i_value, invalid(), IS_INTEGER, IS_REAL, and type.

Referenced by operator<<().

Here is the call graph for this function:

const std::string & Token::getLex ( ) const

Return the lexeme.

Definition at line 200 of file Token.cpp.

References lexeme.

Referenced by operator<<(), and OpalParser::parse().

int Token::getLine ( ) const

Return the token's line number.

Definition at line 215 of file Token.cpp.

References line.

Referenced by CompoundStatement::CompoundStatement(), and OpalParser::readStatement().

double Token::getReal ( ) const

Return real value.

Definition at line 168 of file Token.cpp.

References d_value, i_value, invalid(), IS_INTEGER, IS_REAL, and type.

Referenced by operator<<().

Here is the call graph for this function:

std::string Token::getString ( ) const

Return string value.

Definition at line 180 of file Token.cpp.

References invalid(), IS_STRING, lexeme, and type.

Here is the call graph for this function:

Token::Type Token::getType ( ) const

Return the token type.

Definition at line 205 of file Token.cpp.

References type.

Referenced by operator<<().

std::string Token::getWord ( ) const

Return word value.

Definition at line 190 of file Token.cpp.

References invalid(), IS_WORD, lexeme, and type.

Referenced by MacroCmd::makeInstance(), LineTemplate::makeInstance(), and SequenceTemplate::makeInstance().

Here is the call graph for this function:

void Token::invalid ( const char *  type) const
private

Definition at line 256 of file Token.cpp.

References file, and line.

Referenced by getBool(), getInteger(), getReal(), getString(), and getWord().

bool Token::isDel ( char  del) const
bool Token::isDel ( const char *  del) const

Test for delimiter.

Definition at line 97 of file Token.cpp.

References IS_DELIMITER, lexeme, and type.

bool Token::isDel ( ) const

Test for any delimiter.

Definition at line 102 of file Token.cpp.

References IS_DELIMITER, and type.

bool Token::isEOF ( ) const
bool Token::isError ( ) const

Test for error.

Definition at line 112 of file Token.cpp.

References IS_ERROR, and type.

bool Token::isInteger ( ) const

Test for integer.

Definition at line 117 of file Token.cpp.

References IS_INTEGER, and type.

bool Token::isKey ( const char *  key) const
bool Token::isReal ( ) const

Test for real number.

Definition at line 122 of file Token.cpp.

References IS_REAL, and type.

bool Token::isString ( ) const

Test for string.

Definition at line 132 of file Token.cpp.

References IS_STRING, and type.

Referenced by OpalParser::readStatement().

bool Token::isWord ( ) const

Test for word.

Definition at line 127 of file Token.cpp.

References IS_WORD, and type.

Referenced by MacroCmd::makeInstance(), LineTemplate::makeInstance(), SequenceTemplate::makeInstance(), and OpalParser::readStatement().

const Token & Token::operator= ( const Token rhs)

Definition at line 80 of file Token.cpp.

References c_value, d_value, file, i_value, lexeme, line, and type.

Member Data Documentation

char Token::c_value
private

Definition at line 160 of file Token.h.

Referenced by operator=().

double Token::d_value
private

Definition at line 158 of file Token.h.

Referenced by getInteger(), getReal(), and operator=().

std::string Token::file
private

Definition at line 148 of file Token.h.

Referenced by getFile(), invalid(), and operator=().

int Token::i_value
private

Definition at line 159 of file Token.h.

Referenced by getInteger(), getReal(), and operator=().

std::string Token::lexeme
private

Definition at line 155 of file Token.h.

Referenced by getBool(), getLex(), getString(), getWord(), isDel(), isKey(), and operator=().

int Token::line
private

Definition at line 149 of file Token.h.

Referenced by getLine(), invalid(), and operator=().

Type Token::type
private

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