reader/wgsl: Lex underscore tokens

Bug: tint:1213
Change-Id: Ic5f2bfb2da0bf0f9511f029a93c7007266b2984c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/67063
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
Ben Clayton 2021-10-20 19:59:23 +00:00 committed by Tint LUCI CQ
parent 0da0c95dc3
commit e81d7dc3c8
4 changed files with 9 additions and 0 deletions

View File

@ -840,6 +840,10 @@ Token Lexer::try_punctuation() {
type = Token::Type::kTilde;
pos_ += 1;
location_.column += 1;
} else if (matches(pos_, "_")) {
type = Token::Type::kUnderscore;
pos_ += 1;
location_.column += 1;
} else if (matches(pos_, "^")) {
type = Token::Type::kXor;
pos_ += 1;

View File

@ -493,6 +493,7 @@ INSTANTIATE_TEST_SUITE_P(
TokenData{";", Token::Type::kSemicolon},
TokenData{"*", Token::Type::kStar},
TokenData{"~", Token::Type::kTilde},
TokenData{"_", Token::Type::kUnderscore},
TokenData{"^", Token::Type::kXor}));
using KeywordTest = testing::TestWithParam<TokenData>;

View File

@ -106,6 +106,8 @@ std::string Token::TypeToName(Type type) {
return "*";
case Token::Type::kTilde:
return "~";
case Token::Type::kUnderscore:
return "_";
case Token::Type::kXor:
return "^";

View File

@ -114,6 +114,8 @@ class Token {
kStar,
/// A '~'
kTilde,
/// A '_'
kUnderscore,
/// A '^'
kXor,