Esempio n. 1
0
        private List <Expression> ParseBlock(bool RestoreAfter = false)
        {
            Expression        Element;
            List <Expression> Instruction = new List <Expression>();

            KeyValuePair <string, List <Type> >[] Snap = null;
            if (RestoreAfter)
            {
                Snap = ExpressionTypeBeam.TakeSnapshot();
            }
            do
            {
                NextLine();
                Element = ParseBoolean();
                if (!(Element is AutExpression) || (Element as AutExpression).ExpressionType != AutExpressionType.EndOfBlock)
                {
                    Instruction.Add(Element);
                }
            }while (!(Element is AutExpression) || (Element as AutExpression).ExpressionType != AutExpressionType.EndOfBlock);
            if (RestoreAfter)
            {
                ExpressionTypeBeam.RestoreSnapshot(Snap);
                Seek();
                ConsumeWS();
            }
            return(Instruction);
        }
Esempio n. 2
0
 private Expression ParseKeyword_DO(string Keyword)
 {
     if (!INTERCATIVE)
     {
         var snap      = ExpressionTypeBeam.TakeSnapshot();
         var @break    = Expression.Label("break");
         var @continue = Expression.Label("continue");
         Contextual.Push(Expression.Goto(@break));
         Contextual.Push(Expression.Goto(@continue));
         List <Expression> Instruction = new List <Expression>();
         Instruction.Add(Expression.Label(@continue));
         Instruction.AddRange(ParseBlock(true));
         LineNumber--;
         if (Peek(5).ToUpper() != "UNTIL")
         {
             throw new AutoitException(AutoitExceptionType.EXPECTUNTIL, LineNumber, Cursor, Getstr(Reg_AlphaNum));
         }
         Consume(5);
         ConsumeWS();
         var Cond = Expression.Not(ParseBoolean(false).ConvertTo(typeof(bool)));
         //Instruction.AddRange(VarSynchronisation);
         //VarSynchronisation.Clear();
         Instruction.Add(Expression.IfThen(Cond, Expression.Goto(@continue)));
         Instruction.Add(Expression.Label(@break));
         Instruction.Add(ExpressionTypeBeam.RestoreSnapshot(snap));
         Contextual.Pop();
         Contextual.Pop();
         return(Expression.Block(Instruction.ToArray()));
     }
     else
     {
         throw new AutoitException(AutoitExceptionType.MULTILINEININTERACTIVE, LineNumber, Cursor, Keyword);
     }
 }
Esempio n. 3
0
        private Expression ParseKeyword_WHILE(string Keyword)
        {
            var Element = ParseBoolean(false).ConvertTo(typeof(bool));
            var snap    = ExpressionTypeBeam.TakeSnapshot();

            ConsumeWS();
            if (!EOL)
            {
                var @break    = Expression.Label();
                var @continue = Expression.Label();
                return(Expression.Block(
                           Expression.Label(@continue),
                           Expression.IfThen(Expression.Not(Element), Expression.Goto(@break)),
                           ParseBoolean(),
                           Expression.Goto(@continue),
                           Expression.Label(@break)));
            }
            else if (!INTERCATIVE)
            {
                var @break    = Expression.Label("break");
                var @continue = Expression.Label("continue");
                Contextual.Push(Expression.Goto(@break));
                Contextual.Push(Expression.Goto(@continue));
                List <Expression> Instruction = new List <Expression>();
                Instruction.Add(Expression.Label(@continue));
                Instruction.Add(Expression.IfThen(Expression.Not(Element), Expression.Goto(@break)));
                Instruction.AddRange(ParseBlock(true));
                Instruction.Add(Expression.Goto(@continue));
                Instruction.Add(Expression.Label(@break));
                Instruction.Add(ExpressionTypeBeam.RestoreSnapshot(snap));
                Contextual.Pop();
                Contextual.Pop();
                return(Expression.Block(Instruction.ToArray()));
            }
            else
            {
                throw new AutoitException(AutoitExceptionType.MULTILINEININTERACTIVE, LineNumber, Cursor, Keyword);
            }
        }