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:
Ben Clayton 2021-01-06 19:54:01 +00:00 committed by Commit Bot service account
parent 40b4928a73
commit 9bbf8252a9
5 changed files with 8 additions and 7 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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)) {

View File

@ -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;
})");

View File

@ -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);