Example #1
0
        public ForAction(ParseInfo parseInfo, Scope scope, DeltinScriptParser.ForContext forContext)
        {
            Scope varScope = scope.Child();

            if (forContext.define() != null)
            {
                DefinedVariable = new ScopedVariable(varScope, new DefineContextHandler(parseInfo, forContext.define()));
            }
            else if (forContext.initialVarset != null)
            {
                InitialVarSet = new SetVariableAction(parseInfo, varScope, forContext.initialVarset);
            }

            if (forContext.expr() != null)
            {
                Condition = parseInfo.GetExpression(varScope, forContext.expr());
            }

            if (forContext.endingVarset != null)
            {
                SetVariableAction = new SetVariableAction(parseInfo, varScope, forContext.endingVarset);
                RawContinue       = false;
            }
            else
            {
                RawContinue = true;
            }

            // Get the block.
            if (forContext.block() != null)
            {
                Block = new BlockAction(parseInfo.SetLoop(this), varScope, forContext.block());
                // Get the path info.
                Path = new PathInfo(Block, DocRange.GetRange(forContext.FOR()), false);
            }
            else
            {
                parseInfo.Script.Diagnostics.Error("Expected a block.", DocRange.GetRange(forContext.RIGHT_PAREN()));
            }
        }
        public ForAction(ParseInfo parseInfo, Scope scope, DeltinScriptParser.ForContext forContext)
        {
            Scope varScope = scope.Child();

            if (forContext.define() != null)
            {
                DefinedVariable = Var.CreateVarFromContext(VariableDefineType.Scoped, parseInfo, forContext.define());
                DefinedVariable.Finalize(varScope);
            }
            else if (forContext.initialVarset != null)
            {
                InitialVarSet = new SetVariableAction(parseInfo, varScope, forContext.initialVarset);
            }

            if (forContext.expr() != null)
            {
                Condition = DeltinScript.GetExpression(parseInfo, varScope, forContext.expr());
            }

            if (forContext.endingVarset != null)
            {
                SetVariableAction = new SetVariableAction(parseInfo, varScope, forContext.endingVarset);
            }

            // Get the block.
            if (forContext.block() != null)
            {
                Block = new BlockAction(parseInfo, varScope, forContext.block());
                // Get the path info.
                Path = new PathInfo(Block, DocRange.GetRange(forContext.FOR()), false);
            }
            else
            {
                parseInfo.Script.Diagnostics.Error("Expected a block.", DocRange.GetRange(forContext.RIGHT_PAREN()));
            }
        }