diff --git a/src/reader/wgsl/lexer.cc b/src/reader/wgsl/lexer.cc index af8ab7ec34..9b8f5840bf 100644 --- a/src/reader/wgsl/lexer.cc +++ b/src/reader/wgsl/lexer.cc @@ -143,7 +143,8 @@ void Lexer::skip_whitespace() { } void Lexer::skip_comments() { - if (!matches(pos_, "#")) { + // TODO(bclayton): Remove support for # comments + if (!matches(pos_, "#") && !matches(pos_, "//")) { return; } diff --git a/src/reader/wgsl/lexer_test.cc b/src/reader/wgsl/lexer_test.cc index 3a9d7bbece..86689605b1 100644 --- a/src/reader/wgsl/lexer_test.cc +++ b/src/reader/wgsl/lexer_test.cc @@ -49,9 +49,9 @@ TEST_F(LexerTest, Skips_Whitespace) { } TEST_F(LexerTest, Skips_Comments) { - Source::File file("test.wgsl", R"(#starts with comment -ident1 #ends with comment -# blank line + Source::File file("test.wgsl", R"(//starts with comment +ident1 //ends with comment +// blank line ident2)"); Lexer l(&file); diff --git a/src/reader/wgsl/parser_impl_for_stmt_test.cc b/src/reader/wgsl/parser_impl_for_stmt_test.cc index b112779509..42af07d128 100644 --- a/src/reader/wgsl/parser_impl_for_stmt_test.cc +++ b/src/reader/wgsl/parser_impl_for_stmt_test.cc @@ -135,7 +135,7 @@ TEST_F(ForStmtTest, All) { })"; std::string loop_str = - R"({ # Introduce new scope for loop variable i + R"({ // Introduce new scope for loop variable i var i : i32 = 0; loop { if (!(i < 4)) { diff --git a/src/reader/wgsl/parser_impl_test.cc b/src/reader/wgsl/parser_impl_test.cc index 54dde10d57..95d28cfaae 100644 --- a/src/reader/wgsl/parser_impl_test.cc +++ b/src/reader/wgsl/parser_impl_test.cc @@ -46,7 +46,7 @@ fn main() -> void { TEST_F(ParserImplTest, HandlesError) { auto p = parser(R"( -fn main() -> { # missing return type +fn main() -> { // missing return type return; })"); diff --git a/src/reader/wgsl/parser_test.cc b/src/reader/wgsl/parser_test.cc index 0ee28ab2a0..1bb967e434 100644 --- a/src/reader/wgsl/parser_test.cc +++ b/src/reader/wgsl/parser_test.cc @@ -48,7 +48,7 @@ fn main() -> void { TEST_F(ParserTest, HandlesError) { Source::File file("test.wgsl", R"( -fn main() -> { # missing return type +fn main() -> { // missing return type return; })"); Parser p(&file);