public ParsnipModel Visit(SyntacticModel.Rule target) { var ruleID = target.Head.RuleIdentifier.Text; var className = target.Head.ClassIdentifier?.Text; var returnType = GetNodeType(className); var rule = new Rule(ruleID, returnType, null); model = model.AddingRule(rule); return(model); }
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 ParsnipModel Visit(SyntacticModel.Rule target) => model;