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 = 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.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 ForNode(DeltinScriptParser.ForContext context, BuildAstVisitor visitor) : base(new Location(visitor.file, DocRange.GetRange(context))) { errorRange = new Location(visitor.file, DocRange.GetRange(context.FOR())); Block = (BlockNode)visitor.VisitBlock(context.block()); if (context.varset() != null) { VarSetNode = (VarSetNode)visitor.VisitVarset(context.varset()); } if (context.define() != null) { DefineNode = (DefineNode)visitor.VisitDefine(context.define()); } if (context.expr() != null) { Expression = visitor.VisitExpr(context.expr()); } if (context.forEndStatement() != null) { Statement = (VarSetNode)visitor.VisitVarset(context.forEndStatement().varset()); } }