Parse postfix dot-transpose

This commit is contained in:
Alexander Luzgarev 2018-04-04 10:55:54 +02:00
parent fbcba4edf2
commit db216671c3
2 changed files with 17 additions and 2 deletions

View File

@ -412,6 +412,20 @@ namespace Parser.Tests
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));
Assert.AreEqual(text, actual.FullText);
}
[Test]
public void ParseDotTranspose()
{
var text = "a.'";
var sut = CreateParser(text);
var actual = sut.ParseExpression();
Assert.IsInstanceOf<UnaryPostfixOperationExpressionNode>(actual);
var e = (UnaryPostfixOperationExpressionNode) actual;
Assert.AreEqual(TokenKind.DotTranspose, e.Operation.Token.Kind);
Assert.AreEqual("a", (e.Operand as IdentifierNameNode)?.Token.PureToken.LiteralText);
Assert.AreEqual(text, actual.FullText);
}
}
}

View File

@ -343,8 +343,9 @@ namespace Parser
break;
case TokenKind.Transpose:
var transposeSign = Factory.Token(EatToken());
expression = Factory.UnaryPostfixOperationExpression(expression, transposeSign);
case TokenKind.DotTranspose:
var operation = Factory.Token(EatToken());
expression = Factory.UnaryPostfixOperationExpression(expression, operation);
break;
default:
return expression;