diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/compiler-core/slang-lexer.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/source/compiler-core/slang-lexer.cpp b/source/compiler-core/slang-lexer.cpp index 7bb9aa84d..24cd3034b 100644 --- a/source/compiler-core/slang-lexer.cpp +++ b/source/compiler-core/slang-lexer.cpp @@ -438,6 +438,22 @@ namespace Slang static bool _maybeLexNumberExponent(Lexer* lexer, int base) { + if (_peek(lexer) == '#') + { + // Special case #INF + const auto inf = toSlice("#INF"); + for (auto c : inf) + { + if (_peek(lexer) != c) + { + return false; + } + _advance(lexer); + } + + return true; + } + if(!_isNumberExponent(_peek(lexer), base)) return false; @@ -626,6 +642,24 @@ namespace Slang } } + if (*cursor == '#') + { + // It must be INF + const auto inf = toSlice("#INF"); + + if (UnownedStringSlice(cursor, end).startsWith(inf)) + { + if(outSuffix) + { + *outSuffix = UnownedStringSlice(cursor + inf.getLength(), end); + } + + value = INFINITY; + + return value; + } + } + // Now read optional exponent if(_isNumberExponent(*cursor, radix)) { |
