public override Node VisitFor(DeltinScriptParser.ForContext context)
        {
            BlockNode block = (BlockNode)VisitBlock(context.block());

            VarSetNode varSet = null;

            if (context.varset() != null)
            {
                varSet = (VarSetNode)VisitVarset(context.varset());
            }

            DefineNode defineNode = null;

            if (context.define() != null)
            {
                defineNode = (DefineNode)VisitDefine(context.define());
            }

            Node expression = null;

            if (context.expr() != null)
            {
                expression = VisitExpr(context.expr());
            }

            VarSetNode statement = null;

            if (context.forEndStatement() != null)
            {
                statement = (VarSetNode)VisitVarset(context.forEndStatement().varset());
            }

            return(new ForNode(varSet, defineNode, expression, statement, block, new Location(file, Range.GetRange(context))));
        }
        void ParseDefine(ScopeGroup getter, ScopeGroup scope, DefineNode defineNode)
        {
            IndexedVar var;

            if (!defineNode.Extended)
            {
                var = IndexedVar.AssignVar(VarCollection, scope, defineNode.VariableName, IsGlobal, defineNode);
            }
            else
            {
                var = IndexedVar.AssignVarExt(VarCollection, scope, defineNode.VariableName, IsGlobal, defineNode);
            }

            // Set the defined variable if the variable is defined like "define var = 1"
            Element[] inScopeActions = var.InScope(defineNode.Value != null ? ParseExpression(getter, scope, defineNode.Value) : null);
            if (inScopeActions != null)
            {
                Actions.AddRange(inScopeActions);
            }

            if (defineNode.Type != null)
            {
                var.Type = ParserData.GetDefinedType(defineNode.Type, defineNode.Location);
            }
        }
 public ForNode(VarSetNode varSetNode, DefineNode defineNode, Node expression, VarSetNode statement, BlockNode block, Location location) : base(location)
 {
     VarSetNode = varSetNode;
     DefineNode = defineNode;
     Expression = expression;
     Statement  = statement;
     Block      = block;
 }