private void Closure(InteriorNode node) {
if (stack.Count > 0) {
SyntaxTreeNode topNode = (SyntaxTreeNode)stack.Pop();
InteriorNode inNode = topNode as InteriorNode;
if (isPartial && inNode != null) {
// need to reach in and wrap right hand side of element.
// and n remains the same.
node.LeftChild = inNode.RightChild;
inNode.RightChild = node;
}
else {
// wrap terminal or any node
node.LeftChild = topNode;
topNode = node;
}
stack.Push(topNode);
}
else if (contentNode != null) { //If there is content to wrap
// wrap whole content
node.LeftChild = contentNode;
contentNode = node;
}
}