/// <summary> /// Override this method if you do not want to include it as a function. /// Overriding this must contain {TryParse(args,true)} or you won't get anywhere! /// </summary> /// <param name="args"></param> /// <param name="findFor"></param> protected virtual void ForExtension(TFunction caller, ExtensionFor findFor) { this.IsLoop = true; string[] forNumber = findFor.Extend(); int forNumberAsNumber = int.Parse(forNumber[0]); var tracer = new LoopTracer(); Compiler.LoopTracerStack.Add(tracer); if (forNumberAsNumber <= 0) { forNumberAsNumber = int.MaxValue; } for (var x = 0; x < forNumberAsNumber; x++) { if (!TokenParser.Stop) { if (tracer.Break) { break; } if (tracer.Continue) { tracer.SetContinue(false);//reset continue } caller.SetTracer(tracer); TryParse(caller, true); } else { break; } } Compiler.LoopTracerStack.Remove(tracer); tracer = null; }
protected override void ForExtension(TFunction caller, ExtensionFor findFor) { Compiler.ExceptionListener.Throw(new ExceptionHandler(ExceptionType.CompilerException, $"Cannot call 'For' on {this.Name}.", LineValue)); }
//stop the base for looping extension from overriding this custom looping function protected override void ForExtension(TFunction caller, ExtensionFor findFor) { TryParse(caller, true); }