From 2111f4080c4c9541f1bf4d4efd90fa6f7fd03de4 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 25 Nov 2018 22:05:01 +0100 Subject: [PATCH] Fixes string not checking if it ends with a quotation mark --- Upsilon/Diagnostics.cs | 5 +++++ Upsilon/Parser/Lexer.cs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/Upsilon/Diagnostics.cs b/Upsilon/Diagnostics.cs index 100e6a1..0ccdb58 100644 --- a/Upsilon/Diagnostics.cs +++ b/Upsilon/Diagnostics.cs @@ -34,6 +34,11 @@ namespace Upsilon { LogError($"Invalid character found. Expected: '{expectedToken}'", location); } + public void LogBadCharacter(TextSpan location, char expected, char actual) + { + LogError($"Invalid character found. Expected: '{expected}', Got: '{actual}'", location); + } + public void LogBadCharacter(TextSpan location) { LogError($"Invalid character found.", location); diff --git a/Upsilon/Parser/Lexer.cs b/Upsilon/Parser/Lexer.cs index 1d2f8ef..6d33a5e 100644 --- a/Upsilon/Parser/Lexer.cs +++ b/Upsilon/Parser/Lexer.cs @@ -151,6 +151,11 @@ namespace Upsilon.Parser sb.Append(Current); } + if (Current != '"') + { + _diagnostics.LogBadCharacter(new TextSpan(_position, 1), '"', Current); + } + var res = sb.ToString(); return new SyntaxToken(SyntaxKind.String, start, $"\"{res}\"", res); }