14 if (std::ranges::find_if(
m_it_to_row, [it](
const auto& pair) {
15 return pair.first == it;
26 for (std::size_t i = 0, end =
m_it_to_row.size(); i < end; ++i)
30 if (current < it && it <
next)
34 std::make_pair(it, row));
72 error(
"Expected symbol, got empty string",
"");
84 if (std::cmp_greater_equal(n,
m_str.size()))
93 for (std::size_t i = 0, end =
m_it_to_row.size(); i < end; ++i)
103 std::string_view view =
m_str;
104 const auto it_pos =
static_cast<std::size_t
>(std::distance(
m_str.begin(),
m_it));
105 view = view.substr(0, it_pos);
106 const auto nearest_newline_index = view.find_last_of(
'\n');
107 if (nearest_newline_index != std::string_view::npos)
127 std::string next_token;
132 error(message, next_token);
210 bool matched =
false;
224 bool matched =
false;
295 if (
accept(alpha_symbols, s))
297 while (
accept(alnum_symbols, s))
306 return std::ranges::all_of(s, [
this](
const char c) {
342 return std::ranges::any_of(words, [&buffer](
const std::string& word) {
343 return word == buffer;
ArkScript homemade exceptions.
bool sequence(const std::string &s)
FilePosition m_filepos
The position of the cursor in the file.
bool spaceComment(std::string *s=nullptr)
std::string::iterator m_next_it
void initParser(const std::string &filename, const std::string &code)
bool expect(const CharPred &t, std::string *s=nullptr)
heck if a Character Predicate was able to parse, call next() if matching ; throw a CodeError if it do...
bool number(std::string *s=nullptr)
std::string::iterator m_it
bool accept(const CharPred &t, std::string *s=nullptr)
check if a Character Predicate was able to parse, call next() if matching
bool hexNumber(unsigned length, std::string *s=nullptr)
bool newlineOrComment(std::string *s=nullptr)
bool anyUntil(const CharPred &delim, std::string *s=nullptr)
Match any char that do not match the predicate.
bool oneOf(std::initializer_list< std::string > words, std::string *s=nullptr)
Fetch a token and try to match one of the given words.
void error(const std::string &error, std::string exp)
bool space(std::string *s=nullptr)
void registerNewLine(std::string::iterator it, std::size_t row)
Register the position of a new line, with an iterator pointing to the new line and the row number.
void next()
getting next character and changing the values of count/row/col/sym
bool name(std::string *s=nullptr)
bool comment(std::string *s=nullptr)
bool packageName(std::string *s=nullptr)
void errorWithNextToken(const std::string &message)
Fetch the next token (space and paren delimited) to generate an error.
void errorMissingSuffix(char suffix, const std::string &node_name)
Generate an error for a given node when a suffix is missing.
bool inlineSpace(std::string *s=nullptr)
bool signedNumber(std::string *s=nullptr)
std::vector< std::pair< std::string::iterator, std::size_t > > m_it_to_row
A crude map of position to line number to speed up line number computing.
utf8_char_t m_sym
The current utf8 character we're on.
FilePosition getCursor() const
codepoint_t codepoint() const
const char * c_str() const
static std::pair< std::string::iterator, utf8_char_t > at(const std::string::iterator it, const std::string::iterator end)
Parse a codepoint and compute its length and representation.
const IsChar IsMinus('-')
CodeError thrown by the compiler (parser, macro processor, optimizer, and compiler itself)
Describe a position in a given file ; handled by the BaseParser.