mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-01 20:10:28 +00:00
LibJS: Implement basic MemberExpression parsing
At last we can parse "hello friends".length :^)
This commit is contained in:
parent
ed100bc6f4
commit
f405cb6a77
Notes:
sideshowbarker
2024-07-19 08:45:18 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/f405cb6a77d
2 changed files with 6 additions and 4 deletions
|
@ -1,3 +1 @@
|
|||
function foo() {
|
||||
"hello friends".length
|
||||
}
|
||||
"hello friends".length
|
||||
|
|
|
@ -132,6 +132,9 @@ NonnullOwnPtr<Expression> Parser::parse_secondary_expression(NonnullOwnPtr<Expre
|
|||
case TokenType::Equals:
|
||||
consume();
|
||||
return make<AssignmentExpression>(AssignmentOp::Assign, move(lhs), parse_expression());
|
||||
case TokenType::Period:
|
||||
consume();
|
||||
return make<MemberExpression>(move(lhs), parse_expression());
|
||||
default:
|
||||
m_has_errors = true;
|
||||
expected("secondary expression (missing switch case)");
|
||||
|
@ -239,7 +242,8 @@ bool Parser::match_secondary_expression() const
|
|||
|| type == TokenType::Asterisk
|
||||
|| type == TokenType::Slash
|
||||
|| type == TokenType::Equals
|
||||
|| type == TokenType::ParenOpen;
|
||||
|| type == TokenType::ParenOpen
|
||||
|| type == TokenType::Period;
|
||||
}
|
||||
|
||||
bool Parser::match_statement() const
|
||||
|
|
Loading…
Reference in a new issue