internal static Selection VisitUnion(SyntacticModel.Union union, Boolean isMemoized, ParsnipModel model) { var selection = new Selection(new SelectionStep[0]); foreach (var sequence in union.Sequences) { var func = VisitSequence(sequence, false, model); var step = new SelectionStep(func, interfaceMethod: null); selection = selection.AddingStep(step); } return(selection); }
public ParsnipModel Visit(SyntacticModel.Rule target) { var oldRule = model.Rules.First(i => i.RuleIdentifier == target.Head.RuleIdentifier.Text); var selection = new Selection(new SelectionStep[0]); foreach (var choice in target.Body.Choices) { var func = VisitChoice(choice, false, model); var step = new SelectionStep(func, interfaceMethod: null); selection = selection.AddingStep(step); } var newRule = oldRule.WithParseFunction(selection); return(model = model.ReplacingRule(oldRule, newRule)); }
public static Selection AddingStep(this Selection selection, SelectionStep step) => new Selection(selection.Steps.Appending(step));