12#ifndef ARK_COMPILER_LEXER_HPP
13#define ARK_COMPILER_LEXER_HPP
34 explicit Lexer(
unsigned debug)
noexcept;
41 void feed(
const std::string& code);
48 std::vector<Token>&
tokens()
noexcept;
56 return ((
'a' <= chr && chr <=
'f') || (
'A' <= chr && chr <=
'F') || (
'0' <= chr && chr <=
'9'));
74 bool isKeyword(
const std::string& value)
noexcept;
91 bool isOperator(
const std::string& value)
noexcept;
112 [[noreturn]]
void throwTokenizingError(
const std::string& message,
const std::string& match, std::size_t line, std::size_t col,
const std::string& context);
Common code for the compiler.
Token definition for ArkScript.
The lexer, in charge of creating a list of tokens.
std::vector< Token > & tokens() noexcept
Return the list of tokens.
bool isIdentifier(const std::string &value) noexcept
Check if the value can be an identifier in ArkScript.
constexpr bool isHexChar(char chr)
bool isKeyword(const std::string &value) noexcept
Check if the value is a keyword in ArkScript.
TokenType guessType(const std::string &value) noexcept
Helper function to determine the type of a token.
void feed(const std::string &code)
Give code to tokenize and create the list of tokens.
bool isOperator(const std::string &value) noexcept
Check if the value is an operator in ArkScript.
std::vector< Token > m_tokens
bool endOfControlChar(const std::string &sequence, char next) noexcept
Check if a control character / sequence is complete or not.
void throwTokenizingError(const std::string &message, const std::string &match, std::size_t line, std::size_t col, const std::string &context)
To throw nice lexer errors.