OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
Token Class Reference

Representation of a single input token. More...

#include <Token.h>

Collaboration diagram for Token:
Collaboration graph

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

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 32 of file Token.h.

Member Enumeration Documentation

◆ Type

Possible token types.

Enumerator
IS_DELIMITER 
IS_EOF 
IS_ERROR 
IS_INTEGER 
IS_REAL 
IS_WORD 
IS_STRING 

Definition at line 35 of file Token.h.

Constructor & Destructor Documentation

◆ Token() [1/7]

Token::Token ( )

Constructor.

Definition at line 30 of file Token.cpp.

◆ Token() [2/7]

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

Constructor.

Definition at line 41 of file Token.cpp.

◆ Token() [3/7]

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

Constructor.

Definition at line 50 of file Token.cpp.

◆ Token() [4/7]

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

Constructor.

Definition at line 53 of file Token.cpp.

◆ Token() [5/7]

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

Constructor.

Definition at line 56 of file Token.cpp.

◆ Token() [6/7]

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

Constructor.

Definition at line 59 of file Token.cpp.

◆ Token() [7/7]

Token::Token ( const Token rhs)

Definition at line 32 of file Token.cpp.

◆ ~Token()

Token::~Token ( )

Definition at line 68 of file Token.cpp.

Member Function Documentation

◆ getBool()

bool Token::getBool ( ) const

Return boolean value.

Definition at line 103 of file Token.cpp.

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

Here is the call graph for this function:

◆ getFile()

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

Return the token's file name.

Definition at line 160 of file Token.cpp.

References file.

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

◆ getInteger()

int Token::getInteger ( ) const

Return integer value.

Definition at line 116 of file Token.cpp.

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

Referenced by Statement::integer(), and operator<<().

Here is the call graph for this function:

◆ getLex()

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

Return the lexeme.

Definition at line 156 of file Token.cpp.

References lexeme.

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

◆ getLine()

int Token::getLine ( ) const

Return the token's line number.

Definition at line 162 of file Token.cpp.

References line.

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

◆ getReal()

double Token::getReal ( ) const

Return real value.

Definition at line 127 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:

◆ getString()

std::string Token::getString ( ) const

Return string value.

Definition at line 138 of file Token.cpp.

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

Here is the call graph for this function:

◆ getType()

Token::Type Token::getType ( ) const

Return the token type.

Definition at line 158 of file Token.cpp.

References type.

Referenced by operator<<().

◆ getWord()

std::string Token::getWord ( ) const

Return word value.

Definition at line 147 of file Token.cpp.

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

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

Here is the call graph for this function:

◆ invalid()

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

Definition at line 198 of file Token.cpp.

References file, line, and type.

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

◆ isDel() [1/3]

bool Token::isDel ( ) const

Test for any delimiter.

Definition at line 87 of file Token.cpp.

References IS_DELIMITER, and type.

◆ isDel() [2/3]

◆ isDel() [3/3]

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

Test for delimiter.

Definition at line 85 of file Token.cpp.

References IS_DELIMITER, lexeme, and type.

◆ isEOF()

◆ isError()

bool Token::isError ( ) const

Test for error.

Definition at line 91 of file Token.cpp.

References IS_ERROR, and type.

◆ isInteger()

bool Token::isInteger ( ) const

Test for integer.

Definition at line 93 of file Token.cpp.

References IS_INTEGER, and type.

◆ isKey()

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

◆ isReal()

bool Token::isReal ( ) const

Test for real number.

Definition at line 95 of file Token.cpp.

References IS_REAL, and type.

◆ isString()

bool Token::isString ( ) const

Test for string.

Definition at line 99 of file Token.cpp.

References IS_STRING, and type.

Referenced by OpalParser::readStatement().

◆ isWord()

bool Token::isWord ( ) const

Test for word.

Definition at line 97 of file Token.cpp.

References IS_WORD, and type.

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

◆ operator=()

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

Definition at line 70 of file Token.cpp.

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

Member Data Documentation

◆ c_value

char Token::c_value
private

Definition at line 147 of file Token.h.

Referenced by operator=().

◆ d_value

double Token::d_value
private

Definition at line 145 of file Token.h.

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

◆ file

std::string Token::file
private

Definition at line 135 of file Token.h.

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

◆ i_value

int Token::i_value
private

Definition at line 146 of file Token.h.

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

◆ lexeme

std::string Token::lexeme
private

Definition at line 142 of file Token.h.

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

◆ line

int Token::line
private

Definition at line 136 of file Token.h.

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

◆ type


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