mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
LibJS: Include source location hint in Parser::print_errors()
This commit is contained in:
parent
28552f3f36
commit
abd49c174a
Notes:
sideshowbarker
2024-07-19 01:01:26 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/abd49c174a6 Pull-request: https://github.com/SerenityOS/serenity/pull/4343
2 changed files with 8 additions and 2 deletions
|
@ -40,6 +40,8 @@ public:
|
|||
|
||||
Token next();
|
||||
|
||||
const StringView& source() const { return m_source; };
|
||||
|
||||
private:
|
||||
void consume();
|
||||
bool consume_exponent();
|
||||
|
|
|
@ -143,8 +143,12 @@ public:
|
|||
const Vector<Error>& errors() const { return m_parser_state.m_errors; }
|
||||
void print_errors() const
|
||||
{
|
||||
for (auto& error : m_parser_state.m_errors)
|
||||
fprintf(stderr, "SyntaxError: %s\n", error.to_string().characters());
|
||||
for (auto& error : m_parser_state.m_errors) {
|
||||
auto hint = error.source_location_hint(m_parser_state.m_lexer.source());
|
||||
if (!hint.is_empty())
|
||||
warnln("{}", hint);
|
||||
warnln("SyntaxError: {}", error.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue