Example #1
0
        private Expression ParseBlock()
        {
            ExpressionTypeBeam.PushBlockScope();
            ConsumeWS();
            Expression        C1      = null;
            List <Expression> BlockCT = new List <Expression>();
            bool ct = true;

            do
            {
                BlockCT.Add(C1);
                C1 = ParseBoolean();

                ct = !EOF && (!(C1 is AutExpression) || (C1 as AutExpression).ExpressionType != AutExpressionType.EndOfBlock);
                if (ct)
                {
                    NextLine();
                }
            } while (ct);

            return(Expression.Block(ExpressionTypeBeam.PopScope(), BlockCT.Where(x => x != null)));
        }
Example #2
0
        private Expression ParseKeyword_IF(string Keyword)
        {
            var Element = ParseBoolean(false).ConvertTo(typeof(bool));

            ConsumeWS();
            if (Peek(4).ToUpper() == "THEN")
            {
                Consume(4);
                ConsumeWS();
                if (!EOL)
                {
                    ExpressionTypeBeam.PushBlockScope();
                    var Exp = ParseBoolean();
                    Exp = Expression.Block(ExpressionTypeBeam.PopScope(), Exp);
                    NextLine(); ConsumeWS();
                    if (Peek(6).ToUpper() == "ELSEIF")
                    {
                        Consume(6); return(Expression.IfThenElse(Element, Exp, ParseKeyword_IF(Keyword)));
                    }
                    else if (Peek(4).ToUpper() == "ELSE")
                    {
                        Consume(4);
                        ExpressionTypeBeam.PushBlockScope();
                        var e2 = ParseBoolean();
                        return(Expression.IfThenElse(Element, Exp, Expression.Block(ExpressionTypeBeam.PopScope(), e2)));
                    }
                    else
                    {
                        NextLine(-1); return(Expression.IfThen(Element, Exp));
                    }
                }
                else if (!INTERCATIVE)
                {
                    Expression Condition   = Element;
                    Expression Instruction = ParseBlock();
                    Seek();
                    ConsumeWS();
                    var s = Getstr(Reg_AlphaNum).ToUpper();
                    switch (s)
                    {
                    case "ELSE":
                        Expression Otherwise = ParseBlock();
                        Seek();
                        ConsumeWS();
                        return(Expression.IfThenElse(Condition, Instruction, Otherwise));

                    case "ELSEIF":
                        return(Expression.IfThenElse(Condition, Instruction, ParseKeywordOrFunc("IF")));

                    default:
                        return(Expression.IfThen(Condition, Instruction));
                    }
                }
                else
                {
                    throw new AutoitException(AutoitExceptionType.MULTILINEININTERACTIVE, LineNumber, Cursor, Keyword);
                }
            }
            else
            {
                throw new AutoitException(AutoitExceptionType.MISSINGTHEN, LineNumber, Cursor, ScriptLine);
            }
        }