12DEFINE_ERROR(
"lexer", Error, EOF, Syntax, IllegalCharacter)
14const std::unordered_map<std::string_view, token::Type>
kKeywords = {
15 {
"let", token::Type::kLet},
16 {
"fn", token::Type::kFn},
21 Lexer(std::string input);
26 static auto IsWhitespace(
const char c) {
27 constexpr std::array kWhitespaceChars{
' ',
'\t',
'\n'};
28 return std::ranges::any_of(kWhitespaceChars, [c](
const char whitespace) {
29 return c == whitespace;
33 static auto IsLetter(
const char c) {
34 return std::isalpha(c) || c ==
'_';
37 static auto IsDigit(
const char c) {
38 return std::isdigit(c) || c ==
'.';
47 void ConsumeWhitespace();
51 std::string::iterator curr_;
52 std::string::iterator peek_;
auto NextToken() -> result_t< token::Token >
Definition lexer.cpp:16
Lexer(std::string input)
Definition lexer.cpp:10
const std::unordered_map< std::string_view, token::Type > kKeywords
Definition lexer.hpp:14
boost::outcome_v2::result< T, result::Err, boost::outcome_v2::policy::terminate > result_t
Definition result.hpp:66
#define DEFINE_ERROR(module_name, name,...)
Definition result.hpp:91