wsgl parser: Use expect() for call r-parenthesis
Keeps error message consistent. Reduces code. Bug: tint:282 Change-Id: Ibbbb98bb6f080dd338af7de415c6e86298d910e3 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31730 Commit-Queue: Ben Clayton <bclayton@google.com> Commit-Queue: dan sinclair <dsinclair@chromium.org> Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
67c37197d6
commit
443039a58f
|
@ -2587,11 +2587,8 @@ std::unique_ptr<ast::CallStatement> ParserImpl::func_call_stmt() {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
t = next();
|
if (!expect("call statement", Token::Type::kParenRight))
|
||||||
if (!t.IsParenRight()) {
|
|
||||||
add_error(t, "missing ) for call statement");
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
|
||||||
|
|
||||||
return std::make_unique<ast::CallStatement>(
|
return std::make_unique<ast::CallStatement>(
|
||||||
std::make_unique<ast::CallExpression>(
|
std::make_unique<ast::CallExpression>(
|
||||||
|
@ -2763,11 +2760,9 @@ std::unique_ptr<ast::Expression> ParserImpl::postfix_expr(
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
t = next();
|
if (!expect("call expression", Token::Type::kParenRight))
|
||||||
if (!t.IsParenRight()) {
|
|
||||||
add_error(t, "missing ) for call expression");
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
|
||||||
expr = std::make_unique<ast::CallExpression>(source, std::move(prefix),
|
expr = std::make_unique<ast::CallExpression>(source, std::move(prefix),
|
||||||
std::move(params));
|
std::move(params));
|
||||||
} else if (t.IsPeriod()) {
|
} else if (t.IsPeriod()) {
|
||||||
|
|
|
@ -63,7 +63,7 @@ TEST_F(ParserImplTest, Statement_Call_Missing_RightParen) {
|
||||||
auto* p = parser("a(");
|
auto* p = parser("a(");
|
||||||
auto e = p->statement();
|
auto e = p->statement();
|
||||||
ASSERT_TRUE(p->has_error());
|
ASSERT_TRUE(p->has_error());
|
||||||
EXPECT_EQ(p->error(), "1:3: missing ) for call statement");
|
EXPECT_EQ(p->error(), "1:3: expected ')' for call statement");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, Statement_Call_Missing_Semi) {
|
TEST_F(ParserImplTest, Statement_Call_Missing_Semi) {
|
||||||
|
@ -77,7 +77,7 @@ TEST_F(ParserImplTest, Statement_Call_Bad_ArgList) {
|
||||||
auto* p = parser("a(b c);");
|
auto* p = parser("a(b c);");
|
||||||
auto e = p->statement();
|
auto e = p->statement();
|
||||||
ASSERT_TRUE(p->has_error());
|
ASSERT_TRUE(p->has_error());
|
||||||
EXPECT_EQ(p->error(), "1:5: missing ) for call statement");
|
EXPECT_EQ(p->error(), "1:5: expected ')' for call statement");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -119,14 +119,14 @@ TEST_F(ParserImplErrorTest, BreakStmtMissingSemicolon) {
|
||||||
|
|
||||||
TEST_F(ParserImplErrorTest, CallExprMissingRParen) {
|
TEST_F(ParserImplErrorTest, CallExprMissingRParen) {
|
||||||
EXPECT("fn f() -> void { x = f(1.; }",
|
EXPECT("fn f() -> void { x = f(1.; }",
|
||||||
"test.wgsl:1:26 error: missing ) for call expression\n"
|
"test.wgsl:1:26 error: expected ')' for call expression\n"
|
||||||
"fn f() -> void { x = f(1.; }\n"
|
"fn f() -> void { x = f(1.; }\n"
|
||||||
" ^\n");
|
" ^\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplErrorTest, CallStmtMissingRParen) {
|
TEST_F(ParserImplErrorTest, CallStmtMissingRParen) {
|
||||||
EXPECT("fn f() -> void { f(1.; }",
|
EXPECT("fn f() -> void { f(1.; }",
|
||||||
"test.wgsl:1:22 error: missing ) for call statement\n"
|
"test.wgsl:1:22 error: expected ')' for call statement\n"
|
||||||
"fn f() -> void { f(1.; }\n"
|
"fn f() -> void { f(1.; }\n"
|
||||||
" ^\n");
|
" ^\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,7 +144,7 @@ TEST_F(ParserImplTest, PostfixExpression_Call_MissingRightParen) {
|
||||||
auto e = p->postfix_expression();
|
auto e = p->postfix_expression();
|
||||||
ASSERT_TRUE(p->has_error());
|
ASSERT_TRUE(p->has_error());
|
||||||
ASSERT_EQ(e, nullptr);
|
ASSERT_EQ(e, nullptr);
|
||||||
EXPECT_EQ(p->error(), "1:3: missing ) for call expression");
|
EXPECT_EQ(p->error(), "1:3: expected ')' for call expression");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, PostfixExpression_MemberAccessor) {
|
TEST_F(ParserImplTest, PostfixExpression_MemberAccessor) {
|
||||||
|
|
Loading…
Reference in New Issue