mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 19:04:58 +00:00
LibJS: Remove syntax errors from lexer
Giving the lexer the ability to generate errors adds unnecessary
complexity - also it only calls its syntax_error() function in one place
anyway ("unterminated string literal"). But since the lexer *also* emits
tokens like Eof or UnterminatedStringLiteral, it should be up to the
consumer of these tokens to decide what to do.
Also remove the option to not print errors to stderr as that's not
relevant anymore.
This commit is contained in:
committed by
Andreas Kling
parent
3485613f4a
commit
00b61a212f
@@ -240,13 +240,6 @@ bool Lexer::is_numeric_literal_start() const
|
||||
return isdigit(m_current_char) || (m_current_char == '.' && m_position < m_source.length() && isdigit(m_source[m_position]));
|
||||
}
|
||||
|
||||
void Lexer::syntax_error(const char* msg)
|
||||
{
|
||||
m_has_errors = true;
|
||||
if (m_log_errors)
|
||||
fprintf(stderr, "Syntax Error: %s (line: %zu, column: %zu)\n", msg, m_line_number, m_line_column);
|
||||
}
|
||||
|
||||
Token Lexer::next()
|
||||
{
|
||||
size_t trivia_start = m_position;
|
||||
@@ -395,7 +388,6 @@ Token Lexer::next()
|
||||
consume();
|
||||
}
|
||||
if (m_current_char != stop_char) {
|
||||
syntax_error("unterminated string literal");
|
||||
token_type = TokenType::UnterminatedStringLiteral;
|
||||
} else {
|
||||
consume();
|
||||
|
||||
Reference in New Issue
Block a user