OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
Token Class Reference

Representation of a single input token. More...

#include <Token.h>

Collaboration diagram for Token:

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

Constructor & Destructor Documentation

◆ Token() [1/7]

Token::Token ( )

Constructor.

Definition at line 31 of file Token.cpp.

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

Referenced by operator=(), and Token().

◆ Token() [2/7]

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

Constructor.

Definition at line 43 of file Token.cpp.

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

◆ Token() [3/7]

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

Constructor.

Definition at line 49 of file Token.cpp.

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

◆ Token() [4/7]

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

Constructor.

Definition at line 55 of file Token.cpp.

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

◆ Token() [5/7]

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

Constructor.

Definition at line 62 of file Token.cpp.

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

◆ Token() [6/7]

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

Constructor.

Definition at line 69 of file Token.cpp.

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

◆ Token() [7/7]

Token::Token ( const Token & rhs)

Definition at line 37 of file Token.cpp.

References c_value, d_value, file, i_value, lexeme, line, Token(), and type.

Here is the call graph for this function:

◆ ~Token()

Token::~Token ( )

Definition at line 76 of file Token.cpp.

Member Function Documentation

◆ getBool()

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:

◆ getFile()

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().

◆ getInteger()

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:

◆ getLex()

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().

◆ getLine()

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().

◆ getReal()

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:

◆ getString()

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:

◆ getType()

Token::Type Token::getType ( ) const

Return the token type.

Definition at line 205 of file Token.cpp.

References type.

Referenced by operator<<().

◆ getWord()

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 LineTemplate::makeInstance(), MacroCmd::makeInstance(), and SequenceTemplate::makeInstance().

Here is the call graph for this function:

◆ invalid()

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

Definition at line 256 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 102 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 97 of file Token.cpp.

References IS_DELIMITER, lexeme, and type.

◆ isEOF()

◆ isError()

bool Token::isError ( ) const

Test for error.

Definition at line 112 of file Token.cpp.

References IS_ERROR, and type.

◆ isInteger()

bool Token::isInteger ( ) const

Test for integer.

Definition at line 117 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 122 of file Token.cpp.

References IS_REAL, and type.

◆ isString()

bool Token::isString ( ) const

Test for string.

Definition at line 132 of file Token.cpp.

References IS_STRING, and type.

Referenced by OpalParser::readStatement().

◆ isWord()

bool Token::isWord ( ) const

Test for word.

Definition at line 127 of file Token.cpp.

References IS_WORD, and type.

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

◆ operator=()

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, Token(), and type.

Here is the call graph for this function:

Member Data Documentation

◆ c_value

char Token::c_value
private

Definition at line 160 of file Token.h.

Referenced by operator=(), Token(), Token(), Token(), Token(), Token(), Token(), and Token().

◆ d_value

double Token::d_value
private

Definition at line 158 of file Token.h.

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

◆ file

std::string Token::file
private

Definition at line 148 of file Token.h.

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

◆ i_value

int Token::i_value
private

Definition at line 159 of file Token.h.

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

◆ lexeme

std::string Token::lexeme
private

◆ line

int Token::line
private

Definition at line 149 of file Token.h.

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

◆ type


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