reader/wgsl: Allow identifiers to start with an underscore

Try to lex identifiers before punctuation, and backtrack if we only
see a single underscore or something that starts with two underscores.

Rename the modf and frexp return types to start with two underscores.

Spec PR:
https://github.com/gpuweb/gpuweb/pull/2326

Change-Id: Id283af100babfe84faa183345cb8a60848140caa
Fixed: tint:1292
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70160
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
This commit is contained in:
James Price
2021-11-19 21:52:13 +00:00
committed by Tint LUCI CQ
parent 0e2185efca
commit 1bf5af25ad
60 changed files with 414 additions and 395 deletions

View File

@@ -835,8 +835,8 @@ TEST_F(ResolverIntrinsicDataTest, Frexp_Error_FirstParamInt) {
R"(error: no matching call to frexp(i32, ptr<workgroup, i32, read_write>)
2 candidate functions:
frexp(f32) -> _frexp_result
frexp(vecN<f32>) -> _frexp_result_vecN
frexp(f32) -> __frexp_result
frexp(vecN<f32>) -> __frexp_result_vecN
)");
}
@@ -852,8 +852,8 @@ TEST_F(ResolverIntrinsicDataTest, Frexp_Error_SecondParamFloatPtr) {
R"(error: no matching call to frexp(f32, ptr<workgroup, f32, read_write>)
2 candidate functions:
frexp(f32) -> _frexp_result
frexp(vecN<f32>) -> _frexp_result_vecN
frexp(f32) -> __frexp_result
frexp(vecN<f32>) -> __frexp_result_vecN
)");
}
@@ -866,8 +866,8 @@ TEST_F(ResolverIntrinsicDataTest, Frexp_Error_SecondParamNotAPointer) {
EXPECT_EQ(r()->error(), R"(error: no matching call to frexp(f32, i32)
2 candidate functions:
frexp(f32) -> _frexp_result
frexp(vecN<f32>) -> _frexp_result_vecN
frexp(f32) -> __frexp_result
frexp(vecN<f32>) -> __frexp_result_vecN
)");
}
@@ -883,8 +883,8 @@ TEST_F(ResolverIntrinsicDataTest, Frexp_Error_VectorSizesDontMatch) {
R"(error: no matching call to frexp(vec2<f32>, ptr<workgroup, vec4<i32>, read_write>)
2 candidate functions:
frexp(vecN<f32>) -> _frexp_result_vecN
frexp(f32) -> _frexp_result
frexp(vecN<f32>) -> __frexp_result_vecN
frexp(f32) -> __frexp_result
)");
}
@@ -962,8 +962,8 @@ TEST_F(ResolverIntrinsicDataTest, Modf_Error_FirstParamInt) {
R"(error: no matching call to modf(i32, ptr<workgroup, f32, read_write>)
2 candidate functions:
modf(f32) -> _modf_result
modf(vecN<f32>) -> _modf_result_vecN
modf(f32) -> __modf_result
modf(vecN<f32>) -> __modf_result_vecN
)");
}
@@ -979,8 +979,8 @@ TEST_F(ResolverIntrinsicDataTest, Modf_Error_SecondParamIntPtr) {
R"(error: no matching call to modf(f32, ptr<workgroup, i32, read_write>)
2 candidate functions:
modf(f32) -> _modf_result
modf(vecN<f32>) -> _modf_result_vecN
modf(f32) -> __modf_result
modf(vecN<f32>) -> __modf_result_vecN
)");
}
@@ -993,8 +993,8 @@ TEST_F(ResolverIntrinsicDataTest, Modf_Error_SecondParamNotAPointer) {
EXPECT_EQ(r()->error(), R"(error: no matching call to modf(f32, f32)
2 candidate functions:
modf(f32) -> _modf_result
modf(vecN<f32>) -> _modf_result_vecN
modf(f32) -> __modf_result
modf(vecN<f32>) -> __modf_result_vecN
)");
}
@@ -1010,8 +1010,8 @@ TEST_F(ResolverIntrinsicDataTest, Modf_Error_VectorSizesDontMatch) {
R"(error: no matching call to modf(vec2<f32>, ptr<workgroup, vec4<f32>, read_write>)
2 candidate functions:
modf(vecN<f32>) -> _modf_result_vecN
modf(f32) -> _modf_result
modf(vecN<f32>) -> __modf_result_vecN
modf(f32) -> __modf_result
)");
}