summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/compiler-core/slang-lexer-diagnostic-defs.h1
-rw-r--r--source/compiler-core/slang-lexer.cpp4
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