31 std::vector<std::pair<std::string::iterator, std::size_t>>
m_it_to_row;
32 std::string::iterator
m_it, m_next_it;
42 void registerNewLine(std::string::iterator it, std::size_t row);
52 void initParser(
const std::string& filename,
const std::string& code);
56 [[nodiscard]]
CodeErrorContext generateErrorContextAtCurrentPosition()
const;
65 void error(
const std::string& error,
FilePosition start_at,
const std::optional<CodeErrorContext>& additional_context = std::nullopt)
const;
73 void errorWithNextToken(
const std::string& message,
const std::optional<CodeErrorContext>& additional_context = std::nullopt);
82 void expectSuffixOrError(
char suffix,
const std::string& context,
const std::optional<CodeErrorContext>& additional_context = std::nullopt);
88 long getCount() {
return static_cast<long>(std::distance(m_str.begin(), m_it)); }
94 [[nodiscard]] std::size_t
getSize()
const {
return m_str.size(); }
100 [[nodiscard]]
bool isEOF()
const {
return m_it == m_str.end(); }
107 void backtrack(
long n);
116 bool accept(
const CharPred& t, std::string* s =
nullptr);
124 bool expect(
const CharPred& t, std::string* s =
nullptr);
126 [[nodiscard]] std::string peek()
const;
130 bool space(std::string* s =
nullptr);
131 bool inlineSpace(std::string* s =
nullptr);
132 bool comment(std::string* s =
nullptr);
133 [[nodiscard]] std::string spaceComment();
134 [[nodiscard]] std::string newlineOrComment();
136 bool number(std::string* s =
nullptr);
137 bool signedNumber(std::string* s =
nullptr);
138 bool hexNumber(
unsigned length, std::string* s =
nullptr);
139 bool name(std::string* s =
nullptr);
140 bool sequence(
const std::string& s);
141 bool packageName(std::string* s =
nullptr);
150 bool anyUntil(
const CharPred& delim, std::string* s =
nullptr);
159 bool oneOf(std::initializer_list<std::string> words, std::string* s =
nullptr);