[wgsl-reader] Fixup off by 1 bug.

When parsing the `u` in `1024u` we were not advancing the lexer to the
next token which would give parse errors.

Change-Id: I8473b55992ff01d24f9d961878afa6b54d855e68
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23460
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
dan sinclair 2020-06-18 14:10:58 +00:00 committed by David Neto
parent e12c5ff42e
commit 206d7401ae
2 changed files with 4 additions and 0 deletions

View File

@ -216,6 +216,7 @@ Token Lexer::build_token_from_int_if_possible(const Source& source,
return {Token::Type::kError, source, return {Token::Type::kError, source,
"u32 (" + input_.substr(start, end - start) + ") too large"}; "u32 (" + input_.substr(start, end - start) + ") too large"};
} }
pos_ += 1;
return {source, static_cast<uint32_t>(res)}; return {source, static_cast<uint32_t>(res)};
} }

View File

@ -249,6 +249,9 @@ TEST_P(IntegerTest_HexUnsigned, Matches) {
EXPECT_EQ(t.line(), 1u); EXPECT_EQ(t.line(), 1u);
EXPECT_EQ(t.column(), 1u); EXPECT_EQ(t.column(), 1u);
EXPECT_EQ(t.to_u32(), params.result); EXPECT_EQ(t.to_u32(), params.result);
t = l.next();
EXPECT_TRUE(t.IsEof());
} }
INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P(
LexerTest, LexerTest,