diff options
Diffstat (limited to 'source/compiler-core')
| -rw-r--r-- | source/compiler-core/slang-lexer.cpp | 18 | ||||
| -rw-r--r-- | source/compiler-core/slang-token-defs.h | 2 |
2 files changed, 19 insertions, 1 deletions
diff --git a/source/compiler-core/slang-lexer.cpp b/source/compiler-core/slang-lexer.cpp index 653c43dba..a5eab67dd 100644 --- a/source/compiler-core/slang-lexer.cpp +++ b/source/compiler-core/slang-lexer.cpp @@ -951,7 +951,23 @@ namespace Slang case '5': case '6': case '7': case '8': case '9': return _lexNumberAfterDecimalPoint(lexer, 10); - // TODO(tfoley): handle ellipsis (`...`) + case '.': + // Note: consuming the second `.` here means that + // we cannot back up and return a `.` token by itself + // any more. We thus end up having distinct tokens for + // `.`, `..`, and `...` even though the `..` case is + // not part of HLSL. + // + _advance(lexer); + switch(_peek(lexer)) + { + case '.': + _advance(lexer); + return TokenType::Ellipsis; + + default: + return TokenType::DotDot; + } default: return TokenType::Dot; diff --git a/source/compiler-core/slang-token-defs.h b/source/compiler-core/slang-token-defs.h index 485429e28..fdbe81e17 100644 --- a/source/compiler-core/slang-token-defs.h +++ b/source/compiler-core/slang-token-defs.h @@ -35,6 +35,8 @@ TOKEN(BlockComment, "block comment") PUNCTUATION(Semicolon, ";") PUNCTUATION(Comma, ",") PUNCTUATION(Dot, ".") +PUNCTUATION(DotDot, "..") +PUNCTUATION(Ellipsis, "...") PUNCTUATION(LBrace, "{") PUNCTUATION(RBrace, "}") |
