// Set number of strokes using the LBT directly.
 public ParseState(List <LexerResult> symbolList, ParseTreeNode node, bool final)
 {
     candidateSymbols = symbolList;
     rootNode         = node;
     previous         = null;
     numberStrokes    = node.lbt.strokes.Count;          // Obtain from node itself.
     completesParse   = final;
 }
 // Note: this constructor is primarily for testing.
 public ParseState(List <LexerResult> symbolList, ParseTreeNode node, int strokes, bool final)
 {
     candidateSymbols = symbolList;
     rootNode         = node;
     previous         = null;
     numberStrokes    = strokes;
     completesParse   = final;             // BUG?
     //regionsOptional = true;
 }
        // **NOTE: we do not search for symbols at this point.
        public ParseState(ParseState parent, PreviousSymbol p)
        {
            candidateSymbols = null;
            previous         = p;

            completesParse = parent.completesParse;
            numberStrokes  = parent.numberStrokes - p.symbol.segment.strokes.Count;
            rootNode       = new SymbolTreeNode(p.symbol);
        }
        public ParseState(ParseState pstate, RelationTreeNode node)
        {
            candidateSymbols = pstate.candidateSymbols;
            numberStrokes    = pstate.numberStrokes;
            completesParse   = pstate.completesParse;
            previous         = pstate.previous;

            // Inherit all attributes, but modify the root node.
            rootNode = node;
        }
        public PreviousSymbol clone()
        {
            PreviousSymbol p = new PreviousSymbol();

            p.symbol             = symbol;
            p.parent             = parent.clone();
            p.regions            = regions;
            p.regionNonterminals = regionNonterminals;
            p.regionsOptional    = regionsOptional;

            return(p);
        }
        // Constructor for root node.
        public ParseState(ParseTreeNode inNode, LBT tree)
        {
            // Create root node for parser.
            rootNode = inNode;

            // Construct previous node.
            // **Note: currently a number of fields will be uninitialized.
            previous                 = new PreviousSymbol();
            previous.symbol          = new LexerResult();
            previous.symbol.lbt      = tree;
            previous.regionsOptional = true;

            // Remaining attribute definitions.
            candidateSymbols = null;            // no symbols considered.
            completesParse   = true;            // root node.
            numberStrokes    = tree.strokes.Count;
        }
        public void Update(ParseState childState)
        {
            candidateSymbols = childState.candidateSymbols;
            previous         = childState.previous;

            // Handle nested regions differently than other symbols.
            if (childState.rootNode is RelationTreeNode)
            {
                if (childState.numberStrokes == 0)
                {
                    // Reduce by number of strokes.
                    numberStrokes = numberStrokes - childState.rootNode.strokes.Count;
                }
            }
            else
            {
                numberStrokes = childState.numberStrokes;
            }

            // Original root node and "completes parse" attributes should be unchanged.
        }