Parse tilde in function input description
This commit is contained in:
parent
98060d36b6
commit
fbcba4edf2
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Lexer;
|
using Lexer;
|
||||||
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
@ -400,5 +401,17 @@ namespace Parser.Tests
|
|||||||
Assert.IsInstanceOf<UnaryPrefixOperationExpressionNode>(f.Elements.Elements[1]);
|
Assert.IsInstanceOf<UnaryPrefixOperationExpressionNode>(f.Elements.Elements[1]);
|
||||||
Assert.AreEqual(text, actual.FullText);
|
Assert.AreEqual(text, actual.FullText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ParseTildeAsFunctionInputReplacement()
|
||||||
|
{
|
||||||
|
var text = "function a(b, ~, c) end";
|
||||||
|
var sut = CreateParser(text);
|
||||||
|
var actual = sut.ParseStatement();
|
||||||
|
Assert.IsInstanceOf<FunctionDeclarationNode>(actual);
|
||||||
|
var f = (FunctionDeclarationNode) actual;
|
||||||
|
Assert.AreEqual(3, f.InputDescription.Parameters.Parameters.Count);
|
||||||
|
CollectionAssert.AreEqual(new[] { "b", "~", "c" }, f.InputDescription.Parameters.Parameters.Select(p => (p as TokenNode).Token.PureToken.LiteralText));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -181,10 +181,18 @@ namespace Parser
|
|||||||
identifierTokens.Add(EatToken(TokenKind.Comma));
|
identifierTokens.Add(EatToken(TokenKind.Comma));
|
||||||
}
|
}
|
||||||
|
|
||||||
identifierTokens.Add(EatToken(TokenKind.Identifier));
|
if (CurrentToken.Kind == TokenKind.Not)
|
||||||
|
{
|
||||||
|
var notToken = EatToken();
|
||||||
|
identifierTokens.Add(notToken);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
identifierTokens.Add(EatToken(TokenKind.Identifier));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Factory.ParameterList(identifierTokens.Select(token => new TokenNode(token) as SyntaxNode).ToList());
|
return Factory.ParameterList(identifierTokens.Select(token => Factory.Token(token) as SyntaxNode).ToList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private FunctionInputDescriptionNode ParseFunctionInputDescription()
|
private FunctionInputDescriptionNode ParseFunctionInputDescription()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user