• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/iserver/libantlr3c-3.2/src/

Lines Matching refs:tree

4 // starting point for your own tree. Though it is often easier just to tag things on
5 // to the user pointer in the tree unless you are building a different type
41 static pANTLR3_COMMON_TOKEN getToken (pANTLR3_BASE_TREE tree);
42 static pANTLR3_BASE_TREE dupNode (pANTLR3_BASE_TREE tree);
43 static ANTLR3_BOOLEAN isNilNode (pANTLR3_BASE_TREE tree);
44 static ANTLR3_UINT32 getType (pANTLR3_BASE_TREE tree);
45 static pANTLR3_STRING getText (pANTLR3_BASE_TREE tree);
46 static ANTLR3_UINT32 getLine (pANTLR3_BASE_TREE tree);
47 static ANTLR3_UINT32 getCharPositionInLine (pANTLR3_BASE_TREE tree);
48 static pANTLR3_STRING toString (pANTLR3_BASE_TREE tree);
49 static pANTLR3_BASE_TREE getParent (pANTLR3_BASE_TREE tree);
50 static void setParent (pANTLR3_BASE_TREE tree, pANTLR3_BASE_TREE parent);
51 static void setChildIndex (pANTLR3_BASE_TREE tree, ANTLR3_INT32 i);
52 static ANTLR3_INT32 getChildIndex (pANTLR3_BASE_TREE tree);
53 static void createChildrenList (pANTLR3_BASE_TREE tree);
54 static void reuse (pANTLR3_BASE_TREE tree);
60 static pANTLR3_BASE_TREE newFromTree (pANTLR3_ARBORETUM factory, pANTLR3_COMMON_TREE tree);
156 pANTLR3_COMMON_TREE tree;
160 tree = factory->nilStack->peek(factory->nilStack);
162 if (tree != NULL)
170 return (pANTLR3_BASE_TREE)tree;
173 // See if we need a new tree pool before allocating a new tree
185 tree = factory->pools[factory->thisPool] + factory->nextTree;
190 antlr3SetCTAPI(tree);
195 tree->factory = factory;
196 tree->baseTree.strFactory = factory->unTruc.baseTree.strFactory;
198 // The super points to the common tree so we must override the one used by
199 // by the pre-built tree as otherwise we will always poitn to the same initial
200 // common tree and we might spend 3 hours trying to debug why - this would never
203 tree->baseTree.super = tree;
207 return &(tree->baseTree);
212 newFromTree(pANTLR3_ARBORETUM factory, pANTLR3_COMMON_TREE tree)
223 // Pick up the payload we had in the supplied tree
225 ((pANTLR3_COMMON_TREE)(newTree->super))->token = tree->token;
226 newTree->u = tree->baseTree.u; // Copy any user pointer
243 // Pick up the payload we had in the supplied tree
265 // We now JUST free the pools because the C runtime CommonToken based tree
288 antlr3SetCTAPI(pANTLR3_COMMON_TREE tree)
290 // Init base tree
292 antlr3BaseTreeNew(&(tree->baseTree));
298 tree->baseTree.super = tree;
300 // Common tree overrides
302 tree->baseTree.isNilNode = isNilNode;
303 tree->baseTree.toString = toString;
304 tree->baseTree.dupNode = (void *(*)(pANTLR3_BASE_TREE))(dupNode);
305 tree->baseTree.getLine = getLine;
306 tree->baseTree.getCharPositionInLine = getCharPositionInLine;
307 tree->baseTree.toString = toString;
308 tree->baseTree.getType = getType;
309 tree->baseTree.getText = getText;
310 tree->baseTree.getToken = getToken;
311 tree->baseTree.getParent = getParent;
312 tree->baseTree.setParent = setParent;
313 tree->baseTree.setChildIndex = setChildIndex;
314 tree->baseTree.getChildIndex = getChildIndex;
315 tree->baseTree.createChildrenList = createChildrenList;
316 tree->baseTree.reuse = reuse;
317 tree->baseTree.free = NULL; // Factory trees have no free function
319 tree->baseTree.children = NULL;
321 tree->token = NULL; // No token as yet
322 tree->startIndex = 0;
323 tree->stopIndex = 0;
324 tree->parent = NULL; // No parent yet
325 tree->childIndex = -1;
337 pANTLR3_COMMON_TREE tree;
338 tree = ANTLR3_MALLOC(sizeof(ANTLR3_COMMON_TREE));
340 if (tree == NULL)
345 antlr3SetCTAPI(tree);
347 return tree;
362 //Pick up the payload we had in the supplied tree
372 createChildrenList (pANTLR3_BASE_TREE tree)
374 tree->children = ((pANTLR3_COMMON_TREE)(tree->super))->factory->vFactory->newVector(((pANTLR3_COMMON_TREE)(tree->super))->factory->vFactory);
379 getToken (pANTLR3_BASE_TREE tree)
381 // The token is the payload of the common tree or other implementor
387 return ((pANTLR3_COMMON_TREE)(tree->super))->token;
391 dupNode (pANTLR3_BASE_TREE tree)
393 // The node we are duplicating is in fact the common tree (that's why we are here)
398 theOld = (pANTLR3_COMMON_TREE)(tree->super);
406 isNilNode (pANTLR3_BASE_TREE tree)
408 // This is a Nil tree if it has no payload (Token in our case)
410 if (((pANTLR3_COMMON_TREE)(tree->super))->token == NULL)
421 getType (pANTLR3_BASE_TREE tree)
425 theTree = (pANTLR3_COMMON_TREE)(tree->super);
438 getText (pANTLR3_BASE_TREE tree)
440 return tree->toString(tree);
443 static ANTLR3_UINT32 getLine (pANTLR3_BASE_TREE tree)
448 cTree = (pANTLR3_COMMON_TREE)(tree->super);
454 if (tree->getChildCount(tree) > 0)
458 child = (pANTLR3_BASE_TREE)tree->getChild(tree, 0);
466 static ANTLR3_UINT32 getCharPositionInLine (pANTLR3_BASE_TREE tree)
470 token = ((pANTLR3_COMMON_TREE)(tree->super))->token;
474 if (tree->getChildCount(tree) > 0)
478 child = (pANTLR3_BASE_TREE)tree->getChild(tree, 0);
487 static pANTLR3_STRING toString (pANTLR3_BASE_TREE tree)
489 if (tree->isNilNode(tree) == ANTLR3_TRUE)
493 nilNode = tree->strFactory->newPtr(tree->strFactory, (pANTLR3_UINT8)"nil", 3);
498 return ((pANTLR3_COMMON_TREE)(tree->super))->token->getText(((pANTLR3_COMMON_TREE)(tree->super))->token);
502 getParent (pANTLR3_BASE_TREE tree)
504 return & (((pANTLR3_COMMON_TREE)(tree->super))->parent->baseTree);
508 setParent (pANTLR3_BASE_TREE tree, pANTLR3_BASE_TREE parent)
510 ((pANTLR3_COMMON_TREE)(tree->super))->parent = parent == NULL ? NULL : ((pANTLR3_COMMON_TREE)(parent->super))->parent;
514 setChildIndex (pANTLR3_BASE_TREE tree, ANTLR3_INT32 i)
516 ((pANTLR3_COMMON_TREE)(tree->super))->childIndex = i;
519 getChildIndex (pANTLR3_BASE_TREE tree )
521 return ((pANTLR3_COMMON_TREE)(tree->super))->childIndex;
524 /** Clean up any child vector that the tree might have, so it can be reused,
528 reuse (pANTLR3_BASE_TREE tree)
532 cTree = (pANTLR3_COMMON_TREE)(tree->super);
542 cTree->factory->nilStack->push(cTree->factory->nilStack, tree, NULL);