public Expression Visit(ParserApp app) { Expression lambda = app.Lambda.Accept(this); Expression expr = app.Expression.Accept(this); return(new Apply(lambda as AbstractLambdaExpression, expr)); }
public ParserType Visit(ParserApp app) { var lambdaType = app.Lambda.Accept(this); var expr = app.Expression.Accept(this); if (!(lambdaType is ParserLambdaType)) { throw new ArgumentException("In an application left expression must be a lambda. Type: " + lambdaType.ToString()); } ParserLambdaType lambda = lambdaType as ParserLambdaType; if (!lambda.InputType.Equivalent(expr)) { throw new ArgumentException(String.Format( "In an application the type of the right expression must match the type of the bound variable " + "Expr type: {0} Variable type: {1}", expr.ToString(), lambda.InputType.ToString())); } ParserType logicType = new ParserLogicType(); app.Type = logicType; return(logicType); }