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 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 WhileAction(ParseInfo parseInfo, Scope scope, While whileContext) { RawContinue = true; Condition = parseInfo.GetExpression(scope, whileContext.Condition); Block = parseInfo.SetLoop(this).GetStatement(scope, whileContext.Statement); Path = new PathInfo(Block, whileContext.Range, false); }
public WhileAction(ParseInfo parseInfo, Scope scope, DeltinScriptParser.WhileContext whileContext) { if (whileContext.expr() == null) { parseInfo.Script.Diagnostics.Error("Expected expression.", DocRange.GetRange(whileContext.LEFT_PAREN())); } else { Condition = DeltinScript.GetExpression(parseInfo, scope, whileContext.expr()); } Block = new BlockAction(parseInfo.SetLoop(this), scope, whileContext.block()); Path = new PathInfo(Block, DocRange.GetRange(whileContext.WHILE()), false); }
public AutoForAction(ParseInfo parseInfo, Scope scope, DeltinScriptParser.For_autoContext autoForContext) { RawContinue = true; // Get the auto-for variable. (Required) if (autoForContext.forVariable != null) { IExpression variable = parseInfo.GetExpression(scope, autoForContext.forVariable); // Get the variable being set. VariableResolve = new VariableResolve(new VariableResolveOptions() { // The for cannot be indexed and should be on the rule-level. CanBeIndexed = false, FullVariable = true }, variable, DocRange.GetRange(autoForContext.forVariable), parseInfo.Script.Diagnostics); if (autoForContext.EQUALS() != null) { if (autoForContext.start == null) { parseInfo.Script.Diagnostics.Error("Expected expression.", DocRange.GetRange(autoForContext.EQUALS())); } else { InitialResolveValue = parseInfo.GetExpression(scope, autoForContext.start); } } } // Get the defined variable. else if (autoForContext.forDefine != null) { DefinedVariable = new AutoForVariable(scope, new DefineContextHandler(parseInfo, autoForContext.forDefine)); } else { parseInfo.Script.Diagnostics.Error("Expected define or variable.", DocRange.GetRange(autoForContext.FOR())); } // Get the auto-for end. (Required) if (autoForContext.stop == null) { parseInfo.Script.Diagnostics.Error("Expected end expression.", DocRange.GetRange(autoForContext.startSep)); } else { Stop = parseInfo.GetExpression(scope, autoForContext.stop); } // Get the auto-for step. (Not Required) if (autoForContext.step == null) { Step = new ExpressionOrWorkshopValue(new V_Number(1)); } else { Step = new ExpressionOrWorkshopValue(parseInfo.GetExpression(scope, autoForContext.step)); } // Get the block. if (autoForContext.block() == null) { parseInfo.Script.Diagnostics.Error("Missing block.", DocRange.GetRange(autoForContext.RIGHT_PAREN())); } else { Block = new BlockAction(parseInfo.SetLoop(this), scope, autoForContext.block()); Path = new PathInfo(Block, DocRange.GetRange(autoForContext.block()), false); } }