public static ParsnipModel Go(ParsnipModel model) { var oldRules = model.Rules; foreach (var oldRule in oldRules) { var interfaceMethodName = NameGen.InterfaceMethodName(oldRule.RuleIdentifier); var vis = new Visitor(interfaceMethodName); (var newFunc, var newMethods) = oldRule.ParseFunction.ApplyVisitor(vis, oldRule.ReturnType); var newRule = oldRule.WithParseFunction(newFunc); model = model.ReplacingRule(oldRule, newRule); foreach (var method in newMethods) { model = model.AddingInterfaceMethod(method); } } return(model); }