Ejemplo n.º 1
0
 /// <summary>
 ///     Visits a STABILIZE expression
 /// </summary>
 /// <param name="stabilizeExpression"></param>
 protected virtual void VisitStabilizeExpression(StabilizeExpression stabilizeExpression)
 {
     if (stabilizeExpression != null)
     {
         VisitExpression(stabilizeExpression.Expression);
         VisitExpression(stabilizeExpression.Condition);
         VisitExpression(stabilizeExpression.InitialValue);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Evaluates a unary expression
        ///  . NOT expression
        ///  . Term
        /// </summary>
        /// <param name="enclosing"></param>
        /// <returns></returns>
        private Expression EvaluateUnaryExpression()
        {
            Expression retVal = null;

            string unaryOp = LookAhead(UnaryExpression.UNARY_OPERATORS);

            if (unaryOp != null)
            {
                Match(unaryOp);
                Expression expression = Expression(6);
                retVal = new UnaryExpression(Root, expression, unaryOp);
            }
            else
            {
                if (LookAhead("STABILIZE"))
                {
                    Match("STABILIZE");
                    Expression expression = Expression(0);
                    Match("INITIAL_VALUE");
                    Expression initialValue = Expression(0);
                    Match("STOP_CONDITION");
                    Expression condition = Expression(0);

                    retVal = new StabilizeExpression(Root, expression, initialValue, condition);
                }
                else
                {
                    retVal = EvaluateStructure();
                    if (retVal == null)
                    {
                        retVal = EvaluateFunction();
                    }
                    if (retVal == null)
                    {
                        Term term = Term();
                        if (term != null)
                        {
                            retVal = new UnaryExpression(Root, term);
                        }
                        else if (LookAhead("("))
                        {
                            Match("(");
                            retVal = new UnaryExpression(Root, Expression(0));
                            Match(")");

                            if (retVal != null)
                            {
                                retVal = Continuation(retVal);
                            }
                        }
                    }
                }
            }

            return(retVal);
        }
Ejemplo n.º 3
0
 /// <summary>
 ///     Visits a STABILIZE expression
 /// </summary>
 /// <param name="stabilizeExpression"></param>
 protected virtual void VisitStabilizeExpression(StabilizeExpression stabilizeExpression)
 {
     if (stabilizeExpression != null)
     {
         VisitExpression(stabilizeExpression.Expression);
         VisitExpression(stabilizeExpression.Condition);
         VisitExpression(stabilizeExpression.InitialValue);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        ///     Evaluates a unary expression
        ///     . NOT expression
        ///     . Term
        /// </summary>
        /// <returns></returns>
        private Expression EvaluateUnaryExpression()
        {
            Expression retVal;

            SkipWhiteSpaces();
            int start = Index;
            string unaryOp = LookAhead(UnaryExpression.UnaryOperators);
            if (unaryOp != null)
            {
                Match(unaryOp);
                Expression expression = Expression(6);
                retVal = new UnaryExpression(Root, RootLog, expression, unaryOp, start, Index);
            }
            else
            {
                if (LookAhead("STABILIZE"))
                {
                    Match("STABILIZE");
                    Expression expression = Expression(0);
                    Match("INITIAL_VALUE");
                    Expression initialValue = Expression(0);
                    Match("STOP_CONDITION");
                    Expression condition = Expression(0);

                    retVal = new StabilizeExpression(Root, RootLog, expression, initialValue, condition, start, Index);
                }
                else
                {
                    retVal = EvaluateStructure();
                    if (retVal == null)
                    {
                        retVal = EvaluateFunction();
                    }
                    if (retVal == null)
                    {
                        Term term = Term();
                        if (term != null)
                        {
                            retVal = new UnaryExpression(Root, RootLog, term, start, Index);
                        }
                        else if (LookAhead("("))
                        {
                            Match("(");
                            retVal = new UnaryExpression(Root, RootLog, Expression(0), null, start, -1);
                            Match(")");
                            retVal.End = Index;

                            retVal = Continuation(retVal);
                        }
                    }
                }
            }

            return retVal;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Evaluates a unary expression
        ///  . NOT expression
        ///  . Term
        /// </summary>
        /// <param name="enclosing"></param>
        /// <returns></returns>
        private Expression EvaluateUnaryExpression()
        {
            Expression retVal = null;

            string unaryOp = LookAhead(UnaryExpression.UNARY_OPERATORS);
            if (unaryOp != null)
            {
                Match(unaryOp);
                Expression expression = Expression(6);
                retVal = new UnaryExpression(Root, expression, unaryOp);
            }
            else
            {
                if (LookAhead("STABILIZE"))
                {
                    Match("STABILIZE");
                    Expression expression = Expression(0);
                    Match("INITIAL_VALUE");
                    Expression initialValue = Expression(0);
                    Match("STOP_CONDITION");
                    Expression condition = Expression(0);

                    retVal = new StabilizeExpression(Root, expression, initialValue, condition);
                }
                else
                {
                    retVal = EvaluateStructure();
                    if (retVal == null)
                    {
                        retVal = EvaluateFunction();
                    }
                    if (retVal == null)
                    {
                        Term term = Term();
                        if (term != null)
                        {
                            retVal = new UnaryExpression(Root, term);
                        }
                        else if (LookAhead("("))
                        {
                            Match("(");
                            retVal = new UnaryExpression(Root, Expression(0));
                            Match(")");

                            if (retVal != null)
                            {
                                retVal = Continuation(retVal);
                            }
                        }
                    }
                }
            }

            return retVal;
        }