Lines Matching refs:ctns
43 static void addNavigationNode (pANTLR3_COMMON_TREE_NODE_STREAM ctns, ANTLR3_UINT32 ttype);
44 static ANTLR3_BOOLEAN hasUniqueNavigationNodes (pANTLR3_COMMON_TREE_NODE_STREAM ctns);
45 static pANTLR3_BASE_TREE newDownNode (pANTLR3_COMMON_TREE_NODE_STREAM ctns);
46 static pANTLR3_BASE_TREE newUpNode (pANTLR3_COMMON_TREE_NODE_STREAM ctns);
47 static void reset (pANTLR3_COMMON_TREE_NODE_STREAM ctns);
48 static void push (pANTLR3_COMMON_TREE_NODE_STREAM ctns, ANTLR3_INT32 index);
49 static ANTLR3_INT32 pop (pANTLR3_COMMON_TREE_NODE_STREAM ctns);
50 //static ANTLR3_INT32 index (pANTLR3_COMMON_TREE_NODE_STREAM ctns);
51 static ANTLR3_UINT32 getLookaheadSize (pANTLR3_COMMON_TREE_NODE_STREAM ctns);
79 static void fillBuffer (pANTLR3_COMMON_TREE_NODE_STREAM ctns, pANTLR3_BASE_TREE t);
80 static void fillBufferRoot (pANTLR3_COMMON_TREE_NODE_STREAM ctns);
85 static void antlr3CommonTreeNodeStreamFree (pANTLR3_COMMON_TREE_NODE_STREAM ctns);
223 stream->tnstream->ctns = stream;
365 stream->tnstream->ctns = stream;
420 static void antlr3CommonTreeNodeStreamFree (pANTLR3_COMMON_TREE_NODE_STREAM ctns)
427 if (ctns->isRewriter != ANTLR3_TRUE)
429 ctns->adaptor ->free (ctns->adaptor);
431 if (ctns->nodeStack != NULL)
433 ctns->nodeStack->free(ctns->nodeStack);
436 ANTLR3_FREE(ctns->INVALID_NODE.token);
437 ANTLR3_FREE(ctns->EOF_NODE.token);
438 ANTLR3_FREE(ctns->DOWN.token);
439 ANTLR3_FREE(ctns->UP.token);
442 if (ctns->nodes != NULL)
444 ctns->nodes ->free (ctns->nodes);
446 ctns->tnstream->istream ->free (ctns->tnstream->istream);
447 ctns->tnstream ->free (ctns->tnstream);
450 ANTLR3_FREE(ctns);
460 fillBufferRoot(pANTLR3_COMMON_TREE_NODE_STREAM ctns)
465 fillBuffer(ctns, ctns->root);
466 ctns->p = 0; // Indicate we are at buffer start
474 fillBuffer(pANTLR3_COMMON_TREE_NODE_STREAM ctns, pANTLR3_BASE_TREE t)
480 nilNode = ctns->adaptor->isNilNode(ctns->adaptor, t);
487 ctns->nodes->add(ctns->nodes, t, NULL);
497 ctns->addNavigationNode(ctns, ANTLR3_TOKEN_DOWN);
506 fillBuffer(ctns, ctns->adaptor->getChild(ctns->adaptor, t, c));
514 ctns->addNavigationNode(ctns, ANTLR3_TOKEN_UP);
526 ctns)
528 if (ctns->p != -1)
530 ctns->p = 0;
532 ctns->tnstream->istream->lastMarker = 0;
539 if (ctns->isRewriter != ANTLR3_TRUE)
541 if (ctns->nodeStack != NULL)
543 ctns->nodeStack->free(ctns->nodeStack);
544 ctns->nodeStack = antlr3StackNew(INITIAL_CALL_STACK_SIZE);
555 return &(tns->ctns->INVALID_NODE.baseTree);
558 if ( (tns->ctns->p - k) < 0)
560 return &(tns->ctns->INVALID_NODE.baseTree);
563 return tns->ctns->nodes->get(tns->ctns->nodes, tns->ctns->p - k);
579 if (tns->ctns->p == -1)
581 fillBufferRoot(tns->ctns);
590 return &(tns->ctns->INVALID_NODE.baseTree);
595 if (( tns->ctns->p + k - 1) >= (ANTLR3_INT32)(tns->ctns->nodes->count))
597 return &(tns->ctns->EOF_NODE.baseTree);
600 return tns->ctns->nodes->get(tns->ctns->nodes, tns->ctns->p + k - 1);
609 return tns->ctns->root;
618 pANTLR3_COMMON_TREE_NODE_STREAM ctns;
621 ctns = tns->ctns;
623 if (ctns->p == -1)
625 fillBufferRoot(ctns);
627 ctns->p++;
659 pANTLR3_COMMON_TREE_NODE_STREAM ctns;
662 ctns = tns->ctns;
664 if (tns->ctns->p == -1)
666 fillBufferRoot(tns->ctns);
671 ctns->tnstream->istream->lastMarker = ctns->tnstream->istream->index(ctns->tnstream->istream);
673 return ctns->tnstream->istream->lastMarker;
706 pANTLR3_COMMON_TREE_NODE_STREAM ctns;
709 ctns = tns->ctns;
711 ctns->p = ANTLR3_UINT32_CAST(index);
718 pANTLR3_COMMON_TREE_NODE_STREAM ctns;
721 ctns = tns->ctns;
723 return (ANTLR3_MARKER)(ctns->p);
734 pANTLR3_COMMON_TREE_NODE_STREAM ctns;
737 ctns = tns->ctns;
739 if (ctns->p == -1)
741 fillBufferRoot(ctns);
744 return ctns->nodes->size(ctns->nodes);
752 addNavigationNode (pANTLR3_COMMON_TREE_NODE_STREAM ctns, ANTLR3_UINT32 ttype)
760 if (ctns->hasUniqueNavigationNodes(ctns) == ANTLR3_TRUE)
762 node = ctns->newDownNode(ctns);
766 node = &(ctns->DOWN.baseTree);
771 if (ctns->hasUniqueNavigationNodes(ctns) == ANTLR3_TRUE)
773 node = ctns->newUpNode(ctns);
777 node = &(ctns->UP.baseTree);
783 ctns->nodes->add(ctns->nodes, node, NULL);
790 return tns->ctns->adaptor;
794 hasUniqueNavigationNodes (pANTLR3_COMMON_TREE_NODE_STREAM ctns)
796 return ctns->uniqueNavigationNodes;
802 tns->ctns->uniqueNavigationNodes = uniqueNavigationNodes;
814 return tns->toStringSS(tns, tns->ctns->root, NULL);
822 buf = tns->ctns->stringFactory->newRaw(tns->ctns->stringFactory);
844 text = tns->ctns->stringFactory->newRaw(tns->ctns->stringFactory);
882 getLookaheadSize (pANTLR3_COMMON_TREE_NODE_STREAM ctns)
884 return ctns->tail < ctns->head
885 ? (ctns->lookAheadLength - ctns->head + ctns->tail)
886 : (ctns->tail - ctns->head);
890 newDownNode (pANTLR3_COMMON_TREE_NODE_STREAM ctns)
904 newUpNode (pANTLR3_COMMON_TREE_NODE_STREAM ctns)
945 if (tns->ctns->p == -1)
947 fillBufferRoot(tns->ctns);
950 return tns->ctns->nodes->get(tns->ctns->nodes, k);
954 push (pANTLR3_COMMON_TREE_NODE_STREAM ctns, ANTLR3_INT32 index)
956 ctns->nodeStack->push(ctns->nodeStack, ANTLR3_FUNC_PTR(ctns->p), NULL); // Save current index
957 ctns->tnstream->istream->seek(ctns->tnstream->istream, index);
961 pop (pANTLR3_COMMON_TREE_NODE_STREAM ctns)
965 retVal = ANTLR3_UINT32_CAST(ctns->nodeStack->pop(ctns->nodeStack));
966 ctns->tnstream->istream->seek(ctns->tnstream->istream, retVal);