private SpokeMethodCall checkRunMacro(TokenEnumerator enumerator, int tabIndex, evalInformation inf) { //tm. for (int index = 0; ; index++) { gombo: if (index >= allMacros_.Count) break; var tokenMacroPiece = allMacros_[index]; List<SpokeItem> parameters = new List<SpokeItem>(); var tm = enumerator.Clone(); var outs = tm.OutstandingLine; bool bad = false; for (int i = 0; i < tokenMacroPiece.Macro.Length; i++) { var mp = tokenMacroPiece.Macro[i]; if (mp.Type == Token.Ampersand) { for (int j = i + 1; j < tokenMacroPiece.Macro.Length; j++) { var r = tokenMacroPiece.Macro[j]; if (!outs.Any(a => r.Type == Token.Ampersand || (a.Type == r.Type && (a.Type == Token.Word && r.Type == Token.Word ? ((TokenWord)a).Word == ((TokenWord)r).Word : true)))) { bad = true; break; } } if (bad) { break; } var frf = tokenMacroPiece.Macro.Length == i + 1 ? new TokenNewLine() : tokenMacroPiece.Macro[i + 1]; int selectedLine = 0; IToken tp = null; int selectedToken = tm.tokenIndex; if (frf.Type != Token.NewLine) { for (int j = 0; j < tm.CurrentLines.Count; j++) { for (int ic = selectedToken; ic < tm.CurrentLines[j].Tokens.Count; ic++) { var a = tm.CurrentLines[j].Tokens[ic]; if (tm.CurrentLines[j].Tokens[ic].Type == frf.Type && (a.Type == frf.Type && (a.Type == Token.Word && frf.Type == Token.Word ? ((TokenWord)a).Word == ((TokenWord)frf).Word : true))) { tp = tm.CurrentLines[j].Tokens[ic]; break; } } if (tp != null) { selectedLine = j; break; } else { selectedToken = 0; } } var bf = new TokenAmpersand(); tm.CurrentLines[selectedLine].Tokens.Insert(tm.CurrentLines[selectedLine].Tokens.IndexOf(tp), bf); try { CurrentItem = null; var d = eval(tm, tabIndex, new evalInformation(inf) { CheckMacs = inf.CheckMacs + 1, DontEvalEquals = true, BreakBeforeEqual = true }); parameters.Add((SpokeItem)d); if (d == null || (!(tm.Current.Type == Token.Ampersand || tokenMacroPiece.Macro.Length == i + 1))) { index++; goto gombo; } } catch (Exception e) { index++; goto gombo; } tm.CurrentLine.Tokens.Remove(bf); } else { try { CurrentItem = null; var d = eval(tm, tabIndex, new evalInformation(inf) { CheckMacs = inf.CheckMacs + 1, DontEvalEquals = true, BreakBeforeEqual = true }); parameters.Add((SpokeItem)d); if (d == null) { index++; goto gombo; } } catch (Exception e) { index++; goto gombo; } } } else { if (mp.Type == tm.Current.Type && (mp.Type == Token.Word && tm.Current.Type == Token.Word ? ((TokenWord)mp).Word == ((TokenWord)tm.Current).Word : true)) { tm.MoveNext(); } else { bad = true; break; } } } if (!bad) { SpokeMethodCall ambe = new SpokeMethodCall(); SpokeAnonMethod me = new SpokeAnonMethod(); me.SpecAnon = true; me.Parameters = tokenMacroPiece.Parameters; me.Lines = getLines(new TokenEnumerator(tokenMacroPiece.Lines.ToArray()), 1, inf).ToArray(); me.HasYieldReturn = linesHave(me.Lines, ISpokeLine.YieldReturn); me.HasYield = linesHave(me.Lines, ISpokeLine.Yield); me.HasReturn = linesHave(me.Lines, ISpokeLine.Return); ambe.Parent = me; parameters.Insert(0, new SpokeCurrent()); ambe.Parameters = parameters.ToArray(); enumerator.Set(tm); return ambe; } } return null; }