diff options
author | antonovvk <antonovvk@yandex-team.ru> | 2022-02-10 16:47:52 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:52 +0300 |
commit | 37de222addabbef336dcaaea5f7c7645a629fc6d (patch) | |
tree | c0748b5dcbade83af788c0abfa89c0383d6b779c /contrib/libs/antlr3_cpp_runtime/include/antlr3commontreeadaptor.inl | |
parent | 37a63debdc21e372d99e1808cdd31aecf75018c3 (diff) | |
download | ydb-37de222addabbef336dcaaea5f7c7645a629fc6d.tar.gz |
Restoring authorship annotation for <antonovvk@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/antlr3_cpp_runtime/include/antlr3commontreeadaptor.inl')
-rw-r--r-- | contrib/libs/antlr3_cpp_runtime/include/antlr3commontreeadaptor.inl | 676 |
1 files changed, 338 insertions, 338 deletions
diff --git a/contrib/libs/antlr3_cpp_runtime/include/antlr3commontreeadaptor.inl b/contrib/libs/antlr3_cpp_runtime/include/antlr3commontreeadaptor.inl index c897dfd19e..6e191b2a15 100644 --- a/contrib/libs/antlr3_cpp_runtime/include/antlr3commontreeadaptor.inl +++ b/contrib/libs/antlr3_cpp_runtime/include/antlr3commontreeadaptor.inl @@ -1,5 +1,5 @@ namespace antlr3 { - + template <typename ImplTraits> CommonResourcePoolManager<ImplTraits>::CommonResourcePoolManager(CommonTreeStore<ImplTraits> * pool) : m_pool(pool) @@ -73,56 +73,56 @@ CommonTreeStore<ImplTraits>::reuse(TreeType* releasedResource) m_recycleBin.push_back(releasedResource); } -template<class ImplTraits> +template<class ImplTraits> CommonTreeAdaptor<ImplTraits>::CommonTreeAdaptor(DebuggerType*) {} template<class ImplTraits> typename CommonTreeAdaptor<ImplTraits>::TreeTypePtr CommonTreeAdaptor<ImplTraits>::nilNode() -{ +{ return this->create(NULL); -} - -template<class ImplTraits> +} + +template<class ImplTraits> typename CommonTreeAdaptor<ImplTraits>::TreeTypePtr CommonTreeAdaptor<ImplTraits>::dupTree( const TreeType* tree) -{ +{ if (tree == NULL) return NULL; return std::move(this->dupTreeImpl(tree, NULL)); -} - -template<class ImplTraits> +} + +template<class ImplTraits> typename CommonTreeAdaptor<ImplTraits>::TreeTypePtr CommonTreeAdaptor<ImplTraits>::dupTree( const TreeTypePtr& tree) -{ +{ if (tree == NULL) return NULL; return std::move(dupTreeImpl(tree.get(), NULL)); -} - -template<class ImplTraits> +} + +template<class ImplTraits> typename CommonTreeAdaptor<ImplTraits>::TreeTypePtr CommonTreeAdaptor<ImplTraits>::dupTreeImpl( const TreeType *root, TreeType* parent) -{ +{ TreeTypePtr newTree(dupNode(root)); - + // Ensure new subtree root has parent/child index set // this->setChildIndex( newTree, root->get_childIndex() ); this->setParent(newTree, parent); - + ChildrenType const& r_children = root->get_children(); for (auto i = r_children.begin(); i != r_children.end(); ++i) { // add child's clone this->addChild(newTree, dupTreeImpl(i->get(), newTree.get())); } - + return newTree; } - + template<class ImplTraits> void CommonTreeAdaptor<ImplTraits>::addChild( TreeTypePtr& t, TreeTypePtr& child) { @@ -130,66 +130,66 @@ void CommonTreeAdaptor<ImplTraits>::addChild( TreeTypePtr& t, TreeTypePtr& child { t->addChild(child); } -} - -template<class ImplTraits> +} + +template<class ImplTraits> void CommonTreeAdaptor<ImplTraits>::addChild( TreeTypePtr& t, TreeTypePtr&& child) -{ +{ if (t != NULL && child != NULL) { t->addChild(child); } -} - -template<class ImplTraits> +} + +template<class ImplTraits> void CommonTreeAdaptor<ImplTraits>::addChildToken( TreeTypePtr& t, CommonTokenType* child) -{ +{ if (t != NULL && child != NULL) { this->addChild(t, this->create(child)); } -} - -template<class ImplTraits> +} + +template<class ImplTraits> void CommonTreeAdaptor<ImplTraits>::setParent( TreeTypePtr& child, TreeType* parent) -{ +{ child->set_parent(parent); -} - -template<class ImplTraits> +} + +template<class ImplTraits> typename CommonTreeAdaptor<ImplTraits>::TreeType* CommonTreeAdaptor<ImplTraits>::getParent( TreeTypePtr& child) -{ +{ if ( child==NULL ) return NULL; return child->getParent(); -} - -template<class ImplTraits> +} + +template<class ImplTraits> typename CommonTreeAdaptor<ImplTraits>::TreeTypePtr CommonTreeAdaptor<ImplTraits>::errorNode( CommonTokenType*, const CommonTokenType*, const CommonTokenType*) -{ +{ // Use the supplied common tree node stream to get another tree from the factory // TODO: Look at creating the erronode as in Java, but this is complicated by the // need to track and free the memory allocated to it, so for now, we just // want something in the tree that isn't a NULL pointer. // return this->create( CommonTokenType::TOKEN_INVALID, "Tree Error Node"); - -} - -template<class ImplTraits> + +} + +template<class ImplTraits> bool CommonTreeAdaptor<ImplTraits>::isNilNode( TreeTypePtr& t) -{ +{ return t->isNilNode(); -} - -template<class ImplTraits> +} + +template<class ImplTraits> typename CommonTreeAdaptor<ImplTraits>::TreeTypePtr CommonTreeAdaptor<ImplTraits>::becomeRoot( TreeTypePtr& newRootTree, TreeTypePtr& oldRootTree) -{ +{ /* Protect against tree rewrites if we are in some sort of error * state, but have tried to recover. In C we can end up with a null pointer * for a tree that was not produced. @@ -198,7 +198,7 @@ CommonTreeAdaptor<ImplTraits>::becomeRoot( TreeTypePtr& newRootTree, TreeTypePtr { return std::move(oldRootTree); } - + /* root is just the new tree as is if there is no * current root tree. */ @@ -206,7 +206,7 @@ CommonTreeAdaptor<ImplTraits>::becomeRoot( TreeTypePtr& newRootTree, TreeTypePtr { return std::move(newRootTree); } - + /* Produce ^(nil real-node) */ if (newRootTree->isNilNode()) @@ -218,27 +218,27 @@ CommonTreeAdaptor<ImplTraits>::becomeRoot( TreeTypePtr& newRootTree, TreeTypePtr fprintf(stderr, "More than one node as root! TODO: Create tree exception handling\n"); return std::move(newRootTree); } - + /* The new root is the first child, keep track of the original newRoot * because if it was a Nil Node, then we can reuse it now. */ TreeTypePtr saveRoot = std::move(newRootTree); newRootTree = std::move(saveRoot->getChild(0)); - + // Will Reclaim the old nilNode() saveRoot here } - + /* Add old root into new root. addChild takes care of the case where oldRoot * is a flat list (nill rooted tree). All children of oldroot are added to * new root. */ newRootTree->addChild(oldRootTree); - + /* Always returns new root structure */ return std::move(newRootTree); } - + template<class ImplTraits> typename CommonTreeAdaptor<ImplTraits>::TreeTypePtr CommonTreeAdaptor<ImplTraits>::becomeRoot( TreeTypePtr&& newRootTree, TreeTypePtr& oldRootTree) @@ -290,28 +290,28 @@ CommonTreeAdaptor<ImplTraits>::becomeRoot( TreeTypePtr&& newRootTree, TreeTypePt /* Always returns new root structure */ return std::move(newRootTree); -} - -template<class ImplTraits> +} + +template<class ImplTraits> typename CommonTreeAdaptor<ImplTraits>::TreeTypePtr CommonTreeAdaptor<ImplTraits>::becomeRootToken( CommonTokenType* newRoot, TreeTypePtr& oldRoot) -{ +{ return this->becomeRoot(this->create(newRoot), oldRoot); -} - -template<class ImplTraits> +} + +template<class ImplTraits> typename CommonTreeAdaptor<ImplTraits>::TreeTypePtr CommonTreeAdaptor<ImplTraits>::create( CommonTokenType const* payload) -{ +{ TreeTypePtr retval = TreeStoreType::create(); retval->set_token(payload); return retval; -} - -template<class ImplTraits> +} + +template<class ImplTraits> typename CommonTreeAdaptor<ImplTraits>::TreeTypePtr CommonTreeAdaptor<ImplTraits>::create( ANTLR_UINT32 tokenType, const CommonTokenType* fromToken) -{ +{ /* Create the new token */ auto newToken = this->createToken(fromToken); /* Set the type of the new token to that supplied */ @@ -319,7 +319,7 @@ CommonTreeAdaptor<ImplTraits>::create( ANTLR_UINT32 tokenType, const CommonToken /* Return a new node based upon this token */ return this->create(newToken); } - + template<class ImplTraits> typename CommonTreeAdaptor<ImplTraits>::TreeTypePtr CommonTreeAdaptor<ImplTraits>::create( ANTLR_UINT32 tokenType, const CommonTokenType* fromToken, const char* text) @@ -335,7 +335,7 @@ CommonTreeAdaptor<ImplTraits>::create( ANTLR_UINT32 tokenType, const CommonToken /* Return a new node based upon this token */ return this->create(newToken); } - + template<class ImplTraits> typename CommonTreeAdaptor<ImplTraits>::TreeTypePtr CommonTreeAdaptor<ImplTraits>::create( ANTLR_UINT32 tokenType, const CommonTokenType* fromToken, typename CommonTreeAdaptor<ImplTraits>::StringType const& text) @@ -351,181 +351,181 @@ CommonTreeAdaptor<ImplTraits>::create( ANTLR_UINT32 tokenType, const CommonToken /* Return a new node based upon this token */ return this->create(newToken); } - + template<class ImplTraits> typename CommonTreeAdaptor<ImplTraits>::TreeTypePtr CommonTreeAdaptor<ImplTraits>::create( ANTLR_UINT32 tokenType, const char* text) { auto fromToken = this->createToken(tokenType, text); return this->create(fromToken); -} - -template<class ImplTraits> +} + +template<class ImplTraits> typename CommonTreeAdaptor<ImplTraits>::TreeTypePtr CommonTreeAdaptor<ImplTraits>::create( ANTLR_UINT32 tokenType, typename CommonTreeAdaptor<ImplTraits>::StringType const& text) -{ +{ auto fromToken = this->createToken(tokenType, text); return this->create(fromToken); -} - -template<class ImplTraits> +} + +template<class ImplTraits> typename CommonTreeAdaptor<ImplTraits>::TreeTypePtr CommonTreeAdaptor<ImplTraits>::dupNode(const TreeType* treeNode) -{ +{ if (treeNode == NULL) return TreeStoreType::null(); TreeTypePtr retval(TreeStoreType::create()); treeNode->dupNode(retval.get()); return retval; -} - -template<class ImplTraits> +} + +template<class ImplTraits> typename CommonTreeAdaptor<ImplTraits>::TreeTypePtr CommonTreeAdaptor<ImplTraits>::dupNode(const TreeTypePtr& treeNode) -{ +{ if (treeNode == NULL) return TreeStoreType::null(); TreeTypePtr retval(TreeStoreType::create()); treeNode->dupNode(retval.get()); return retval; -} - -template<class ImplTraits> +} + +template<class ImplTraits> ANTLR_UINT32 CommonTreeAdaptor<ImplTraits>::getType( TreeTypePtr& t) -{ +{ if ( t==NULL) return CommonTokenType::TOKEN_INVALID; return t->getType(); -} - -template<class ImplTraits> +} + +template<class ImplTraits> typename CommonTreeAdaptor<ImplTraits>::StringType CommonTreeAdaptor<ImplTraits>::getText( TreeTypePtr& t) -{ +{ return t->getText(); -} - -template<class ImplTraits> +} + +template<class ImplTraits> typename CommonTreeAdaptor<ImplTraits>::TreeTypePtr& CommonTreeAdaptor<ImplTraits>::getChild( TreeTypePtr& t, ANTLR_UINT32 i) -{ +{ if ( t==NULL ) return NULL; return t->getChild(i); -} - -template<class ImplTraits> +} + +template<class ImplTraits> void CommonTreeAdaptor<ImplTraits>::setChild( TreeTypePtr& t, ANTLR_UINT32 i, TreeTypePtr& child) -{ +{ t->setChild(i, child); -} - -template<class ImplTraits> +} + +template<class ImplTraits> void CommonTreeAdaptor<ImplTraits>::deleteChild( TreeTypePtr& t, ANTLR_UINT32 i) -{ +{ t->deleteChild(i); -} - -template<class ImplTraits> +} + +template<class ImplTraits> void CommonTreeAdaptor<ImplTraits>::setChildIndex( TreeTypePtr& t, ANTLR_INT32 i) -{ +{ if( t!= NULL) t->set_childIndex(i); -} - -template<class ImplTraits> +} + +template<class ImplTraits> ANTLR_INT32 CommonTreeAdaptor<ImplTraits>::getChildIndex( TreeTypePtr& t) -{ +{ if ( t==NULL ) return 0; return t->getChildIndex(); -} - -template<class ImplTraits> +} + +template<class ImplTraits> ANTLR_UINT32 CommonTreeAdaptor<ImplTraits>::getChildCount( TreeTypePtr& t) -{ +{ if ( t==NULL ) return 0; return t->getChildCount(); -} - -template<class ImplTraits> +} + +template<class ImplTraits> ANTLR_UINT64 CommonTreeAdaptor<ImplTraits>::getUniqueID( TreeTypePtr& node ) -{ +{ return reinterpret_cast<ANTLR_UINT64>(node); -} - -template<class ImplTraits> -typename CommonTreeAdaptor<ImplTraits>::CommonTokenType* +} + +template<class ImplTraits> +typename CommonTreeAdaptor<ImplTraits>::CommonTokenType* CommonTreeAdaptor<ImplTraits>::createToken( ANTLR_UINT32 tokenType, const char* text) -{ +{ CommonTokenType* newToken = TreeStoreType::createToken(); newToken->set_tokText( text ); newToken->set_type(tokenType); return newToken; -} - -template<class ImplTraits> -typename CommonTreeAdaptor<ImplTraits>::CommonTokenType* +} + +template<class ImplTraits> +typename CommonTreeAdaptor<ImplTraits>::CommonTokenType* CommonTreeAdaptor<ImplTraits>::createToken( ANTLR_UINT32 tokenType, typename CommonTreeAdaptor<ImplTraits>::StringType const& text) -{ +{ CommonTokenType* newToken = TreeStoreType::createToken(); newToken->set_tokText( text ); newToken->set_type(tokenType); return newToken; -} - -template<class ImplTraits> -typename CommonTreeAdaptor<ImplTraits>::CommonTokenType* +} + +template<class ImplTraits> +typename CommonTreeAdaptor<ImplTraits>::CommonTokenType* CommonTreeAdaptor<ImplTraits>::createToken( const CommonTokenType* fromToken) -{ +{ CommonTokenType* newToken = TreeStoreType::createToken(fromToken); return newToken; -} - -template<class ImplTraits> +} + +template<class ImplTraits> typename CommonTreeAdaptor<ImplTraits>::CommonTokenType* CommonTreeAdaptor<ImplTraits>::getToken( TreeTypePtr& t) -{ +{ return t->getToken(); } - + template<class ImplTraits> void CommonTreeAdaptor<ImplTraits>::setTokenBoundaries( TreeTypePtr& t, const CommonTokenType* startToken, const CommonTokenType* stopToken) { ANTLR_MARKER start = 0; ANTLR_MARKER stop = 0; - + if (t == NULL) return; - + if ( startToken != NULL) start = startToken->get_tokenIndex(); - + if ( stopToken != NULL) stop = stopToken->get_tokenIndex(); - + t->set_startIndex(start); t->set_stopIndex(stop); -} - -template<class ImplTraits> +} + +template<class ImplTraits> ANTLR_MARKER CommonTreeAdaptor<ImplTraits>::getTokenStartIndex( TreeTypePtr& t) -{ +{ if ( t==NULL ) return -1; return t->get_tokenStartIndex(); -} - -template<class ImplTraits> +} + +template<class ImplTraits> ANTLR_MARKER CommonTreeAdaptor<ImplTraits>::getTokenStopIndex( TreeTypePtr& t) -{ +{ if ( t==NULL ) return -1; return t->get_tokenStopIndex(); -} - -template<class ImplTraits> +} + +template<class ImplTraits> typename CommonTreeAdaptor<ImplTraits>::StringType CommonTreeAdaptor<ImplTraits>::makeDot( TreeTypePtr& theTree) -{ +{ // The string we are building up // StringType dotSpec; @@ -538,7 +538,7 @@ typename CommonTreeAdaptor<ImplTraits>::StringType CommonTreeAdaptor<ImplTraits "\tbgcolor=\"lightgrey\"; node [shape=box, fixedsize=false, fontsize=12, fontname=\"Helvetica-bold\", fontcolor=\"blue\"\n" "\twidth=.25, height=.25, color=\"black\", fillcolor=\"white\", style=\"filled, solid, bold\"];\n\n" "\tedge [arrowsize=.5, color=\"black\", style=\"bold\"]\n\n"; - + if (theTree == NULL) { // No tree, so create a blank spec @@ -546,33 +546,33 @@ typename CommonTreeAdaptor<ImplTraits>::StringType CommonTreeAdaptor<ImplTraits dotSpec->append("n0[label=\"EMPTY TREE\"]\n"); return dotSpec; } - - sprintf(buff, "\tn%p[label=\"", theTree); + + sprintf(buff, "\tn%p[label=\"", theTree); dotSpec.append(buff); - text = this->getText(theTree); - for (std::size_t j = 0; j < text.size(); j++) - { - switch(text[j]) - { - case '"': - dotSpec.append("\\\""); - break; - - case '\n': - dotSpec.append("\\n"); - break; - - case '\r': - dotSpec.append("\\r"); - break; - - default: - dotSpec += text[j]; - break; - } - } + text = this->getText(theTree); + for (std::size_t j = 0; j < text.size(); j++) + { + switch(text[j]) + { + case '"': + dotSpec.append("\\\""); + break; + + case '\n': + dotSpec.append("\\n"); + break; + + case '\r': + dotSpec.append("\\r"); + break; + + default: + dotSpec += text[j]; + break; + } + } dotSpec->append("\"]\n"); - + // First produce the node defintions // this->defineDotNodes(theTree, dotSpec); @@ -582,22 +582,22 @@ typename CommonTreeAdaptor<ImplTraits>::StringType CommonTreeAdaptor<ImplTraits // Terminate the spec // dotSpec.append("\n}"); - + // Result // return dotSpec; -} - -template<class ImplTraits> +} + +template<class ImplTraits> void CommonTreeAdaptor<ImplTraits>::replaceChildren( TreeTypePtr parent, ANTLR_INT32 startChildIndex, ANTLR_INT32 stopChildIndex, TreeTypePtr t) -{ +{ if (parent != NULL) parent->replaceChildren(startChildIndex, stopChildIndex, t); -} - -template<class ImplTraits> -CommonTreeAdaptor<ImplTraits>::~CommonTreeAdaptor() -{ +} + +template<class ImplTraits> +CommonTreeAdaptor<ImplTraits>::~CommonTreeAdaptor() +{ #ifdef ANTLR3_DEBUG std::cout << "SZ" << TreeStoreType::size() << std::endl; std::cout << "RZ" << TreeStoreType::m_recycleBin.size() << std::endl; @@ -620,11 +620,11 @@ CommonTreeAdaptor<ImplTraits>::~CommonTreeAdaptor() << std::endl; } #endif -} - -template<class ImplTraits> +} + +template<class ImplTraits> void CommonTreeAdaptor<ImplTraits>::defineDotNodes(TreeTypePtr t, const StringType& dotSpec) -{ +{ // How many nodes are we talking about? // int nCount; @@ -633,11 +633,11 @@ void CommonTreeAdaptor<ImplTraits>::defineDotNodes(TreeTypePtr t, const StringTy char buff[64]; StringType text; int j; - + // Count the nodes // nCount = this->getChildCount(t); - + if (nCount == 0) { // This will already have been included as a child of another node @@ -645,17 +645,17 @@ void CommonTreeAdaptor<ImplTraits>::defineDotNodes(TreeTypePtr t, const StringTy // return; } - + // For each child of the current tree, define a node using the // memory address of the node to name it // for (i = 0; i<nCount; i++) { - + // Pick up a pointer for the child // child = this->getChild(t, i); - + // Name the node // sprintf(buff, "\tn%p[label=\"", child); @@ -663,27 +663,27 @@ void CommonTreeAdaptor<ImplTraits>::defineDotNodes(TreeTypePtr t, const StringTy text = this->getText(child); for (j = 0; j < text.size(); j++) { - switch(text[j]) - { - case '"': - dotSpec.append("\\\""); - break; - - case '\n': - dotSpec.append("\\n"); - break; - - case '\r': - dotSpec.append("\\r"); - break; - - default: - dotSpec += text[j]; - break; - } + switch(text[j]) + { + case '"': + dotSpec.append("\\\""); + break; + + case '\n': + dotSpec.append("\\n"); + break; + + case '\r': + dotSpec.append("\\r"); + break; + + default: + dotSpec += text[j]; + break; + } } dotSpec.append("\"]\n"); - + // And now define the children of this child (if any) // this->defineDotNodes(child, dotSpec); @@ -692,11 +692,11 @@ void CommonTreeAdaptor<ImplTraits>::defineDotNodes(TreeTypePtr t, const StringTy // Done // return; -} - -template<class ImplTraits> +} + +template<class ImplTraits> void CommonTreeAdaptor<ImplTraits>::defineDotEdges(TreeTypePtr t, const StringType& dotSpec) -{ +{ // How many nodes are we talking about? // int nCount; @@ -706,11 +706,11 @@ void CommonTreeAdaptor<ImplTraits>::defineDotEdges(TreeTypePtr t, const StringTy // return; } - + // Count the nodes // nCount = this->getChildCount(t); - + if (nCount == 0) { // This will already have been included as a child of another node @@ -718,7 +718,7 @@ void CommonTreeAdaptor<ImplTraits>::defineDotEdges(TreeTypePtr t, const StringTy // return; } - + // For each child, define an edge from this parent, then process // and children of this child in the same way // @@ -726,84 +726,84 @@ void CommonTreeAdaptor<ImplTraits>::defineDotEdges(TreeTypePtr t, const StringTy { TreeTypePtr child; char buff[128]; - StringType text; - + StringType text; + // Next child // child = this->getChild(t, i); - + // Create the edge relation // sprintf(buff, "\t\tn%p -> n%p\t\t// ", t, child); dotSpec.append(buff); - + // Document the relationship // - text = this->getText(t); + text = this->getText(t); for (std::size_t j = 0; j < text.size(); j++) - { - switch(text[j]) - { - case '"': - dotSpec.append("\\\""); - break; - - case '\n': - dotSpec.append("\\n"); - break; - - case '\r': - dotSpec.append("\\r"); - break; - - default: - dotSpec += text[j]; - break; - } - } - - dotSpec.append(" -> "); - - text = this->getText(child); - for (std::size_t j = 0; j < text.size(); j++) - { - switch(text[j]) - { - case '"': - dotSpec.append("\\\""); - break; - - case '\n': - dotSpec.append("\\n"); - break; - - case '\r': - dotSpec.append("\\r"); - break; - - default: - dotSpec += text[j]; - break; - } - } + { + switch(text[j]) + { + case '"': + dotSpec.append("\\\""); + break; + + case '\n': + dotSpec.append("\\n"); + break; + + case '\r': + dotSpec.append("\\r"); + break; + + default: + dotSpec += text[j]; + break; + } + } + + dotSpec.append(" -> "); + + text = this->getText(child); + for (std::size_t j = 0; j < text.size(); j++) + { + switch(text[j]) + { + case '"': + dotSpec.append("\\\""); + break; + + case '\n': + dotSpec.append("\\n"); + break; + + case '\r': + dotSpec.append("\\r"); + break; + + default: + dotSpec += text[j]; + break; + } + } dotSpec.append("\n"); // Define edges for this child // this->defineDotEdges(child, dotSpec); } - + // Done // return; -} - -template<class ImplTraits> +} + +template<class ImplTraits> typename CommonTreeAdaptor<ImplTraits>::TreeTypePtr CommonTreeAdaptor<ImplTraits>::rulePostProcessing( TreeTypePtr& root) -{ +{ TreeTypePtr saveRoot = std::move(root); - + if (saveRoot != NULL && saveRoot->isNilNode()) { if (saveRoot->getChildCount() == 0) @@ -824,41 +824,41 @@ typename CommonTreeAdaptor<ImplTraits>::TreeTypePtr CommonTreeAdaptor<ImplTraits } } return saveRoot; -} - -template<class ImplTraits> -DebugTreeAdaptor<ImplTraits>::DebugTreeAdaptor( DebuggerType* debugger ) -{ +} + +template<class ImplTraits> +DebugTreeAdaptor<ImplTraits>::DebugTreeAdaptor( DebuggerType* debugger ) +{ m_debugger = debugger; -} - -template<class ImplTraits> -void DebugTreeAdaptor<ImplTraits>::setDebugEventListener( DebuggerType* debugger) -{ +} + +template<class ImplTraits> +void DebugTreeAdaptor<ImplTraits>::setDebugEventListener( DebuggerType* debugger) +{ m_debugger = debugger; -} - -template<class ImplTraits> +} + +template<class ImplTraits> typename DebugTreeAdaptor<ImplTraits>::TreeTypePtr DebugTreeAdaptor<ImplTraits>::nilNode() -{ +{ TreeTypePtr t = this->create(NULL); m_debugger->createNode(t); return t; -} - -template<class ImplTraits> +} + +template<class ImplTraits> void DebugTreeAdaptor<ImplTraits>::addChild(TreeTypePtr& t, TreeTypePtr& child) -{ +{ if (t != NULL && child != NULL) { t->addChild(child); m_debugger->addChild(t, child); } -} - -template<class ImplTraits> +} + +template<class ImplTraits> void DebugTreeAdaptor<ImplTraits>::addChildToken(TreeTypePtr& t, CommonTokenType* child) -{ +{ TreeTypePtr tc; if (t != NULL && child != NULL) { @@ -866,41 +866,41 @@ void DebugTreeAdaptor<ImplTraits>::addChildToken(TreeTypePtr& t, CommonTokenType this->addChild(t, tc); m_debugger->addChild(t, tc); } -} - -template<class ImplTraits> +} + +template<class ImplTraits> typename DebugTreeAdaptor<ImplTraits>::TreeTypePtr DebugTreeAdaptor<ImplTraits>::becomeRoot( TreeTypePtr& newRootTree, TreeTypePtr& oldRootTree ) -{ +{ TreeTypePtr t = super::becomeRoot(newRootTree, oldRootTree); m_debugger->becomeRoot(newRootTree, oldRootTree); return t; -} - -template<class ImplTraits> +} + +template<class ImplTraits> typename DebugTreeAdaptor<ImplTraits>::TreeTypePtr DebugTreeAdaptor<ImplTraits>::becomeRootToken(CommonTokenType* newRoot, TreeTypePtr& oldRoot) -{ +{ TreeTypePtr t = super::becomeRoot(this->create(newRoot), oldRoot); m_debugger->becomeRoot(t, oldRoot); return t; -} - -template<class ImplTraits> +} + +template<class ImplTraits> typename DebugTreeAdaptor<ImplTraits>::TreeTypePtr DebugTreeAdaptor<ImplTraits>::createTypeToken(ANTLR_UINT32 tokenType, CommonTokenType* fromToken) -{ +{ TreeTypePtr t; t = this->createTypeToken(tokenType, fromToken); m_debugger->createNode(t); return t; -} - -template<class ImplTraits> +} + +template<class ImplTraits> typename DebugTreeAdaptor<ImplTraits>::TreeTypePtr DebugTreeAdaptor<ImplTraits>::createTypeTokenText(ANTLR_UINT32 tokenType, CommonTokenType* fromToken, ANTLR_UINT8* text) -{ +{ TreeTypePtr t; t = this->createTypeTokenText(tokenType, fromToken, text); m_debugger->createNode(t); return t; -} +} template<class ImplTraits> typename DebugTreeAdaptor<ImplTraits>::TreeTypePtr DebugTreeAdaptor<ImplTraits>::createTypeText( ANTLR_UINT32 tokenType, ANTLR_UINT8* text) @@ -910,10 +910,10 @@ typename DebugTreeAdaptor<ImplTraits>::TreeTypePtr DebugTreeAdaptor<ImplTraits>: m_debugger->createNode(t); return t; } - -template<class ImplTraits> + +template<class ImplTraits> typename DebugTreeAdaptor<ImplTraits>::TreeTypePtr DebugTreeAdaptor<ImplTraits>::dupTree( const TreeTypePtr& tree) -{ +{ TreeTypePtr t; // Call the normal dup tree mechanism first @@ -928,38 +928,38 @@ typename DebugTreeAdaptor<ImplTraits>::TreeTypePtr DebugTreeAdaptor<ImplTraits>: this->simulateTreeConstruction( t); return t; -} - -template<class ImplTraits> +} + +template<class ImplTraits> typename DebugTreeAdaptor<ImplTraits>::TreeTypePtr DebugTreeAdaptor<ImplTraits>::dupTree( const TreeType* tree) -{ +{ TreeTypePtr t; - + // Call the normal dup tree mechanism first // t = this->dupTreeImpl(tree, NULL); - + // In order to tell the debugger what we have just done, we now // simulate the tree building mechanism. THis will fire // lots of debugging events to the client and look like we // duped the tree.. // this->simulateTreeConstruction( t); - + return t; -} - -template<class ImplTraits> +} + +template<class ImplTraits> void DebugTreeAdaptor<ImplTraits>::simulateTreeConstruction(TreeTypePtr& tree) -{ +{ ANTLR_UINT32 n; ANTLR_UINT32 i; TreeTypePtr child; - + // Send the create node event // m_debugger->createNode(tree); - + n = this->getChildCount(tree); for (i = 0; i < n; i++) { @@ -967,6 +967,6 @@ void DebugTreeAdaptor<ImplTraits>::simulateTreeConstruction(TreeTypePtr& tree) this->simulateTreeConstruction(child); m_debugger->addChild(tree, child); } -} - +} + } |