diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn index 20134a908b..3290694f62 100644 --- a/src/tint/BUILD.gn +++ b/src/tint/BUILD.gn @@ -1369,7 +1369,7 @@ if (tint_build_unittests) { "reader/wgsl/parser_impl_loop_stmt_test.cc", "reader/wgsl/parser_impl_multiplicative_expression_test.cc", "reader/wgsl/parser_impl_param_list_test.cc", - "reader/wgsl/parser_impl_paren_rhs_stmt_test.cc", + "reader/wgsl/parser_impl_paren_expression_test.cc", "reader/wgsl/parser_impl_pipeline_stage_test.cc", "reader/wgsl/parser_impl_primary_expression_test.cc", "reader/wgsl/parser_impl_relational_expression_test.cc", diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt index 312aa5218c..8f8f19c343 100644 --- a/src/tint/CMakeLists.txt +++ b/src/tint/CMakeLists.txt @@ -966,7 +966,7 @@ if(TINT_BUILD_TESTS) reader/wgsl/parser_impl_loop_stmt_test.cc reader/wgsl/parser_impl_multiplicative_expression_test.cc reader/wgsl/parser_impl_param_list_test.cc - reader/wgsl/parser_impl_paren_rhs_stmt_test.cc + reader/wgsl/parser_impl_paren_expression_test.cc reader/wgsl/parser_impl_pipeline_stage_test.cc reader/wgsl/parser_impl_primary_expression_test.cc reader/wgsl/parser_impl_relational_expression_test.cc diff --git a/src/tint/reader/wgsl/parser_impl.cc b/src/tint/reader/wgsl/parser_impl.cc index a490a5ca1a..8b4bc52fd3 100644 --- a/src/tint/reader/wgsl/parser_impl.cc +++ b/src/tint/reader/wgsl/parser_impl.cc @@ -1567,9 +1567,9 @@ Expect ParserImpl::expect_body_stmt() { }); } -// paren_rhs_stmt +// paren_expression // : PAREN_LEFT logical_or_expression PAREN_RIGHT -Expect ParserImpl::expect_paren_rhs_stmt() { +Expect ParserImpl::expect_paren_expression() { return expect_paren_block("", [&]() -> Expect { auto expr = logical_or_expression(); if (expr.errored) { @@ -1963,7 +1963,7 @@ Maybe ParserImpl::if_stmt() { } // switch_stmt -// : SWITCH paren_rhs_stmt BRACKET_LEFT switch_body+ BRACKET_RIGHT +// : SWITCH paren_expression BRACKET_LEFT switch_body+ BRACKET_RIGHT Maybe ParserImpl::switch_stmt() { Source source; if (!match(Token::Type::kSwitch, &source)) { @@ -2325,8 +2325,8 @@ Maybe ParserImpl::continuing_stmt() { // : IDENT argument_expression_list? // | type_decl argument_expression_list // | const_literal -// | paren_rhs_stmt -// | BITCAST LESS_THAN type_decl GREATER_THAN paren_rhs_stmt +// | paren_expression +// | BITCAST LESS_THAN type_decl GREATER_THAN paren_expression Maybe ParserImpl::primary_expression() { auto t = peek(); auto source = t.source(); @@ -2340,7 +2340,7 @@ Maybe ParserImpl::primary_expression() { } if (t.Is(Token::Type::kParenLeft)) { - auto paren = expect_paren_rhs_stmt(); + auto paren = expect_paren_expression(); if (paren.errored) { return Failure::kErrored; } @@ -2356,7 +2356,7 @@ Maybe ParserImpl::primary_expression() { return Failure::kErrored; } - auto params = expect_paren_rhs_stmt(); + auto params = expect_paren_expression(); if (params.errored) { return Failure::kErrored; } diff --git a/src/tint/reader/wgsl/parser_impl.h b/src/tint/reader/wgsl/parser_impl.h index 5857454e18..a9c0423d5a 100644 --- a/src/tint/reader/wgsl/parser_impl.h +++ b/src/tint/reader/wgsl/parser_impl.h @@ -476,9 +476,9 @@ class ParserImpl { /// Parses a `body_stmt` grammar element, erroring on parse failure. /// @returns the parsed statements Expect expect_body_stmt(); - /// Parses a `paren_rhs_stmt` grammar element, erroring on parse failure. + /// Parses a `paren_expression` grammar element, erroring on parse failure. /// @returns the parsed element or nullptr - Expect expect_paren_rhs_stmt(); + Expect expect_paren_expression(); /// Parses a `statements` grammar element /// @returns the statements parsed Expect expect_statements(); diff --git a/src/tint/reader/wgsl/parser_impl_paren_rhs_stmt_test.cc b/src/tint/reader/wgsl/parser_impl_paren_expression_test.cc similarity index 90% rename from src/tint/reader/wgsl/parser_impl_paren_rhs_stmt_test.cc rename to src/tint/reader/wgsl/parser_impl_paren_expression_test.cc index dd5a978bbe..e6bb2236ef 100644 --- a/src/tint/reader/wgsl/parser_impl_paren_rhs_stmt_test.cc +++ b/src/tint/reader/wgsl/parser_impl_paren_expression_test.cc @@ -19,7 +19,7 @@ namespace { TEST_F(ParserImplTest, ParenRhsStmt) { auto p = parser("(a + b)"); - auto e = p->expect_paren_rhs_stmt(); + auto e = p->expect_paren_expression(); ASSERT_FALSE(p->has_error()) << p->error(); ASSERT_FALSE(e.errored); ASSERT_NE(e.value, nullptr); @@ -28,7 +28,7 @@ TEST_F(ParserImplTest, ParenRhsStmt) { TEST_F(ParserImplTest, ParenRhsStmt_MissingLeftParen) { auto p = parser("true)"); - auto e = p->expect_paren_rhs_stmt(); + auto e = p->expect_paren_expression(); ASSERT_TRUE(p->has_error()); ASSERT_TRUE(e.errored); ASSERT_EQ(e.value, nullptr); @@ -37,7 +37,7 @@ TEST_F(ParserImplTest, ParenRhsStmt_MissingLeftParen) { TEST_F(ParserImplTest, ParenRhsStmt_MissingRightParen) { auto p = parser("(true"); - auto e = p->expect_paren_rhs_stmt(); + auto e = p->expect_paren_expression(); ASSERT_TRUE(p->has_error()); ASSERT_TRUE(e.errored); ASSERT_EQ(e.value, nullptr); @@ -46,7 +46,7 @@ TEST_F(ParserImplTest, ParenRhsStmt_MissingRightParen) { TEST_F(ParserImplTest, ParenRhsStmt_InvalidExpression) { auto p = parser("(if (a() {})"); - auto e = p->expect_paren_rhs_stmt(); + auto e = p->expect_paren_expression(); ASSERT_TRUE(p->has_error()); ASSERT_TRUE(e.errored); ASSERT_EQ(e.value, nullptr); @@ -55,7 +55,7 @@ TEST_F(ParserImplTest, ParenRhsStmt_InvalidExpression) { TEST_F(ParserImplTest, ParenRhsStmt_MissingExpression) { auto p = parser("()"); - auto e = p->expect_paren_rhs_stmt(); + auto e = p->expect_paren_expression(); ASSERT_TRUE(p->has_error()); ASSERT_TRUE(e.errored); ASSERT_EQ(e.value, nullptr);