internal static CellTreeNode Flatten(CellTreeNode node)
            {
                // First do simple flattening and then associative op flattening
                CellTreeNode newNode = FlatteningVisitor.Flatten(node);
                AssociativeOpFlatteningVisitor visitor = new AssociativeOpFlatteningVisitor();

                return(newNode.Accept <bool, CellTreeNode>(visitor, true));
            }
            // effects: Flattens node and returns a new tree that is flattened
            internal static CellTreeNode Flatten(CellTreeNode node)
            {
                FlatteningVisitor visitor = new FlatteningVisitor();

                return(node.Accept <bool, CellTreeNode>(visitor, true));
            }
示例#3
0
 // effects: Given a cell tree node , removes unnecessary
 // "nesting" that occurs in the tree -- an unnecessary nesting
 // occurs when a node has exactly one child.
 internal CellTreeNode Flatten()
 {
     return(FlatteningVisitor.Flatten(this));
 }