public PreviousSymbol(LexerResult s, ParseTreeNode p, List <string> r, List <string> n,
                              bool optional)
        {
            symbol = (LexerResult)s.Clone(); // (lex results never mutated)
            parent = p;                      // .clone(); // Capture state of subtree on construction.

            if (s.BLEFT != null)
            {
                parent.children.Add(s.BLEFT);
            }
            if (s.TLEFT != null)
            {
                parent.children.Add(s.TLEFT);
            }

            // Avoid crashing on null values.
            if (r == null)
            {
                regions            = new List <string>();
                regionNonterminals = new List <string>();
            }
            else
            {
                regions            = r;
                regionNonterminals = n;
            }

            regionsOptional = optional;
        }
        public override ParseTreeNode clone()
        {
            // Node labels and stoke data will be fixed for a given node (ref. only), but children will
            // differ for different parse trees (new copy).
            LexerResult    resultCopy = (LexerResult)symbolData.Clone();
            SymbolTreeNode nodeCopy   = new SymbolTreeNode(resultCopy);

            nodeCopy.strokes = strokes;
            nodeCopy.lbt     = null;
            if (lbt != null)
            {
                nodeCopy.lbt = new LBT(lbt);           // copy lbt
            }
            if (children != null)
            {
                foreach (ParseTreeNode child in children)
                {
                    nodeCopy.children.Add(child.clone());
                }
            }
            nodeCopy.symbolData = symbolData;
            return(nodeCopy);
        }