113 bool isIdentifier(
char ch)
const;
119 bool isSymbol(
char ch)
const;
126 Result<Token> readIdentifier(std::pair<size_t, size_t> start);
Lexer()
Constructs a Lexer.
Definition lexer.cpp:30
Result< void > setSource(const std::string &source)
Sets the source file for the lexer.
Definition lexer.cpp:32
Result< Token > peekToken()
Returns the next token without advancing the input.
Definition lexer.cpp:75
Result< Token > nextToken()
Returns the next token from the input.
Definition lexer.cpp:49
void skipWhitespace()
Skips whitespace characters in the input.
Definition lexer.cpp:86
Result< std::vector< Token > > tokenizeAll()
Tokenizes the entire input.
Definition lexer.cpp:92
std::expected< T, CompileError > Result
Definition error.h:33
std::ostream & operator<<(std::ostream &os, const Token &token)
Outputs a token to the given output stream.
Definition lexer.cpp:181
Represents a token produced by the lexer.
Definition lexer.h:27
std::string _value
Definition lexer.h:46
std::string typeToString() const
Converts the token type to a string representation.
Definition lexer.cpp:10
std::string toString() const
Converts the token to a string representation.
Definition lexer.h:41
Type
The type of the token.
Definition lexer.h:29
@ NUMBER
Definition lexer.h:29
@ STRING
Definition lexer.h:29
@ UNKNOWN
Definition lexer.h:29
@ IDENTIFIER
Definition lexer.h:29
@ EOF_TOKEN
Definition lexer.h:29
@ SYMBOL
Definition lexer.h:29
size_t _line
Definition lexer.h:47
size_t _column
Definition lexer.h:48
Type _type
Definition lexer.h:45