ANTLR Support Libraries 2.7.1+

antlr/ASTPair.hpp

Go to the documentation of this file.
00001 #ifndef INC_ASTPair_hpp__
00002 #define INC_ASTPair_hpp__
00003 
00004 /* ANTLR Translator Generator
00005  * Project led by Terence Parr at http://www.jGuru.com
00006  * Software rights: http://www.antlr.org/license.html
00007  *
00008  * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/ASTPair.hpp#2 $
00009  */
00010 
00011 #include <antlr/config.hpp>
00012 #include <antlr/AST.hpp>
00013 
00014 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
00015 namespace antlr {
00016 #endif
00017 
00026 class ANTLR_API ASTPair {
00027 public:
00028    RefAST root;      // current root of tree
00029    RefAST child;     // current child to which siblings are added
00030 
00032    void advanceChildToEnd() {
00033       if (child) {
00034          while (child->getNextSibling()) {
00035             child = child->getNextSibling();
00036          }
00037       }
00038    }
00039 // /** Copy an ASTPair.  Don't call it clone() because we want type-safety */
00040 // ASTPair copy() {
00041 //    ASTPair tmp = new ASTPair();
00042 //    tmp.root = root;
00043 //    tmp.child = child;
00044 //    return tmp;
00045 // }
00046    ANTLR_USE_NAMESPACE(std)string toString() const {
00047       ANTLR_USE_NAMESPACE(std)string r = !root ? ANTLR_USE_NAMESPACE(std)string("null") : root->getText();
00048       ANTLR_USE_NAMESPACE(std)string c = !child ? ANTLR_USE_NAMESPACE(std)string("null") : child->getText();
00049       return "["+r+","+c+"]";
00050    }
00051 };
00052 
00053 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
00054 }
00055 #endif
00056 
00057 #endif //INC_ASTPair_hpp__
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines