GSC Interpreter
A Turing-complete interpreter developed for a compiler course
|
Represents a token in the source code. More...
#include <token.hpp>
Public Member Functions | |
Token (TokenType type, std::string lexeme, std::any literal, int line) | |
Constructs a Token object. | |
TokenType | getType () const |
std::string | getLexeme () const |
std::any | getLiteral () const |
int | getLine () const |
std::string | toString () const |
Private Attributes | |
const TokenType | type |
const std::string | lexeme |
const std::any | literal |
const int | line |
Represents a token in the source code.
The Token class encapsulates the type, lexeme, literal value, and line number of a token. It provides a method to convert the token to a string representation.
Token::Token | ( | TokenType | type, |
std::string | lexeme, | ||
std::any | literal, | ||
int | line | ||
) |
Constructs a Token object.
type | The type of the token. |
lexeme | The lexeme of the token. |
literal | The literal value of the token (if any). |
line | The line number where the token was found. |
Definition at line 4 of file token.cpp.
std::string Token::getLexeme | ( | ) | const |
std::string Token::toString | ( | ) | const |
Definition at line 16 of file token.cpp.