mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
LibJS: Implement basic lexing + parsing of StringLiteral
This still includes the double-quote characters (") but at least the AST comes out right.
This commit is contained in:
parent
879bf3e97b
commit
ed100bc6f4
Notes:
sideshowbarker
2024-07-19 08:45:20 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/ed100bc6f48
2 changed files with 9 additions and 0 deletions
|
@ -195,6 +195,13 @@ Token Lexer::next()
|
|||
consume();
|
||||
}
|
||||
token_type = TokenType::NumericLiteral;
|
||||
} else if (m_current_char == '"') {
|
||||
consume();
|
||||
while (m_current_char != '"') {
|
||||
consume();
|
||||
}
|
||||
consume();
|
||||
token_type = TokenType::StringLiteral;
|
||||
} else if (m_current_char == EOF) {
|
||||
token_type = TokenType::Eof;
|
||||
} else {
|
||||
|
|
|
@ -89,6 +89,8 @@ NonnullOwnPtr<Expression> Parser::parse_primary_expression()
|
|||
return make<NumericLiteral>(consume().double_value());
|
||||
case TokenType::BoolLiteral:
|
||||
return make<BooleanLiteral>(consume().bool_value());
|
||||
case TokenType::StringLiteral:
|
||||
return make<StringLiteral>(consume().string_value());
|
||||
case TokenType::CurlyOpen:
|
||||
return parse_object_expression();
|
||||
default:
|
||||
|
|
Loading…
Reference in a new issue