![]() |
ArkScript
A small, fast, functional and scripting language for video games
|
The lexer, in charge of creating a list of tokens. More...
#include <Lexer.hpp>
Public Member Functions | |
Lexer (unsigned debug) noexcept | |
Construct a new Lexer object. | |
void | feed (const std::string &code) |
Give code to tokenize and create the list of tokens. | |
std::vector< Token > & | tokens () noexcept |
Return the list of tokens. | |
Private Member Functions | |
constexpr bool | isHexChar (char chr) |
TokenType | guessType (const std::string &value) noexcept |
Helper function to determine the type of a token. | |
bool | isKeyword (const std::string &value) noexcept |
Check if the value is a keyword in ArkScript. | |
bool | isIdentifier (const std::string &value) noexcept |
Check if the value can be an identifier in ArkScript. | |
bool | isOperator (const std::string &value) noexcept |
Check if the value is an operator in ArkScript. | |
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. | |
Private Attributes | |
unsigned | m_debug |
std::vector< Token > | m_tokens |
|
explicitnoexcept |
|
privatenoexcept |
void Ark::internal::Lexer::feed | ( | const std::string & | code | ) |
Give code to tokenize and create the list of tokens.
code | the ArkScript code |
Definition at line 19 of file Lexer.cpp.
References Ark::internal::Capture, endOfControlChar(), Ark::internal::GetField, Ark::internal::Grouping, guessType(), m_debug, m_tokens, Ark::internal::Mismatch, Ark::internal::Shorthand, Ark::internal::String, throwTokenizingError(), and Ark::internal::tokentype_string.
Referenced by Ark::internal::Parser::feed().
|
privatenoexcept |
Helper function to determine the type of a token.
value |
Definition at line 262 of file Lexer.cpp.
References Ark::internal::Capture, Ark::internal::GetField, Ark::internal::Identifier, Ark::Utils::isDouble(), Ark::internal::Keyword, Ark::internal::Mismatch, Ark::internal::Number, Ark::internal::Operator, and Ark::internal::Spread.
Referenced by feed().
|
inlineconstexprprivate |
|
privatenoexcept |
|
privatenoexcept |
Check if the value is a keyword in ArkScript.
value |
Definition at line 286 of file Lexer.cpp.
References Ark::internal::keywords.
|
privatenoexcept |
Check if the value is an operator in ArkScript.
value |
Definition at line 296 of file Lexer.cpp.
References Ark::internal::operators.
|
private |
To throw nice lexer errors.
message | |
match | |
line | |
col | |
context |
Definition at line 330 of file Lexer.cpp.
References Ark::internal::makeTokenBasedErrorCtx(), and Ark::Utils::splitString().
Referenced by feed().
|
noexcept |
Return the list of tokens.
Definition at line 257 of file Lexer.cpp.
References m_tokens.
Referenced by Ark::internal::Parser::feed().
|
private |
|
private |