private IExpression ParseTermExpression() { IExpression expression = this.ParseSimpleTermExpression(); while (this.TryParse(TokenType.Operator, ".") || this.TryParse(TokenType.Separator, "[", "(")) { if (this.TryParse(TokenType.Separator, "(")) { expression = new InvokeExpressionExpression(expression, this.ParseArgumentList()); } else if (this.TryParse(TokenType.Operator, ".")) { this.lexer.NextToken(); string name = this.ParseName(); List <IExpression> arguments = null; if (this.TryParse(TokenType.Separator, "(")) { arguments = this.ParseArgumentList(); } expression = new DotExpression(expression, name, arguments); } else { expression = new ArrayExpression(expression, this.ParseArrayArgumentList()); } } return(expression); }
public void ParseInvokeExpressionExpression() { IExpression expression = ParseExpression("MyFunc(2)(3)"); Assert.IsNotNull(expression); Assert.IsInstanceOfType(expression, typeof(InvokeExpressionExpression)); InvokeExpressionExpression invexp = (InvokeExpressionExpression)expression; Assert.IsInstanceOfType(invexp.Expression, typeof(InvokeExpression)); Assert.AreEqual(1, invexp.Arguments.Count); Assert.IsInstanceOfType(invexp.Arguments.First(), typeof(ConstantExpression)); }