/// <summary> /// Eliminate unit rules (e.g., <X> -> <Y>) /// </summary> /// <param name="productions"></param> private void StepUnit(ISet <Production> productions) { // TODO: maybe we shouldn't allow self loops? RemoveSelfLoops(productions); var toRemove = BaseGrammar.RemoveDuplicatesHelper(productions); foreach (var production in toRemove) { productions.Remove(production); } var finalProductions = RemoveUnits(productions); productions.Clear(); productions.UnionWith(finalProductions); }
protected void RemoveDuplicates() { var toRemove = BaseGrammar.RemoveDuplicatesHelper(this.Productions); this.RemoveProductionsWithoutSimplifying(toRemove); }