diff --git a/src/tint/reader/wgsl/parser_impl.cc b/src/tint/reader/wgsl/parser_impl.cc index b2b9a03164..c0ea04bc3b 100644 --- a/src/tint/reader/wgsl/parser_impl.cc +++ b/src/tint/reader/wgsl/parser_impl.cc @@ -2577,7 +2577,7 @@ Maybe ParserImpl::exclusive_or_expression() { Expect ParserImpl::expect_inclusive_or_expr(const ast::Expression* lhs) { while (continue_parsing()) { Source source; - if (!match(Token::Type::kOr)) + if (!match(Token::Type::kOr, &source)) return lhs; auto rhs = exclusive_or_expression(); @@ -2644,7 +2644,7 @@ Maybe ParserImpl::logical_and_expression() { Expect ParserImpl::expect_logical_or_expr(const ast::Expression* lhs) { while (continue_parsing()) { Source source; - if (!match(Token::Type::kOrOr)) + if (!match(Token::Type::kOrOr, &source)) return lhs; auto rhs = logical_and_expression(); diff --git a/src/tint/reader/wgsl/parser_impl_additive_expression_test.cc b/src/tint/reader/wgsl/parser_impl_additive_expression_test.cc index 51cf90ea00..4573b84f03 100644 --- a/src/tint/reader/wgsl/parser_impl_additive_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_additive_expression_test.cc @@ -25,6 +25,11 @@ TEST_F(ParserImplTest, AdditiveExpression_Parses_Plus) { EXPECT_FALSE(p->has_error()) << p->error(); ASSERT_NE(e.value, nullptr); + EXPECT_EQ(e->source.range.begin.line, 1u); + EXPECT_EQ(e->source.range.begin.column, 3u); + EXPECT_EQ(e->source.range.end.line, 1u); + EXPECT_EQ(e->source.range.end.column, 4u); + ASSERT_TRUE(e->Is()); auto* rel = e->As(); EXPECT_EQ(ast::BinaryOp::kAdd, rel->op); diff --git a/src/tint/reader/wgsl/parser_impl_and_expression_test.cc b/src/tint/reader/wgsl/parser_impl_and_expression_test.cc index 1ed8a9cd4a..fd90460124 100644 --- a/src/tint/reader/wgsl/parser_impl_and_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_and_expression_test.cc @@ -25,6 +25,11 @@ TEST_F(ParserImplTest, AndExpression_Parses) { EXPECT_FALSE(p->has_error()) << p->error(); ASSERT_NE(e.value, nullptr); + EXPECT_EQ(e->source.range.begin.line, 1u); + EXPECT_EQ(e->source.range.begin.column, 3u); + EXPECT_EQ(e->source.range.end.line, 1u); + EXPECT_EQ(e->source.range.end.column, 4u); + ASSERT_TRUE(e->Is()); auto* rel = e->As(); EXPECT_EQ(ast::BinaryOp::kAnd, rel->op); diff --git a/src/tint/reader/wgsl/parser_impl_equality_expression_test.cc b/src/tint/reader/wgsl/parser_impl_equality_expression_test.cc index 4e1f5a3f8d..158227d833 100644 --- a/src/tint/reader/wgsl/parser_impl_equality_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_equality_expression_test.cc @@ -25,6 +25,11 @@ TEST_F(ParserImplTest, EqualityExpression_Parses_Equal) { EXPECT_FALSE(p->has_error()) << p->error(); ASSERT_NE(e.value, nullptr); + EXPECT_EQ(e->source.range.begin.line, 1u); + EXPECT_EQ(e->source.range.begin.column, 3u); + EXPECT_EQ(e->source.range.end.line, 1u); + EXPECT_EQ(e->source.range.end.column, 5u); + ASSERT_TRUE(e->Is()); auto* rel = e->As(); EXPECT_EQ(ast::BinaryOp::kEqual, rel->op); @@ -45,6 +50,11 @@ TEST_F(ParserImplTest, EqualityExpression_Parses_NotEqual) { EXPECT_FALSE(p->has_error()) << p->error(); ASSERT_NE(e.value, nullptr); + EXPECT_EQ(e->source.range.begin.line, 1u); + EXPECT_EQ(e->source.range.begin.column, 3u); + EXPECT_EQ(e->source.range.end.line, 1u); + EXPECT_EQ(e->source.range.end.column, 5u); + ASSERT_TRUE(e->Is()); auto* rel = e->As(); EXPECT_EQ(ast::BinaryOp::kNotEqual, rel->op); diff --git a/src/tint/reader/wgsl/parser_impl_exclusive_or_expression_test.cc b/src/tint/reader/wgsl/parser_impl_exclusive_or_expression_test.cc index c6f8ad48ce..2994ae8eca 100644 --- a/src/tint/reader/wgsl/parser_impl_exclusive_or_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_exclusive_or_expression_test.cc @@ -25,6 +25,11 @@ TEST_F(ParserImplTest, ExclusiveOrExpression_Parses) { EXPECT_FALSE(p->has_error()) << p->error(); ASSERT_NE(e.value, nullptr); + EXPECT_EQ(e->source.range.begin.line, 1u); + EXPECT_EQ(e->source.range.begin.column, 3u); + EXPECT_EQ(e->source.range.end.line, 1u); + EXPECT_EQ(e->source.range.end.column, 4u); + ASSERT_TRUE(e->Is()); auto* rel = e->As(); EXPECT_EQ(ast::BinaryOp::kXor, rel->op); diff --git a/src/tint/reader/wgsl/parser_impl_inclusive_or_expression_test.cc b/src/tint/reader/wgsl/parser_impl_inclusive_or_expression_test.cc index 83b9358c07..f534ff7991 100644 --- a/src/tint/reader/wgsl/parser_impl_inclusive_or_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_inclusive_or_expression_test.cc @@ -25,6 +25,11 @@ TEST_F(ParserImplTest, InclusiveOrExpression_Parses) { EXPECT_FALSE(p->has_error()) << p->error(); ASSERT_NE(e.value, nullptr); + EXPECT_EQ(e->source.range.begin.line, 1u); + EXPECT_EQ(e->source.range.begin.column, 3u); + EXPECT_EQ(e->source.range.end.line, 1u); + EXPECT_EQ(e->source.range.end.column, 4u); + ASSERT_TRUE(e->Is()); auto* rel = e->As(); EXPECT_EQ(ast::BinaryOp::kOr, rel->op); diff --git a/src/tint/reader/wgsl/parser_impl_logical_and_expression_test.cc b/src/tint/reader/wgsl/parser_impl_logical_and_expression_test.cc index 57624a5e64..8baadaf7cf 100644 --- a/src/tint/reader/wgsl/parser_impl_logical_and_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_logical_and_expression_test.cc @@ -25,6 +25,11 @@ TEST_F(ParserImplTest, LogicalAndExpression_Parses) { EXPECT_FALSE(p->has_error()) << p->error(); ASSERT_NE(e.value, nullptr); + EXPECT_EQ(e->source.range.begin.line, 1u); + EXPECT_EQ(e->source.range.begin.column, 3u); + EXPECT_EQ(e->source.range.end.line, 1u); + EXPECT_EQ(e->source.range.end.column, 5u); + ASSERT_TRUE(e->Is()); auto* rel = e->As(); EXPECT_EQ(ast::BinaryOp::kLogicalAnd, rel->op); diff --git a/src/tint/reader/wgsl/parser_impl_logical_or_expression_test.cc b/src/tint/reader/wgsl/parser_impl_logical_or_expression_test.cc index 6bde6bd5c1..943b059321 100644 --- a/src/tint/reader/wgsl/parser_impl_logical_or_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_logical_or_expression_test.cc @@ -25,6 +25,11 @@ TEST_F(ParserImplTest, LogicalOrExpression_Parses) { EXPECT_FALSE(p->has_error()) << p->error(); ASSERT_NE(e.value, nullptr); + EXPECT_EQ(e->source.range.begin.line, 1u); + EXPECT_EQ(e->source.range.begin.column, 3u); + EXPECT_EQ(e->source.range.end.line, 1u); + EXPECT_EQ(e->source.range.end.column, 5u); + ASSERT_TRUE(e->Is()); auto* rel = e->As(); EXPECT_EQ(ast::BinaryOp::kLogicalOr, rel->op); diff --git a/src/tint/reader/wgsl/parser_impl_multiplicative_expression_test.cc b/src/tint/reader/wgsl/parser_impl_multiplicative_expression_test.cc index 6d77fd5dab..28ac568d19 100644 --- a/src/tint/reader/wgsl/parser_impl_multiplicative_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_multiplicative_expression_test.cc @@ -25,6 +25,11 @@ TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Multiply) { EXPECT_FALSE(p->has_error()) << p->error(); ASSERT_NE(e.value, nullptr); + EXPECT_EQ(e->source.range.begin.line, 1u); + EXPECT_EQ(e->source.range.begin.column, 3u); + EXPECT_EQ(e->source.range.end.line, 1u); + EXPECT_EQ(e->source.range.end.column, 4u); + ASSERT_TRUE(e->Is()); auto* rel = e->As(); EXPECT_EQ(ast::BinaryOp::kMultiply, rel->op); diff --git a/src/tint/reader/wgsl/parser_impl_relational_expression_test.cc b/src/tint/reader/wgsl/parser_impl_relational_expression_test.cc index 725761b9a4..7ad161f94b 100644 --- a/src/tint/reader/wgsl/parser_impl_relational_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_relational_expression_test.cc @@ -25,6 +25,11 @@ TEST_F(ParserImplTest, RelationalExpression_Parses_LessThan) { EXPECT_FALSE(p->has_error()) << p->error(); ASSERT_NE(e.value, nullptr); + EXPECT_EQ(e->source.range.begin.line, 1u); + EXPECT_EQ(e->source.range.begin.column, 3u); + EXPECT_EQ(e->source.range.end.line, 1u); + EXPECT_EQ(e->source.range.end.column, 4u); + ASSERT_TRUE(e->Is()); auto* rel = e->As(); EXPECT_EQ(ast::BinaryOp::kLessThan, rel->op); @@ -45,6 +50,11 @@ TEST_F(ParserImplTest, RelationalExpression_Parses_GreaterThan) { EXPECT_FALSE(p->has_error()) << p->error(); ASSERT_NE(e.value, nullptr); + EXPECT_EQ(e->source.range.begin.line, 1u); + EXPECT_EQ(e->source.range.begin.column, 3u); + EXPECT_EQ(e->source.range.end.line, 1u); + EXPECT_EQ(e->source.range.end.column, 4u); + ASSERT_TRUE(e->Is()); auto* rel = e->As(); EXPECT_EQ(ast::BinaryOp::kGreaterThan, rel->op); @@ -65,6 +75,11 @@ TEST_F(ParserImplTest, RelationalExpression_Parses_LessThanEqual) { EXPECT_FALSE(p->has_error()) << p->error(); ASSERT_NE(e.value, nullptr); + EXPECT_EQ(e->source.range.begin.line, 1u); + EXPECT_EQ(e->source.range.begin.column, 3u); + EXPECT_EQ(e->source.range.end.line, 1u); + EXPECT_EQ(e->source.range.end.column, 5u); + ASSERT_TRUE(e->Is()); auto* rel = e->As(); EXPECT_EQ(ast::BinaryOp::kLessThanEqual, rel->op); @@ -85,6 +100,11 @@ TEST_F(ParserImplTest, RelationalExpression_Parses_GreaterThanEqual) { EXPECT_FALSE(p->has_error()) << p->error(); ASSERT_NE(e.value, nullptr); + EXPECT_EQ(e->source.range.begin.line, 1u); + EXPECT_EQ(e->source.range.begin.column, 3u); + EXPECT_EQ(e->source.range.end.line, 1u); + EXPECT_EQ(e->source.range.end.column, 5u); + ASSERT_TRUE(e->Is()); auto* rel = e->As(); EXPECT_EQ(ast::BinaryOp::kGreaterThanEqual, rel->op); diff --git a/src/tint/reader/wgsl/parser_impl_shift_expression_test.cc b/src/tint/reader/wgsl/parser_impl_shift_expression_test.cc index fd612b5f4b..83c1255e9d 100644 --- a/src/tint/reader/wgsl/parser_impl_shift_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_shift_expression_test.cc @@ -25,6 +25,11 @@ TEST_F(ParserImplTest, ShiftExpression_Parses_ShiftLeft) { EXPECT_FALSE(p->has_error()) << p->error(); ASSERT_NE(e.value, nullptr); + EXPECT_EQ(e->source.range.begin.line, 1u); + EXPECT_EQ(e->source.range.begin.column, 3u); + EXPECT_EQ(e->source.range.end.line, 1u); + EXPECT_EQ(e->source.range.end.column, 5u); + ASSERT_TRUE(e->Is()); auto* rel = e->As(); EXPECT_EQ(ast::BinaryOp::kShiftLeft, rel->op); @@ -45,6 +50,11 @@ TEST_F(ParserImplTest, ShiftExpression_Parses_ShiftRight) { EXPECT_FALSE(p->has_error()) << p->error(); ASSERT_NE(e.value, nullptr); + EXPECT_EQ(e->source.range.begin.line, 1u); + EXPECT_EQ(e->source.range.begin.column, 3u); + EXPECT_EQ(e->source.range.end.line, 1u); + EXPECT_EQ(e->source.range.end.column, 5u); + ASSERT_TRUE(e->Is()); auto* rel = e->As(); EXPECT_EQ(ast::BinaryOp::kShiftRight, rel->op);