public ForeachAction(ParseInfo parseInfo, Scope scope, DeltinScriptParser.ForeachContext foreachContext) { RawContinue = false; Scope varScope = scope.Child(); ForeachVar = new ForeachVariable(varScope, new ForeachContextHandler(parseInfo, foreachContext)); // Get the array that will be iterated on. Syntax error if it is missing. if (foreachContext.expr() != null) { Array = parseInfo.GetExpression(scope, foreachContext.expr()); } else { parseInfo.Script.Diagnostics.Error("Expected expression.", DocRange.GetRange(foreachContext.IN())); } // Get the foreach block. Syntax error if it is missing. if (foreachContext.block() != null) { Block = new BlockAction(parseInfo.SetLoop(this), varScope, foreachContext.block()); // Get the path info. Path = new PathInfo(Block, DocRange.GetRange(foreachContext.FOREACH()), false); } else { parseInfo.Script.Diagnostics.Error("Expected block.", DocRange.GetRange(foreachContext.RIGHT_PAREN())); } }
public ForeachAction(ParseInfo parseInfo, Scope scope, DeltinScriptParser.ForeachContext foreachContext) { Scope varScope = scope.Child(); ForeachVar = new Var(foreachContext.name.Text, new Location(parseInfo.Script.Uri, DocRange.GetRange(foreachContext.name)), parseInfo); ForeachVar.VariableType = VariableType.ElementReference; ForeachVar.CodeType = CodeType.GetCodeTypeFromContext(parseInfo, foreachContext.code_type()); ForeachVar.Finalize(varScope); // Get the array that will be iterated on. Syntax error if it is missing. if (foreachContext.expr() != null) { Array = DeltinScript.GetExpression(parseInfo, scope, foreachContext.expr()); } else { parseInfo.Script.Diagnostics.Error("Expected expression.", DocRange.GetRange(foreachContext.IN())); } // Get the foreach block. Syntax error if it is missing. if (foreachContext.block() != null) { Block = new BlockAction(parseInfo, varScope, foreachContext.block()); // Get the path info. Path = new PathInfo(Block, DocRange.GetRange(foreachContext.FOREACH()), false); } else { parseInfo.Script.Diagnostics.Error("Expected block.", DocRange.GetRange(foreachContext.RIGHT_PAREN())); } }