Drop `maybe_` from method names.

With the old grammar elements removed, rename the new elements and
drop the `maybe_` prefixes.

Bug: tint:1633
Change-Id: Iafe223546f8af1ddd8a4b60572a106160a226b72
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99921
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
dan sinclair 2022-08-24 19:11:55 +00:00 committed by Dawn LUCI CQ
parent 202362f47d
commit 436b4a2bd0
5 changed files with 46 additions and 46 deletions

View File

@ -579,7 +579,7 @@ Maybe<const ast::Variable*> ParserImpl::global_variable_decl(AttributeList& attr
const ast::Expression* initializer = nullptr;
if (match(Token::Type::kEqual)) {
auto expr = maybe_expression();
auto expr = expression();
if (expr.errored) {
return Failure::kErrored;
}
@ -639,7 +639,7 @@ Maybe<const ast::Variable*> ParserImpl::global_constant_decl(AttributeList& attr
const ast::Expression* initializer = nullptr;
if (has_initializer) {
auto expr = maybe_expression();
auto expr = expression();
if (expr.errored) {
return Failure::kErrored;
}
@ -1426,7 +1426,7 @@ Maybe<const ast::StaticAssert*> ParserImpl::static_assert_statement() {
return Failure::kNoMatch;
}
auto condition = maybe_expression();
auto condition = expression();
if (condition.errored) {
return Failure::kErrored;
}
@ -1691,7 +1691,7 @@ Expect<ast::BlockStatement*> ParserImpl::expect_compound_statement() {
// : PAREN_LEFT expression PAREN_RIGHT
Expect<const ast::Expression*> ParserImpl::expect_paren_expression() {
return expect_paren_block("", [&]() -> Expect<const ast::Expression*> {
auto expr = maybe_expression();
auto expr = expression();
if (expr.errored) {
return Failure::kErrored;
}
@ -1895,7 +1895,7 @@ Maybe<const ast::ReturnStatement*> ParserImpl::return_statement() {
return create<ast::ReturnStatement>(source, nullptr);
}
auto expr = maybe_expression();
auto expr = expression();
if (expr.errored) {
return Failure::kErrored;
}
@ -1920,7 +1920,7 @@ Maybe<const ast::VariableDeclStatement*> ParserImpl::variable_statement() {
return Failure::kErrored;
}
auto initializer = maybe_expression();
auto initializer = expression();
if (initializer.errored) {
return Failure::kErrored;
}
@ -1947,7 +1947,7 @@ Maybe<const ast::VariableDeclStatement*> ParserImpl::variable_statement() {
return Failure::kErrored;
}
auto initializer = maybe_expression();
auto initializer = expression();
if (initializer.errored) {
return Failure::kErrored;
}
@ -1974,7 +1974,7 @@ Maybe<const ast::VariableDeclStatement*> ParserImpl::variable_statement() {
const ast::Expression* initializer = nullptr;
if (match(Token::Type::kEqual)) {
auto initializer_expr = maybe_expression();
auto initializer_expr = expression();
if (initializer_expr.errored) {
return Failure::kErrored;
}
@ -2018,7 +2018,7 @@ Maybe<const ast::IfStatement*> ParserImpl::if_statement() {
return Failure::kNoMatch;
}
auto condition = maybe_expression();
auto condition = expression();
if (condition.errored) {
return Failure::kErrored;
}
@ -2086,7 +2086,7 @@ Maybe<const ast::SwitchStatement*> ParserImpl::switch_statement() {
return Failure::kNoMatch;
}
auto condition = maybe_expression();
auto condition = expression();
if (condition.errored) {
return Failure::kErrored;
}
@ -2319,7 +2319,7 @@ Expect<std::unique_ptr<ForHeader>> ParserImpl::expect_for_header() {
return Failure::kErrored;
}
auto condition = maybe_expression();
auto condition = expression();
if (condition.errored) {
return Failure::kErrored;
}
@ -2367,7 +2367,7 @@ Maybe<const ast::WhileStatement*> ParserImpl::while_statement() {
return Failure::kNoMatch;
}
auto condition = maybe_expression();
auto condition = expression();
if (condition.errored) {
return Failure::kErrored;
}
@ -2601,7 +2601,7 @@ Maybe<const ast::Expression*> ParserImpl::postfix_expression(const ast::Expressi
while (continue_parsing()) {
if (match(Token::Type::kBracketLeft, &source)) {
auto res = sync(Token::Type::kBracketRight, [&]() -> Maybe<const ast::Expression*> {
auto param = maybe_expression();
auto param = expression();
if (param.errored) {
return Failure::kErrored;
}
@ -2649,7 +2649,7 @@ Expect<ParserImpl::ExpressionList> ParserImpl::expect_argument_expression_list(
return expect_paren_block(use, [&]() -> Expect<ExpressionList> {
ExpressionList ret;
while (continue_parsing()) {
auto arg = maybe_expression();
auto arg = expression();
if (arg.errored) {
return Failure::kErrored;
} else if (!arg.matched) {
@ -2881,7 +2881,7 @@ Maybe<const ast::Expression*> ParserImpl::element_count_expression() {
// shift_expression
// : unary_expression shift_expression.post.unary_expression
Maybe<const ast::Expression*> ParserImpl::maybe_shift_expression() {
Maybe<const ast::Expression*> ParserImpl::shift_expression() {
auto lhs = unary_expression();
if (lhs.errored) {
return Failure::kErrored;
@ -2930,7 +2930,7 @@ Expect<const ast::Expression*> ParserImpl::expect_shift_expression_post_unary_ex
// relational_expression
// : unary_expression relational_expression.post.unary_expression
Maybe<const ast::Expression*> ParserImpl::maybe_relational_expression() {
Maybe<const ast::Expression*> ParserImpl::relational_expression() {
auto lhs = unary_expression();
if (lhs.errored) {
return Failure::kErrored;
@ -2979,7 +2979,7 @@ Expect<const ast::Expression*> ParserImpl::expect_relational_expression_post_una
}
auto& next = peek();
auto rhs = maybe_shift_expression();
auto rhs = shift_expression();
if (rhs.errored) {
return Failure::kErrored;
}
@ -3001,7 +3001,7 @@ Expect<const ast::Expression*> ParserImpl::expect_relational_expression_post_una
// relational_expression ( or_or relational_expression )*
//
// Note, a `relational_expression` element was added to simplify many of the right sides
Maybe<const ast::Expression*> ParserImpl::maybe_expression() {
Maybe<const ast::Expression*> ParserImpl::expression() {
auto lhs = unary_expression();
if (lhs.errored) {
return Failure::kErrored;
@ -3045,7 +3045,7 @@ Maybe<const ast::Expression*> ParserImpl::maybe_expression() {
}
next();
auto rhs = maybe_relational_expression();
auto rhs = relational_expression();
if (rhs.errored) {
return Failure::kErrored;
}
@ -3305,7 +3305,7 @@ Maybe<const ast::Statement*> ParserImpl::variable_updating_statement() {
}
}
auto rhs = maybe_expression();
auto rhs = expression();
if (rhs.errored) {
return Failure::kErrored;
}

View File

@ -623,7 +623,7 @@ class ParserImpl {
Maybe<const ast::Expression*> unary_expression();
/// Parses the `expression` grammar rule
/// @returns the parsed expression or nullptr
Maybe<const ast::Expression*> maybe_expression();
Maybe<const ast::Expression*> expression();
/// Parses the `bitwise_expression.post.unary_expression` grammar element
/// @param lhs the left side of the expression
/// @returns the parsed expression or nullptr
@ -652,7 +652,7 @@ class ParserImpl {
Maybe<const ast::Expression*> element_count_expression();
/// Parses a `unary_expression shift.post.unary_expression`
/// @returns the parsed expression or nullptr
Maybe<const ast::Expression*> maybe_shift_expression();
Maybe<const ast::Expression*> shift_expression();
/// Parses a `shift_expression.post.unary_expression` grammar element
/// @param lhs the left side of the expression
/// @returns the parsed expression or `lhs` if no match
@ -660,7 +660,7 @@ class ParserImpl {
const ast::Expression* lhs);
/// Parses a `unary_expression relational_expression.post.unary_expression`
/// @returns the parsed expression or nullptr
Maybe<const ast::Expression*> maybe_relational_expression();
Maybe<const ast::Expression*> relational_expression();
/// Parses a `relational_expression.post.unary_expression` grammar element
/// @param lhs the left side of the expression
/// @returns the parsed expression or `lhs` if no match

View File

@ -19,7 +19,7 @@ namespace {
TEST_F(ParserImplTest, Expression_InvalidLHS) {
auto p = parser("if (a) {} || true");
auto e = p->maybe_expression();
auto e = p->expression();
EXPECT_FALSE(e.matched);
EXPECT_FALSE(e.errored);
EXPECT_FALSE(p->has_error()) << p->error();
@ -28,7 +28,7 @@ TEST_F(ParserImplTest, Expression_InvalidLHS) {
TEST_F(ParserImplTest, Expression_Or_Parses) {
auto p = parser("a || true");
auto e = p->maybe_expression();
auto e = p->expression();
EXPECT_TRUE(e.matched);
EXPECT_FALSE(e.errored);
EXPECT_FALSE(p->has_error()) << p->error();
@ -53,7 +53,7 @@ TEST_F(ParserImplTest, Expression_Or_Parses) {
TEST_F(ParserImplTest, Expression_Or_Parses_Multiple) {
auto p = parser("a || true || b");
auto e = p->maybe_expression();
auto e = p->expression();
EXPECT_TRUE(e.matched);
EXPECT_FALSE(e.errored);
EXPECT_FALSE(p->has_error()) << p->error();
@ -85,7 +85,7 @@ TEST_F(ParserImplTest, Expression_Or_Parses_Multiple) {
TEST_F(ParserImplTest, Expression_Or_InvalidRHS) {
auto p = parser("true || if (a) {}");
auto e = p->maybe_expression();
auto e = p->expression();
EXPECT_FALSE(e.matched);
EXPECT_TRUE(e.errored);
EXPECT_EQ(e.value, nullptr);
@ -95,7 +95,7 @@ TEST_F(ParserImplTest, Expression_Or_InvalidRHS) {
TEST_F(ParserImplTest, Expression_And_Parses) {
auto p = parser("a && true");
auto e = p->maybe_expression();
auto e = p->expression();
EXPECT_TRUE(e.matched);
EXPECT_FALSE(e.errored);
EXPECT_FALSE(p->has_error()) << p->error();
@ -120,7 +120,7 @@ TEST_F(ParserImplTest, Expression_And_Parses) {
TEST_F(ParserImplTest, Expression_And_Parses_Multple) {
auto p = parser("a && true && b");
auto e = p->maybe_expression();
auto e = p->expression();
EXPECT_TRUE(e.matched);
EXPECT_FALSE(e.errored);
EXPECT_FALSE(p->has_error()) << p->error();
@ -150,7 +150,7 @@ TEST_F(ParserImplTest, Expression_And_Parses_Multple) {
TEST_F(ParserImplTest, Expression_And_InvalidRHS) {
auto p = parser("true && if (a) {}");
auto e = p->maybe_expression();
auto e = p->expression();
EXPECT_FALSE(e.matched);
EXPECT_TRUE(e.errored);
EXPECT_EQ(e.value, nullptr);
@ -160,7 +160,7 @@ TEST_F(ParserImplTest, Expression_And_InvalidRHS) {
TEST_F(ParserImplTest, Expression_Mixing_OrWithAnd) {
auto p = parser("a && true || b");
auto e = p->maybe_expression();
auto e = p->expression();
EXPECT_FALSE(e.matched);
EXPECT_TRUE(e.errored);
EXPECT_EQ(e.value, nullptr);
@ -170,7 +170,7 @@ TEST_F(ParserImplTest, Expression_Mixing_OrWithAnd) {
TEST_F(ParserImplTest, Expression_Mixing_AndWithOr) {
auto p = parser("a || true && b");
auto e = p->maybe_expression();
auto e = p->expression();
EXPECT_FALSE(e.matched);
EXPECT_TRUE(e.errored);
EXPECT_EQ(e.value, nullptr);
@ -180,7 +180,7 @@ TEST_F(ParserImplTest, Expression_Mixing_AndWithOr) {
TEST_F(ParserImplTest, Expression_Bitwise) {
auto p = parser("a & b");
auto e = p->maybe_expression();
auto e = p->expression();
EXPECT_TRUE(e.matched);
EXPECT_FALSE(e.errored);
EXPECT_FALSE(p->has_error()) << p->error();
@ -201,7 +201,7 @@ TEST_F(ParserImplTest, Expression_Bitwise) {
TEST_F(ParserImplTest, Expression_Relational) {
auto p = parser("a <= b");
auto e = p->maybe_expression();
auto e = p->expression();
EXPECT_TRUE(e.matched);
EXPECT_FALSE(e.errored);
EXPECT_FALSE(p->has_error()) << p->error();
@ -222,7 +222,7 @@ TEST_F(ParserImplTest, Expression_Relational) {
TEST_F(ParserImplTest, Expression_InvalidUnary) {
auto p = parser("!if || true");
auto e = p->maybe_expression();
auto e = p->expression();
EXPECT_FALSE(e.matched);
EXPECT_TRUE(e.errored);
EXPECT_EQ(e.value, nullptr);
@ -232,7 +232,7 @@ TEST_F(ParserImplTest, Expression_InvalidUnary) {
TEST_F(ParserImplTest, Expression_InvalidBitwise) {
auto p = parser("a & if");
auto e = p->maybe_expression();
auto e = p->expression();
EXPECT_FALSE(e.matched);
EXPECT_TRUE(e.errored);
EXPECT_EQ(e.value, nullptr);
@ -242,7 +242,7 @@ TEST_F(ParserImplTest, Expression_InvalidBitwise) {
TEST_F(ParserImplTest, Expression_InvalidRelational) {
auto p = parser("a <= if");
auto e = p->maybe_expression();
auto e = p->expression();
EXPECT_FALSE(e.matched);
EXPECT_TRUE(e.errored);
EXPECT_EQ(e.value, nullptr);

View File

@ -188,7 +188,7 @@ TEST_F(ParserImplTest, RelationalExpression_PostUnary_NoMatch_ReturnsLHS) {
TEST_F(ParserImplTest, RelationalExpression_Matches) {
auto p = parser("a >= true");
auto e = p->maybe_relational_expression();
auto e = p->relational_expression();
EXPECT_TRUE(e.matched);
EXPECT_FALSE(e.errored);
EXPECT_FALSE(p->has_error()) << p->error();
@ -208,7 +208,7 @@ TEST_F(ParserImplTest, RelationalExpression_Matches) {
TEST_F(ParserImplTest, RelationalExpression_InvalidLHS) {
auto p = parser("if (a) {}< 3");
auto e = p->maybe_relational_expression();
auto e = p->relational_expression();
ASSERT_FALSE(e.matched);
EXPECT_FALSE(e.errored);
ASSERT_FALSE(p->has_error()) << p->error();
@ -217,7 +217,7 @@ TEST_F(ParserImplTest, RelationalExpression_InvalidLHS) {
TEST_F(ParserImplTest, RelationalExpression_InvalidRHS) {
auto p = parser("true < if (a) {}");
auto e = p->maybe_relational_expression();
auto e = p->relational_expression();
ASSERT_FALSE(e.matched);
EXPECT_TRUE(e.errored);
ASSERT_TRUE(p->has_error());
@ -227,7 +227,7 @@ TEST_F(ParserImplTest, RelationalExpression_InvalidRHS) {
TEST_F(ParserImplTest, RelationalExpression_Parses_Equal) {
auto p = parser("a == true");
auto e = p->maybe_relational_expression();
auto e = p->relational_expression();
EXPECT_TRUE(e.matched);
EXPECT_FALSE(e.errored);
EXPECT_FALSE(p->has_error()) << p->error();
@ -252,7 +252,7 @@ TEST_F(ParserImplTest, RelationalExpression_Parses_Equal) {
TEST_F(ParserImplTest, RelationalExpression_Parses_NotEqual) {
auto p = parser("a != true");
auto e = p->maybe_relational_expression();
auto e = p->relational_expression();
EXPECT_TRUE(e.matched);
EXPECT_FALSE(e.errored);
EXPECT_FALSE(p->has_error()) << p->error();
@ -277,7 +277,7 @@ TEST_F(ParserImplTest, RelationalExpression_Parses_NotEqual) {
TEST_F(ParserImplTest, RelationalExpression_Equal_InvalidRHS) {
auto p = parser("true == if (a) {}");
auto e = p->maybe_relational_expression();
auto e = p->relational_expression();
EXPECT_FALSE(e.matched);
EXPECT_TRUE(e.errored);
EXPECT_EQ(e.value, nullptr);

View File

@ -149,7 +149,7 @@ TEST_F(ParserImplTest, ShiftExpression_PostUnary_NoOr_ReturnsLHS) {
TEST_F(ParserImplTest, ShiftExpression_Parses) {
auto p = parser("a << true");
auto e = p->maybe_shift_expression();
auto e = p->shift_expression();
EXPECT_TRUE(e.matched);
EXPECT_FALSE(e.errored);
EXPECT_FALSE(p->has_error()) << p->error();
@ -169,7 +169,7 @@ TEST_F(ParserImplTest, ShiftExpression_Parses) {
TEST_F(ParserImplTest, ShiftExpression_Invalid_Unary) {
auto p = parser("if >> true");
auto e = p->maybe_shift_expression();
auto e = p->shift_expression();
EXPECT_FALSE(e.matched);
EXPECT_FALSE(e.errored);
EXPECT_FALSE(p->has_error()) << p->error();
@ -178,7 +178,7 @@ TEST_F(ParserImplTest, ShiftExpression_Invalid_Unary) {
TEST_F(ParserImplTest, ShiftExpression_Inavlid_ShiftExpressionPostUnary) {
auto p = parser("a * if (a) {}");
auto e = p->maybe_shift_expression();
auto e = p->shift_expression();
EXPECT_FALSE(e.matched);
EXPECT_TRUE(e.errored);
EXPECT_TRUE(p->has_error());