diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2024-07-18 23:54:05 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-18 23:54:05 +0800 |
| commit | 3750a4dcb284d4695f5188c497c5a9dcff98388e (patch) | |
| tree | 91d1127ea6170caaf5587d34ad2163752e756ab8 /source | |
| parent | 6f1371a7870a7c371a77cfdee1daa5c32f0c5377 (diff) | |
Add unexpected end of input error to lexer (#4673)
* Add unexpected end of input error to lexer
* Add end of input test
* Simplify testcase
Diffstat (limited to 'source')
| -rw-r--r-- | source/compiler-core/slang-lexer-diagnostic-defs.h | 1 | ||||
| -rw-r--r-- | source/compiler-core/slang-lexer.cpp | 4 |
2 files changed, 5 insertions, 0 deletions
diff --git a/source/compiler-core/slang-lexer-diagnostic-defs.h b/source/compiler-core/slang-lexer-diagnostic-defs.h index ceeb62455..bce287685 100644 --- a/source/compiler-core/slang-lexer-diagnostic-defs.h +++ b/source/compiler-core/slang-lexer-diagnostic-defs.h @@ -31,5 +31,6 @@ DIAGNOSTIC(10004, Error, endOfFileInLiteral, "end of file in literal") DIAGNOSTIC(10005, Error, newlineInLiteral, "newline in literal") DIAGNOSTIC(10010, Error, quoteCannotBeDelimiter, "'\"' encountered before '(' in raw string literal. '\"' cannot be a part of a delimiter.") +DIAGNOSTIC(10011, Error, unexpectedEndOfInput, "unexpected end of input") #undef DIAGNOSTIC diff --git a/source/compiler-core/slang-lexer.cpp b/source/compiler-core/slang-lexer.cpp index 8c428159c..10c5aa1ae 100644 --- a/source/compiler-core/slang-lexer.cpp +++ b/source/compiler-core/slang-lexer.cpp @@ -1374,6 +1374,10 @@ namespace Slang char buffer[] = { (char) c, 0 }; sink->diagnose(loc, LexerDiagnostics::illegalCharacterPrint, buffer); } + else if(c == kEOF) + { + sink->diagnose(loc, LexerDiagnostics::unexpectedEndOfInput); + } else { // Fallback: print as hexadecimal |
