Exemplo n.º 1
0
            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);
            }
Exemplo n.º 2
0
            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));
            }
Exemplo n.º 3
0
 public static Selection AddingStep(this Selection selection, SelectionStep step) => new Selection(selection.Steps.Appending(step));