wgsl::ParserImpl: Use sync() for postfix_expr()
postfix_expr() handles `[]` array accessors and call expressions `()`. Have postfix_expr() use sync to parse these: * It will use the end bracket token to attempt to resynchronize the parser on error * It also considers maximum parser recursion depth, avoiding stack overflows Fixed: chromium:1180573 Change-Id: I8c1c62c68e24a564e0e4e7d0de9f5a3fa7032369 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42222 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
6d612ad478
commit
03eaff3b0a
|
@ -2136,6 +2136,7 @@ Maybe<ast::Expression*> ParserImpl::primary_expression() {
|
|||
Maybe<ast::Expression*> ParserImpl::postfix_expr(ast::Expression* prefix) {
|
||||
Source source;
|
||||
if (match(Token::Type::kBracketLeft, &source)) {
|
||||
return sync(Token::Type::kBracketRight, [&]() -> Maybe<ast::Expression*> {
|
||||
auto param = logical_or_expression();
|
||||
if (param.errored)
|
||||
return Failure::kErrored;
|
||||
|
@ -2147,9 +2148,11 @@ Maybe<ast::Expression*> ParserImpl::postfix_expr(ast::Expression* prefix) {
|
|||
|
||||
return postfix_expr(
|
||||
create<ast::ArrayAccessorExpression>(source, prefix, param.value));
|
||||
});
|
||||
}
|
||||
|
||||
if (match(Token::Type::kParenLeft, &source)) {
|
||||
return sync(Token::Type::kParenRight, [&]() -> Maybe<ast::Expression*> {
|
||||
ast::ExpressionList params;
|
||||
|
||||
auto t = peek();
|
||||
|
@ -2164,6 +2167,7 @@ Maybe<ast::Expression*> ParserImpl::postfix_expr(ast::Expression* prefix) {
|
|||
return Failure::kErrored;
|
||||
|
||||
return postfix_expr(create<ast::CallExpression>(source, prefix, params));
|
||||
});
|
||||
}
|
||||
|
||||
if (match(Token::Type::kPeriod)) {
|
||||
|
|
Loading…
Reference in New Issue