Correctly lex string literal as the first token
This commit is contained in:
parent
00aae12361
commit
8acea8e90e
@ -205,5 +205,15 @@ namespace Parser.Tests
|
||||
var actual = string.Join("", tokens.Select(token => token.FullText));
|
||||
Assert.AreEqual(s, actual);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ParseStringLiteral()
|
||||
{
|
||||
var sut = CreateLexer("'just a string'");
|
||||
var tokens = sut.ParseAll();
|
||||
Assert.AreEqual(2, tokens.Count);
|
||||
Assert.AreEqual(TokenKind.StringLiteral, tokens[0].Kind);
|
||||
Assert.AreEqual("just a string", tokens[0].PureToken.Value);
|
||||
}
|
||||
}
|
||||
}
|
@ -537,10 +537,11 @@ namespace Lexer
|
||||
Window.ConsumeChar();
|
||||
return PureTokenFactory.CreatePunctuation(TokenKind.QuestionMark);
|
||||
case '\'':
|
||||
if (LastToken.PureToken.Kind == TokenKind.ClosingBrace
|
||||
|| LastToken.PureToken.Kind == TokenKind.ClosingBracket
|
||||
|| LastToken.PureToken.Kind == TokenKind.ClosingSquareBracket
|
||||
|| LastToken.PureToken.Kind == TokenKind.Identifier)
|
||||
if (LastToken != null &&
|
||||
(LastToken.Kind == TokenKind.ClosingBrace
|
||||
|| LastToken.Kind == TokenKind.ClosingBracket
|
||||
|| LastToken.Kind == TokenKind.ClosingSquareBracket
|
||||
|| LastToken.Kind == TokenKind.Identifier))
|
||||
{
|
||||
if (LastToken.TrailingTrivia.Count == 0 && leadingTrivia.Count == 0)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user