OPAL (Object Oriented Parallel Accelerator Library)
2021.1.99
OPAL
|
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 Token & | operator= (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 |
enum Token::Type |
Token::Token | ( | const std::string & | file, |
int | line, | ||
Type | type, | ||
char | c | ||
) |
Token::Token | ( | const std::string & | file, |
int | line, | ||
Type | type, | ||
const char * | s | ||
) |
Token::Token | ( | const std::string & | file, |
int | line, | ||
Type | type, | ||
const std::string & | lex | ||
) |
Token::Token | ( | const std::string & | file, |
int | line, | ||
const std::string & | lex, | ||
double | value | ||
) |
Token::Token | ( | const std::string & | file, |
int | line, | ||
const std::string & | lex, | ||
int | value | ||
) |
bool Token::getBool | ( | ) | const |
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<<().
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<<().
std::string Token::getString | ( | ) | const |
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 SequenceTemplate::makeInstance(), MacroCmd::makeInstance(), and LineTemplate::makeInstance().
|
private |
Definition at line 256 of file Token.cpp.
References file, line, and type.
Referenced by getBool(), getInteger(), getReal(), getString(), and getWord().
bool Token::isDel | ( | ) | const |
Test for any delimiter.
Definition at line 102 of file Token.cpp.
References IS_DELIMITER, and type.
bool Token::isDel | ( | char | del | ) | const |
Test for delimiter.
Definition at line 92 of file Token.cpp.
References IS_DELIMITER, lexeme, and type.
Referenced by CompoundStatement::CompoundStatement(), IfStatement::IfStatement(), MacroCmd::makeTemplate(), Macro::parseActuals(), OpalParser::parseBracketList(), Expressions::parseBracketList(), SequenceTemplate::parseTemplate(), LineTemplate::parseTemplate(), Expressions::parseTokenList(), OpalParser::parseTokenList(), OpalParser::readStatement(), and WhileStatement::WhileStatement().
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::isEOF | ( | ) | const |
Test for end of file.
Definition at line 107 of file Token.cpp.
Referenced by CompoundStatement::CompoundStatement(), IfStatement::IfStatement(), SequenceTemplate::makeInstance(), MacroCmd::makeInstance(), LineTemplate::makeInstance(), OpalParser::parseBracketList(), SequenceTemplate::parseTemplate(), OpalParser::parseTokenList(), OpalParser::readStatement(), and WhileStatement::WhileStatement().
bool Token::isError | ( | ) | const |
bool Token::isInteger | ( | ) | const |
bool Token::isKey | ( | const char * | key | ) | const |
Test for keyword.
Definition at line 137 of file Token.cpp.
References IS_WORD, lexeme, and type.
Referenced by IfStatement::IfStatement(), SequenceTemplate::parseTemplate(), OpalParser::readStatement(), and WhileStatement::WhileStatement().
bool Token::isReal | ( | ) | const |
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.
Referenced by SequenceTemplate::makeInstance(), MacroCmd::makeInstance(), LineTemplate::makeInstance(), and OpalParser::readStatement().
|
private |
Definition at line 160 of file Token.h.
Referenced by operator=().
|
private |
Definition at line 158 of file Token.h.
Referenced by getInteger(), getReal(), and operator=().
|
private |
Definition at line 148 of file Token.h.
Referenced by getFile(), invalid(), and operator=().
|
private |
Definition at line 159 of file Token.h.
Referenced by getInteger(), getReal(), and operator=().
|
private |
Definition at line 155 of file Token.h.
Referenced by getBool(), getLex(), getString(), getWord(), isDel(), isKey(), and operator=().
|
private |
Definition at line 149 of file Token.h.
Referenced by getLine(), invalid(), and operator=().
|
private |
Definition at line 152 of file Token.h.
Referenced by getBool(), getInteger(), getReal(), getString(), getType(), getWord(), invalid(), isDel(), isEOF(), isError(), isInteger(), isKey(), isReal(), isString(), isWord(), and operator=().