public bool IsMatchingPointType(ISymbolicExpressionTreeNode newChild) { var parent = this.Parent; if (newChild == null) { // make sure that one subtree can be removed and that only the last subtree is removed return(grammar.GetMinimumSubtreeCount(parent.Symbol) < parent.SubtreeCount && this.ChildIndex == parent.SubtreeCount - 1); } else { // check syntax constraints of direct parent - child relation if (!grammar.ContainsSymbol(newChild.Symbol) || !grammar.IsAllowedChildSymbol(parent.Symbol, newChild.Symbol, this.ChildIndex)) { return(false); } bool result = true; // check point type for the whole branch newChild.ForEachNodePostfix((n) => { result = result && grammar.ContainsSymbol(n.Symbol) && n.SubtreeCount >= grammar.GetMinimumSubtreeCount(n.Symbol) && n.SubtreeCount <= grammar.GetMaximumSubtreeCount(n.Symbol); }); return(result); } }
public bool IsMatchingPointType(ISymbolicExpressionTreeNode newChild) { var parent = this.Parent; if (newChild == null) { // make sure that one subtree can be removed and that only the last subtree is removed return grammar.GetMinimumSubtreeCount(parent.Symbol) < parent.SubtreeCount && this.ChildIndex == parent.SubtreeCount - 1; } else { // check syntax constraints of direct parent - child relation if (!grammar.ContainsSymbol(newChild.Symbol) || !grammar.IsAllowedChildSymbol(parent.Symbol, newChild.Symbol, this.ChildIndex)) return false; bool result = true; // check point type for the whole branch newChild.ForEachNodePostfix((n) => { result = result && grammar.ContainsSymbol(n.Symbol) && n.SubtreeCount >= grammar.GetMinimumSubtreeCount(n.Symbol) && n.SubtreeCount <= grammar.GetMaximumSubtreeCount(n.Symbol); }); return result; } }