ANTLR Support Libraries 2.7.1+
ASTPair.hpp
Go to the documentation of this file.
1 #ifndef INC_ASTPair_hpp__
2 #define INC_ASTPair_hpp__
3 
4 /* ANTLR Translator Generator
5  * Project led by Terence Parr at http://www.jGuru.com
6  * Software rights: http://www.antlr.org/license.html
7  *
8  * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/ASTPair.hpp#2 $
9  */
10 
11 #include <antlr/config.hpp>
12 #include <antlr/AST.hpp>
13 
14 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
15 namespace antlr {
16 #endif
17 
27 public:
28  RefAST root; // current root of tree
29  RefAST child; // current child to which siblings are added
30 
33  if (child) {
34  while (child->getNextSibling()) {
35  child = child->getNextSibling();
36  }
37  }
38  }
39 // /** Copy an ASTPair. Don't call it clone() because we want type-safety */
40 // ASTPair copy() {
41 // ASTPair tmp = new ASTPair();
42 // tmp.root = root;
43 // tmp.child = child;
44 // return tmp;
45 // }
46  ANTLR_USE_NAMESPACE(std)string toString() const {
47  ANTLR_USE_NAMESPACE(std)string r = !root ? ANTLR_USE_NAMESPACE(std)string("null") : root->getText();
48  ANTLR_USE_NAMESPACE(std)string c = !child ? ANTLR_USE_NAMESPACE(std)string("null") : child->getText();
49  return "["+r+","+c+"]";
50  }
51 };
52 
53 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
54 }
55 #endif
56 
57 #endif //INC_ASTPair_hpp__
Definition: ANTLRException.hpp:15
RefAST root
Definition: ASTPair.hpp:28
#define ANTLR_API
Definition: config.hpp:22
RefAST child
Definition: ASTPair.hpp:29
virtual std ::string getText() const =0
Get the token text for this node.
void advanceChildToEnd()
Definition: ASTPair.hpp:32
virtual RefAST getNextSibling() const =0
Get the next sibling in line after this one.
Definition: ASTPair.hpp:26
#define ANTLR_USE_NAMESPACE(_x_)
Definition: config.hpp:18
std ::string toString() const
Definition: ASTPair.hpp:46