public Sequitur() { Rules = new HashSet<Rule>(); _Data = new DigramContainer(); _StartRule = new Rule("startrule", this); //Rules.Add(_StartRule); _StartRule.reuse(); }
public void swapRule(Rule newRule) { Debug.Assert(IsRule); RuleInstance old = StartPoint.Value as RuleInstance; StartPoint.Value = new RuleInstance(newRule); old.Content.deuse(); Debug.Print("swapped " + old.ToString() + " to " + newRule.ToString()); }
internal RecursionPoint replace(LinkedListNode<Symbol> linkedListNode) { var rule = Data.getRule(linkedListNode); RecursionPoint todo = new RecursionPoint(); var pointsToCheck = new HashSet<LinkedListNode<Symbol>>(); if (rule == null) { rule = new Rule(Data.NextId, this); #if DEBUG Rules.Add(rule); #endif Debug.Print("New rule created:" + rule.ID); todo.UnionWith(Data.newRule(linkedListNode, rule)); } else { Debug.Print("using old rule:" + rule.ID ); } todo.UnionWith(Data.setRule(linkedListNode, rule)); Data.removeDigrams(todo.RemovedDigrams); todo.RemovedDigrams.Clear(); return todo; }