From 7d2b192439cb4a0380a2eb60947540a79a157847 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Tue, 24 Jan 2023 19:31:51 +0000 Subject: [PATCH] tint: rename template argument token strings Drop the `(opening|closing template argument list)` bit. It makes for messy diagnostics. Change-Id: I92d29ece8a012362dd16da297089aab908571415 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117213 Commit-Queue: Ben Clayton Reviewed-by: Dan Sinclair Kokoro: Ben Clayton --- .../reader/wgsl/parser_impl_error_msg_test.cc | 30 ++++++++----------- .../wgsl/parser_impl_texture_sampler_test.cc | 9 ++---- .../reader/wgsl/parser_impl_type_decl_test.cc | 11 +++---- ...arser_impl_type_decl_without_ident_test.cc | 11 +++---- src/tint/reader/wgsl/token.cc | 2 -- 5 files changed, 23 insertions(+), 40 deletions(-) diff --git a/src/tint/reader/wgsl/parser_impl_error_msg_test.cc b/src/tint/reader/wgsl/parser_impl_error_msg_test.cc index ce3628811b..f458834c96 100644 --- a/src/tint/reader/wgsl/parser_impl_error_msg_test.cc +++ b/src/tint/reader/wgsl/parser_impl_error_msg_test.cc @@ -120,9 +120,8 @@ fn f() { a = >; } } TEST_F(ParserImplErrorTest, BitcastExprMissingLessThan) { - EXPECT( - "fn f() { x = bitcast(y); }", - R"(test.wgsl:1:21 error: expected '< (opening template argument list)' for bitcast expression + EXPECT("fn f() { x = bitcast(y); }", + R"(test.wgsl:1:21 error: expected '<' for bitcast expression fn f() { x = bitcast(y); } ^ )"); @@ -660,9 +659,8 @@ TEST_F(ParserImplErrorTest, GlobalDeclInvalidAttribute) { } TEST_F(ParserImplErrorTest, GlobalDeclSampledTextureMissingLessThan) { - EXPECT( - "var x : texture_1d;", - R"(test.wgsl:1:19 error: expected '< (opening template argument list)' for sampled texture type + EXPECT("var x : texture_1d;", + R"(test.wgsl:1:19 error: expected '<' for sampled texture type var x : texture_1d; ^ )"); @@ -685,9 +683,8 @@ var x : texture_1d<1>; } TEST_F(ParserImplErrorTest, GlobalDeclMultisampledTextureMissingLessThan) { - EXPECT( - "var x : texture_multisampled_2d;", - R"(test.wgsl:1:32 error: expected '< (opening template argument list)' for multisampled texture type + EXPECT("var x : texture_multisampled_2d;", + R"(test.wgsl:1:32 error: expected '<' for multisampled texture type var x : texture_multisampled_2d; ^ )"); @@ -833,9 +830,8 @@ static_assert true static_assert true; } TEST_F(ParserImplErrorTest, GlobalDeclStorageTextureMissingLessThan) { - EXPECT( - "var x : texture_storage_2d;", - R"(test.wgsl:1:27 error: expected '< (opening template argument list)' for storage texture type + EXPECT("var x : texture_storage_2d;", + R"(test.wgsl:1:27 error: expected '<' for storage texture type var x : texture_storage_2d; ^ )"); @@ -1200,9 +1196,8 @@ var i : i32 } TEST_F(ParserImplErrorTest, GlobalDeclVarPtrMissingLessThan) { - EXPECT( - "var i : ptr;", - R"(test.wgsl:1:12 error: expected '< (opening template argument list)' for ptr declaration + EXPECT("var i : ptr;", + R"(test.wgsl:1:12 error: expected '<' for ptr declaration var i : ptr; ^ )"); @@ -1242,9 +1237,8 @@ var i : ptr; } TEST_F(ParserImplErrorTest, GlobalDeclVarAtomicMissingLessThan) { - EXPECT( - "var i : atomic;", - R"(test.wgsl:1:15 error: expected '< (opening template argument list)' for atomic declaration + EXPECT("var i : atomic;", + R"(test.wgsl:1:15 error: expected '<' for atomic declaration var i : atomic; ^ )"); diff --git a/src/tint/reader/wgsl/parser_impl_texture_sampler_test.cc b/src/tint/reader/wgsl/parser_impl_texture_sampler_test.cc index 5db4e48cca..299bd333b9 100644 --- a/src/tint/reader/wgsl/parser_impl_texture_sampler_test.cc +++ b/src/tint/reader/wgsl/parser_impl_texture_sampler_test.cc @@ -126,8 +126,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_MissingLessThan) { EXPECT_EQ(t.value, nullptr); EXPECT_FALSE(t.matched); EXPECT_TRUE(t.errored); - EXPECT_EQ(p->error(), - "1:11: expected '< (opening template argument list)' for sampled texture type"); + EXPECT_EQ(p->error(), "1:11: expected '<' for sampled texture type"); } TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_MissingGreaterThan) { @@ -170,8 +169,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_MissingLessThan) EXPECT_EQ(t.value, nullptr); EXPECT_FALSE(t.matched); EXPECT_TRUE(t.errored); - EXPECT_EQ(p->error(), - "1:24: expected '< (opening template argument list)' for multisampled texture type"); + EXPECT_EQ(p->error(), "1:24: expected '<' for multisampled texture type"); } TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_MissingGreaterThan) { @@ -263,8 +261,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_MissingLessThan) { EXPECT_EQ(t.value, nullptr); EXPECT_FALSE(t.matched); EXPECT_TRUE(t.errored); - EXPECT_EQ(p->error(), - "1:19: expected '< (opening template argument list)' for storage texture type"); + EXPECT_EQ(p->error(), "1:19: expected '<' for storage texture type"); } TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_MissingGreaterThan) { diff --git a/src/tint/reader/wgsl/parser_impl_type_decl_test.cc b/src/tint/reader/wgsl/parser_impl_type_decl_test.cc index 9787d5e202..5e18b00402 100644 --- a/src/tint/reader/wgsl/parser_impl_type_decl_test.cc +++ b/src/tint/reader/wgsl/parser_impl_type_decl_test.cc @@ -222,7 +222,7 @@ TEST_F(ParserImplTest, TypeDecl_Ptr_MissingLessThan) { EXPECT_FALSE(t.matched); ASSERT_EQ(t.value, nullptr); ASSERT_TRUE(p->has_error()); - ASSERT_EQ(p->error(), "1:5: expected '< (opening template argument list)' for ptr declaration"); + ASSERT_EQ(p->error(), "1:5: expected '<' for ptr declaration"); } TEST_F(ParserImplTest, TypeDecl_Ptr_MissingGreaterThanAfterType) { @@ -262,8 +262,7 @@ TEST_F(ParserImplTest, TypeDecl_Ptr_MissingCommaAfterAccess) { EXPECT_FALSE(t.matched); ASSERT_EQ(t.value, nullptr); ASSERT_TRUE(p->has_error()); - ASSERT_EQ(p->error(), - "1:19: expected '> (closing template argument list)' for ptr declaration"); + ASSERT_EQ(p->error(), "1:19: expected '>' for ptr declaration"); } TEST_F(ParserImplTest, TypeDecl_Ptr_MissingAddressSpace) { @@ -371,8 +370,7 @@ TEST_F(ParserImplTest, TypeDecl_Atomic_MissingLessThan) { EXPECT_FALSE(t.matched); ASSERT_EQ(t.value, nullptr); ASSERT_TRUE(p->has_error()); - ASSERT_EQ(p->error(), - "1:8: expected '< (opening template argument list)' for atomic declaration"); + ASSERT_EQ(p->error(), "1:8: expected '<' for atomic declaration"); } TEST_F(ParserImplTest, TypeDecl_Atomic_MissingGreaterThan) { @@ -573,8 +571,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_MissingComma) { EXPECT_FALSE(t.matched); ASSERT_EQ(t.value, nullptr); ASSERT_TRUE(p->has_error()); - ASSERT_EQ(p->error(), - "1:11: expected '> (closing template argument list)' for array declaration"); + ASSERT_EQ(p->error(), "1:11: expected '>' for array declaration"); } struct MatrixData { diff --git a/src/tint/reader/wgsl/parser_impl_type_decl_without_ident_test.cc b/src/tint/reader/wgsl/parser_impl_type_decl_without_ident_test.cc index 2714bf8237..ea146c918c 100644 --- a/src/tint/reader/wgsl/parser_impl_type_decl_without_ident_test.cc +++ b/src/tint/reader/wgsl/parser_impl_type_decl_without_ident_test.cc @@ -213,7 +213,7 @@ TEST_F(ParserImplTest, TypeDeclWithoutIdent_Ptr_MissingLessThan) { EXPECT_FALSE(t.matched); ASSERT_EQ(t.value, nullptr); ASSERT_TRUE(p->has_error()); - ASSERT_EQ(p->error(), "1:5: expected '< (opening template argument list)' for ptr declaration"); + ASSERT_EQ(p->error(), "1:5: expected '<' for ptr declaration"); } TEST_F(ParserImplTest, TypeDeclWithoutIdent_Ptr_MissingGreaterThanAfterType) { @@ -253,8 +253,7 @@ TEST_F(ParserImplTest, TypeDeclWithoutIdent_Ptr_MissingCommaAfterAccess) { EXPECT_FALSE(t.matched); ASSERT_EQ(t.value, nullptr); ASSERT_TRUE(p->has_error()); - ASSERT_EQ(p->error(), - "1:19: expected '> (closing template argument list)' for ptr declaration"); + ASSERT_EQ(p->error(), "1:19: expected '>' for ptr declaration"); } TEST_F(ParserImplTest, TypeDeclWithoutIdent_Ptr_MissingAddressSpace) { @@ -362,8 +361,7 @@ TEST_F(ParserImplTest, TypeDeclWithoutIdent_Atomic_MissingLessThan) { EXPECT_FALSE(t.matched); ASSERT_EQ(t.value, nullptr); ASSERT_TRUE(p->has_error()); - ASSERT_EQ(p->error(), - "1:8: expected '< (opening template argument list)' for atomic declaration"); + ASSERT_EQ(p->error(), "1:8: expected '<' for atomic declaration"); } TEST_F(ParserImplTest, TypeDeclWithoutIdent_Atomic_MissingGreaterThan) { @@ -564,8 +562,7 @@ TEST_F(ParserImplTest, TypeDeclWithoutIdent_Array_MissingComma) { EXPECT_FALSE(t.matched); ASSERT_EQ(t.value, nullptr); ASSERT_TRUE(p->has_error()); - ASSERT_EQ(p->error(), - "1:11: expected '> (closing template argument list)' for array declaration"); + ASSERT_EQ(p->error(), "1:11: expected '>' for array declaration"); } struct MatrixData { diff --git a/src/tint/reader/wgsl/token.cc b/src/tint/reader/wgsl/token.cc index 52706d60ad..f13b317605 100644 --- a/src/tint/reader/wgsl/token.cc +++ b/src/tint/reader/wgsl/token.cc @@ -71,7 +71,6 @@ std::string_view Token::TypeToName(Type type) { case Token::Type::kEqualEqual: return "=="; case Token::Type::kTemplateArgsRight: - return "> (closing template argument list)"; case Token::Type::kGreaterThan: return ">"; case Token::Type::kGreaterThanEqual: @@ -79,7 +78,6 @@ std::string_view Token::TypeToName(Type type) { case Token::Type::kShiftRight: return ">>"; case Token::Type::kTemplateArgsLeft: - return "< (opening template argument list)"; case Token::Type::kLessThan: return "<"; case Token::Type::kLessThanEqual: