Fixes string not checking if it ends with a quotation mark

This commit is contained in:
Deukhoofd 2018-11-25 22:05:01 +01:00
parent 8f91b7f550
commit 2111f4080c
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
2 changed files with 10 additions and 0 deletions

View File

@ -34,6 +34,11 @@ namespace Upsilon
{ {
LogError($"Invalid character found. Expected: '{expectedToken}'", location); 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) public void LogBadCharacter(TextSpan location)
{ {
LogError($"Invalid character found.", location); LogError($"Invalid character found.", location);

View File

@ -151,6 +151,11 @@ namespace Upsilon.Parser
sb.Append(Current); sb.Append(Current);
} }
if (Current != '"')
{
_diagnostics.LogBadCharacter(new TextSpan(_position, 1), '"', Current);
}
var res = sb.ToString(); var res = sb.ToString();
return new SyntaxToken(SyntaxKind.String, start, $"\"{res}\"", res); return new SyntaxToken(SyntaxKind.String, start, $"\"{res}\"", res);
} }