Parse tilde as missing output parameter marker
This commit is contained in:
parent
e5d0b0fe2e
commit
d376d691c4
@ -387,5 +387,18 @@ namespace Parser.Tests
|
|||||||
Assert.IsInstanceOf<BinaryOperationExpressionNode>(f.Body);
|
Assert.IsInstanceOf<BinaryOperationExpressionNode>(f.Body);
|
||||||
Assert.AreEqual(text, actual.FullText);
|
Assert.AreEqual(text, actual.FullText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ParseTildeAsResultReplacement()
|
||||||
|
{
|
||||||
|
var text = "[a, ~, b]";
|
||||||
|
var sut = CreateParser(text);
|
||||||
|
var actual = sut.ParseExpression();
|
||||||
|
Assert.IsInstanceOf<ArrayLiteralExpressionNode>(actual);
|
||||||
|
var f = (ArrayLiteralExpressionNode) actual;
|
||||||
|
Assert.AreEqual(3, f.Elements.Elements.Count);
|
||||||
|
Assert.IsInstanceOf<UnaryPrefixOperationExpressionNode>(f.Elements.Elements[1]);
|
||||||
|
Assert.AreEqual(text, actual.FullText);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -598,6 +598,17 @@ namespace Parser
|
|||||||
var unaryTokenKind = ConvertToUnaryTokenKind(operation.Kind);
|
var unaryTokenKind = ConvertToUnaryTokenKind(operation.Kind);
|
||||||
var newPrecedence = GetPrecedence(unaryTokenKind);
|
var newPrecedence = GetPrecedence(unaryTokenKind);
|
||||||
var operand = ParseSubExpression(options, newPrecedence);
|
var operand = ParseSubExpression(options, newPrecedence);
|
||||||
|
if (operand == null)
|
||||||
|
{
|
||||||
|
if (options.ParsingArrayElements && operation.Kind == TokenKind.Not)
|
||||||
|
{
|
||||||
|
operand = Factory.EmptyExpression();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new ParsingException($"Unexpected token {CurrentToken.Kind} at {operation.PureToken.Position}.");
|
||||||
|
}
|
||||||
|
}
|
||||||
lhs = Factory.UnaryPrefixOperationExpression(Factory.Token(operation), operand);
|
lhs = Factory.UnaryPrefixOperationExpression(Factory.Token(operation), operand);
|
||||||
}
|
}
|
||||||
else if (CurrentToken.Kind == TokenKind.At)
|
else if (CurrentToken.Kind == TokenKind.At)
|
||||||
|
@ -449,6 +449,7 @@ namespace Parser
|
|||||||
get { yield break; }
|
get { yield break; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string FullText => "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CompoundNameNode : ExpressionNode
|
public class CompoundNameNode : ExpressionNode
|
||||||
|
Loading…
x
Reference in New Issue
Block a user