Skip to content

Commit

Permalink
lexer: Fixed extreme error spam when triggering lexer error
Browse files Browse the repository at this point in the history
  • Loading branch information
WerWolv committed Feb 7, 2025
1 parent 52860ff commit c6c63d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/source/pl/core/lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ namespace pl::core {

m_tokens.clear();

while(this->m_cursor < end) {
while (this->m_cursor < end) {
const char& c = this->m_sourceCode[this->m_cursor];

if (c == '\x00') {
Expand Down Expand Up @@ -644,6 +644,9 @@ namespace pl::core {
} else {
m_errorLength = 1;
error("Unexpected character: {}", c);
m_cursor++;

break;
}

m_cursor++;
Expand Down
4 changes: 3 additions & 1 deletion lib/source/pl/core/preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,9 +579,11 @@ namespace pl::core {
m_result = std::move(result.value());
else
return { std::nullopt, errors };
if (!errors.empty())
if (!errors.empty()) {
for (auto &item: errors)
this->error(item);
return { m_output, collectErrors() };
}

m_token = m_result.begin();
m_initialized = true;
Expand Down

0 comments on commit c6c63d8

Please sign in to comment.