//Yield implementation private void generateYield_CheckedChanged(object sender, RoutedEventArgs e) { if (generateYield.IsChecked == true) { IGenerator generator = new YieldGenerator(); PopulateGUIcul(generator, DisplayBoxYield, ElapsedTimeYield, NumberOfList, getFail, TimeDelayEstimate, NormalEstimate); } }
public Block Compile() { var position = initialPosition; var previousPosition = initialPosition; InitialPosition = initialPosition; var block = new Block(); var scanning = true; var yieldCount = 0; var parsers = new List <Parser> { new MultilineCommentParser(), new SingleLineCommentParser(), new NoEndParser(), new EndBlockParser(endOfBlock, consumeEndOfBlock), new EndParser(endOfBlock == REGEX_END), //new AnonymousObjectParser(), new SomeParser(), new ClassParser(), new TypeParser(), new StaticParser(), new TraitParser(), new NullOpParser(), new HexParser(), new BinParser(), new OctParser(), new FloatParser(), new IntegerParser(), new StringParser(), new FillInBlockParser(), new InterpolatedStringParser(), new ArrayLiteralParser(), //new ArrayParametersParser(), new DateParser(), //new IndexParser(), new TypeNameParser(), new SpecialValueParser(), new ChangeSignParser(), new PreIncrementDecrementParser(), new ReadOnlyParser(), new ReferenceParser(), new SymbolParser(), new SendMessageParser(), //new MessageBlockParser(), new AbstractParser(), new AutoPropertyParser(), new InitBlockParser(), new LetParser(), new MacroParser(), new OperatorParser(), new ListParser(), new FunctionParser(), new DefineExpressionParser(), new NewObjectParser(), new FunctionInvokeParser(), new DefineParser(), new EnumerationValueParser(), new DelegateParser(), new PlainSignalParser(), //new ScalarParser(), new IsDefinedParser(), //new ApplyInvokeParser(), new RegexParser(), new MessageArgumentParser(), //new AlternateLambdaParser(), new MacroLiteralParser(), new DeferredParser(), new ThreeCharacterOperatorParser(), new TwoCharacterOperatorParser(), new OneCharacterOperatorParser(), new InvokeParser(), new PrintBlockParser(), new GeneratorParser(), new EmptyArrayLiteralParser(), //new BlockParser(true), new PatternParser(), new IndexerParser(), new FormatLiteralParser(), new LazyBlockParser(), new IfParser(), new MatchParser(), new WhileParser(), new WithParser(), new WhereParser(), new CForParser(), new AssertParser(), new ShortCircuitBooleanParser(), new DisjoinMessageParser(), new WordOperatorParser(), new VariableParser() }; while (position < sourceLength && scanning) { if (Verbose) { verboseText.WriteLine($"Scanning {source.Skip(position)}"); } scanning = false; var found = false; foreach (var parser in parsers.Where(p => p.Scan(source, position))) { var result = parser.Result; if (result.Verb != null && !(result.Verb is NullOp)) { if (result.Verb is Yield) { yieldCount++; } block.Add(result.Verb); if (result.Next != null) { block.Add(result.Next); result.Next = null; } if (Verbose) { verboseText.WriteLine($" Found {parser.VerboseName}"); } } if (result.Verbs != null && result.Verbs.Count > 0) { foreach (var verb in result.Verbs) { if (verb is Yield) { yieldCount++; } block.Add(verb); } result.Verbs.Clear(); if (Verbose) { verboseText.WriteLine($" Found {parser.VerboseName}"); } } position = result.Position; (position != -1).Assert("-1?"); scanning = !parser.EndOfBlock; found = true; break; } var substring = source.Substring(position); found.Assert($"Orange compiler: Didn't understand \"{substring.Substitute("/s+", " ").TrimAll()}\""); (position != previousPosition || !scanning).Assert("Orange compiler: Scanning position has not changed"); previousPosition = position; } (initialPosition > 0 && scanning && endOfBlock != REGEX_END).Reject("End of block not found"); if (IsDebugging && initialPosition == 0) { DebuggingState.Final(); } lastPosition = position; if (yieldCount > 1) { var blockGenerator = new YieldGenerator(block); block = PushValue(blockGenerator); var generator = new Generator(VAR_MANGLE + "b", block); block = PushValue(generator); } block.YieldCount = yieldCount; return(block); }