picceler
Loading...
Searching...
No Matches
picceler::Token Struct Reference

Represents a token produced by the lexer. More...

#include <lexer.h>

Public Types

enum class  Type : uint8_t {
  IDENTIFIER , NUMBER , PLUS , MINUS ,
  MULTIPLY , DIVIDE , STRING , L_PAREN ,
  R_PAREN , L_BRACKET , R_BRACKET , L_BRACE ,
  R_BRACE , COMMA , COLON , ARROW ,
  ASSIGN , EQ , NE , LT ,
  GT , LE , GE , TYPE ,
  KW_DEF , KW_RETURN , KW_IF , EOF_TOKEN ,
  UNKNOWN
}
 The type of the token. More...

Public Member Functions

 Token ()
 Token (Type type, std::string value, Location location)
 Token (const Token &other)
 Token (Token &&other) noexcept
 ~Token ()=default
Tokenoperator= (const Token &other)
Tokenoperator= (Token &&other) noexcept
std::string typeToString () const
 Converts the token type to a string representation.
std::string toString () const
 Converts the token to a string representation.
Type type () const
const std::string & value () const
size_t line () const
size_t column () const
Location location () const

Friends

constexpr bool operator== (const Token &lhs, const Token::Type &rhs)

Detailed Description

Represents a token produced by the lexer.

Member Enumeration Documentation

◆ Type

enum class picceler::Token::Type : uint8_t
strong

The type of the token.

Enumerator
IDENTIFIER 
NUMBER 
PLUS 
MINUS 
MULTIPLY 
DIVIDE 
STRING 
L_PAREN 
R_PAREN 
L_BRACKET 
R_BRACKET 
L_BRACE 
R_BRACE 
COMMA 
COLON 
ARROW 
ASSIGN 
EQ 
NE 
LT 
GT 
LE 
GE 
TYPE 
KW_DEF 
KW_RETURN 
KW_IF 
EOF_TOKEN 
UNKNOWN 

Constructor & Destructor Documentation

◆ Token() [1/4]

picceler::Token::Token ( )
inline

◆ Token() [2/4]

picceler::Token::Token ( Type type,
std::string value,
Location location )
inline

◆ Token() [3/4]

picceler::Token::Token ( const Token & other)
inline

◆ Token() [4/4]

picceler::Token::Token ( Token && other)
inlinenoexcept

◆ ~Token()

picceler::Token::~Token ( )
default

Member Function Documentation

◆ column()

size_t picceler::Token::column ( ) const
inline

◆ line()

size_t picceler::Token::line ( ) const
inline

◆ location()

Location picceler::Token::location ( ) const
inline

◆ operator=() [1/2]

Token & picceler::Token::operator= ( const Token & other)
inline

◆ operator=() [2/2]

Token & picceler::Token::operator= ( Token && other)
inlinenoexcept

◆ toString()

std::string picceler::Token::toString ( ) const
inline

Converts the token to a string representation.

Returns
The string representation of the token.

◆ type()

Type picceler::Token::type ( ) const
inline

◆ typeToString()

std::string picceler::Token::typeToString ( ) const

Converts the token type to a string representation.

Returns
The string representation of the token type.

◆ value()

const std::string & picceler::Token::value ( ) const
inline

◆ operator==

bool operator== ( const Token & lhs,
const Token::Type & rhs )
friend

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