LET variable <- expression IN expression LET variable '=>' expression IN expression
Inheritance: Expression, ISubDeclarator
Exemplo n.º 1
0
 /// <summary>
 ///     Visits a let expression
 /// </summary>
 /// <param name="letExpression"></param>
 protected virtual void VisitLetExpression(LetExpression letExpression)
 {
     if (letExpression.BindingExpression != null)
     {
         VisitExpression(letExpression.BindingExpression);
     }
     if (letExpression.Expression != null)
     {
         VisitExpression(letExpression.Expression);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 ///     Visits a let expression
 /// </summary>
 /// <param name="letExpression"></param>
 protected virtual void VisitLetExpression(LetExpression letExpression)
 {
     if (letExpression.BindingExpression != null)
     {
         VisitExpression(letExpression.BindingExpression);
     }
     if (letExpression.Expression != null)
     {
         VisitExpression(letExpression.Expression);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        ///     Provides the parse tree associated to the expression stored in the buffer
        /// </summary>
        /// <param name="expressionLevel">the current level of the expression</param>
        /// <returns></returns>
        private Expression Expression(int expressionLevel)
        {
            Expression retVal = null;

            if (expressionLevel == 0 && LookAhead("LET"))
            {
                int start = Index;

                Match("LET");
                string boundVariable = Identifier();

                string assignOp = LookAhead(AssignOps);
                if (assignOp != null)
                {
                    Match(assignOp);
                    Expression bindinExpression = Expression(0);
                    if (bindinExpression != null)
                    {
                        Match("IN");
                        Expression expression = Expression(0);
                        if (expression != null)
                        {
                            retVal = new LetExpression(Root, RootLog, boundVariable, bindinExpression, expression, start,
                                Index);
                        }
                        else
                        {
                            RootLog.AddError("Cannot parse expression after IN keyword");
                        }
                    }
                    else
                    {
                        RootLog.AddError("Cannot parse expression after " + boundVariable + " " + assignOp + " ");
                    }
                }
                else
                {
                    RootLog.AddError("<- or => expected after " + boundVariable);
                }
            }
            else
            {
                switch (expressionLevel)
                {
                    case 0:
                    case 1:
                    case 2:
                    case 3:
                    case 4:
                    case 5:
                        //
                        // Binary expressions
                        //
                        retVal = Expression(expressionLevel + 1);
                        if (retVal != null)
                        {
                            retVal = ExpressionContinuation(expressionLevel, retVal);
                        }
                        break;

                    case 6:
                        // Continuation, either by . operator, or by function call
                        retVal = Continuation(Expression(expressionLevel + 1));
                        break;

                    case 7:
                        //
                        // List operations
                        //
                        retVal = EvaluateListExpression();
                        if (retVal == null)
                        {
                            //
                            // Unary expressions
                            //
                            retVal = EvaluateUnaryExpression();
                        }
                        break;
                }
            }

            return retVal;
        }
Exemplo n.º 4
0
 /// <summary>
 ///     Visits a let expression
 /// </summary>
 /// <param name="letExpression"></param>
 protected virtual void VisitLetExpression(LetExpression letExpression)
 {
     if (letExpression.BindingExpression != null)
     {
         VisitInterpreterTreeNode(letExpression.BindingExpression);
     }
     if (letExpression.Expression != null)
     {
         VisitInterpreterTreeNode(letExpression.Expression);
     }
 }