mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-06 08:10:02 +00:00
LibJS: Fix do..while parsing by consuming parentheses explicitly (#1652)
Before this patch the parser accepted conditions without enclosing parentheses (like: .."while number < 9").
This commit is contained in:
parent
d077637fd6
commit
2c4a5849f6
Notes:
sideshowbarker
2024-07-19 07:52:56 +09:00
Author: https://github.com/lawl-dev 🔰
Commit: 2c4a5849f6
Pull-request: https://github.com/SerenityOS/serenity/pull/1652
1 changed files with 7 additions and 0 deletions
|
@ -729,9 +729,16 @@ NonnullRefPtr<TryStatement> Parser::parse_try_statement()
|
||||||
NonnullRefPtr<DoWhileStatement> Parser::parse_do_while_statement()
|
NonnullRefPtr<DoWhileStatement> Parser::parse_do_while_statement()
|
||||||
{
|
{
|
||||||
consume(TokenType::Do);
|
consume(TokenType::Do);
|
||||||
|
|
||||||
auto body = parse_statement();
|
auto body = parse_statement();
|
||||||
|
|
||||||
consume(TokenType::While);
|
consume(TokenType::While);
|
||||||
|
consume(TokenType::ParenOpen);
|
||||||
|
|
||||||
auto test = parse_expression(0);
|
auto test = parse_expression(0);
|
||||||
|
|
||||||
|
consume(TokenType::ParenClose);
|
||||||
|
|
||||||
return create_ast_node<DoWhileStatement>(move(test), move(body));
|
return create_ast_node<DoWhileStatement>(move(test), move(body));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue