wgsl: Treat // as comment
Also support # as comments for now while we migrate. See: https: //github.com/gpuweb/gpuweb/issues/1262 https: //github.com/gpuweb/gpuweb/pull/1326 Change-Id: I3547f575c35f4fd46b95f0f2d8b79f4015364c83 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36680 Commit-Queue: Ben Clayton <bclayton@google.com> Commit-Queue: dan sinclair <dsinclair@chromium.org> Reviewed-by: dan sinclair <dsinclair@chromium.org> Auto-Submit: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
40b4928a73
commit
9bbf8252a9
|
@ -143,7 +143,8 @@ void Lexer::skip_whitespace() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lexer::skip_comments() {
|
void Lexer::skip_comments() {
|
||||||
if (!matches(pos_, "#")) {
|
// TODO(bclayton): Remove support for # comments
|
||||||
|
if (!matches(pos_, "#") && !matches(pos_, "//")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,9 +49,9 @@ TEST_F(LexerTest, Skips_Whitespace) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LexerTest, Skips_Comments) {
|
TEST_F(LexerTest, Skips_Comments) {
|
||||||
Source::File file("test.wgsl", R"(#starts with comment
|
Source::File file("test.wgsl", R"(//starts with comment
|
||||||
ident1 #ends with comment
|
ident1 //ends with comment
|
||||||
# blank line
|
// blank line
|
||||||
ident2)");
|
ident2)");
|
||||||
Lexer l(&file);
|
Lexer l(&file);
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ TEST_F(ForStmtTest, All) {
|
||||||
})";
|
})";
|
||||||
|
|
||||||
std::string loop_str =
|
std::string loop_str =
|
||||||
R"({ # Introduce new scope for loop variable i
|
R"({ // Introduce new scope for loop variable i
|
||||||
var i : i32 = 0;
|
var i : i32 = 0;
|
||||||
loop {
|
loop {
|
||||||
if (!(i < 4)) {
|
if (!(i < 4)) {
|
||||||
|
|
|
@ -46,7 +46,7 @@ fn main() -> void {
|
||||||
|
|
||||||
TEST_F(ParserImplTest, HandlesError) {
|
TEST_F(ParserImplTest, HandlesError) {
|
||||||
auto p = parser(R"(
|
auto p = parser(R"(
|
||||||
fn main() -> { # missing return type
|
fn main() -> { // missing return type
|
||||||
return;
|
return;
|
||||||
})");
|
})");
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ fn main() -> void {
|
||||||
|
|
||||||
TEST_F(ParserTest, HandlesError) {
|
TEST_F(ParserTest, HandlesError) {
|
||||||
Source::File file("test.wgsl", R"(
|
Source::File file("test.wgsl", R"(
|
||||||
fn main() -> { # missing return type
|
fn main() -> { // missing return type
|
||||||
return;
|
return;
|
||||||
})");
|
})");
|
||||||
Parser p(&file);
|
Parser p(&file);
|
||||||
|
|
Loading…
Reference in New Issue