|
Porytiles
|
Represents a lexical token from C source code. More...
#include <token.hpp>
Public Member Functions | |
| Token (TokenType type, std::string text, SourcePosition position) | |
| Constructs a token with the given type, text, and position. | |
| Token (std::string text, std::int64_t int_value, SourcePosition position) | |
| Constructs an integer literal token with a parsed value. | |
| TokenType | type () const |
| Returns the token type. | |
| const std::string & | text () const |
| Returns the raw text of the token. | |
| const SourcePosition & | position () const |
| Returns the source position where the token starts. | |
| std::int64_t | int_value () const |
| Returns the integer value for integer_literal tokens. | |
| bool | is (TokenType type) const |
| Checks if this token is of the specified type. | |
| template<typename... Types> | |
| bool | is_any_of (Types... types) const |
| Checks if this token is any of the specified types. | |
Represents a lexical token from C source code.
Token captures the type, textual representation, parsed value (if applicable), and source position of a lexical unit. For integer literals, the parsed numeric value is stored in int_value_. For identifiers and string literals, the text representation is used.
|
inline |
|
inline |
|
inline |
Returns the integer value for integer_literal tokens.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |