/// <summary>Given Rules paired with LNodes produced by <see cref="StageOneParser"/>, /// this method translates each LNode into a <see cref="Pred"/> and updates /// <see cref="Rule.Pred"/> to point to the new Pred.</summary> public void Parse(IEnumerable <Pair <Rule, LNode> > rules) { _rules = LLParserGenerator.AddRulesToDict(rules.Select(p => p.A)); foreach (var pair in rules) { Debug.Assert(pair.A.Pred == null); pair.A.Pred = NodeToPred(pair.B); if (pair.A.HasRecognizerVersion) // oops, need to keep recognizer in sync with main rule { pair.A.MakeRecognizerVersion().Pred = pair.A.Pred; } } Remove_any_in_Labels(); }
/// <summary>Given Rules paired with LNodes produced by <see cref="StageOneParser"/>, /// this method translates each LNode into a <see cref="Pred"/> and updates /// <see cref="Rule.Pred"/> to point to the new Pred.</summary> public void Parse(IEnumerable <Pair <Rule, LNode> > rules) { _rules = LLParserGenerator.AddRulesToDict(rules.Select(p => p.A)); foreach (var pair in rules) { Debug.Assert(pair.A.Pred == null); _parsingRecognizerVersion = _ruleChangesInRecognizer = false; pair.A.Pred = NodeToPred(pair.B); if (_ruleChangesInRecognizer) { _parsingRecognizerVersion = true; pair.A.GetOrMakeRecognizerVersion().Pred = NodeToPred(pair.B); } else if (pair.A.HasRecognizerVersion) { pair.A.Recognizer.Pred = pair.A.Pred; } } Remove_any_in_Labels(); }