mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:27:44 +00:00
LibJS: Include source location hint in Parser::print_errors()
This commit is contained in:
parent
28552f3f36
commit
abd49c174a
2 changed files with 8 additions and 2 deletions
|
@ -40,6 +40,8 @@ public:
|
||||||
|
|
||||||
Token next();
|
Token next();
|
||||||
|
|
||||||
|
const StringView& source() const { return m_source; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void consume();
|
void consume();
|
||||||
bool consume_exponent();
|
bool consume_exponent();
|
||||||
|
|
|
@ -143,8 +143,12 @@ public:
|
||||||
const Vector<Error>& errors() const { return m_parser_state.m_errors; }
|
const Vector<Error>& errors() const { return m_parser_state.m_errors; }
|
||||||
void print_errors() const
|
void print_errors() const
|
||||||
{
|
{
|
||||||
for (auto& error : m_parser_state.m_errors)
|
for (auto& error : m_parser_state.m_errors) {
|
||||||
fprintf(stderr, "SyntaxError: %s\n", error.to_string().characters());
|
auto hint = error.source_location_hint(m_parser_state.m_lexer.source());
|
||||||
|
if (!hint.is_empty())
|
||||||
|
warnln("{}", hint);
|
||||||
|
warnln("SyntaxError: {}", error.to_string());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue