11#include <antlr/config.hpp>
12#include <antlr/ASTRefCount.hpp>
13#include <antlr/Token.hpp>
17#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
26 AST(
const AST&) : ref(0) {}
30 virtual const char*
typeName(
void )
const = 0;
75 virtual ANTLR_USE_NAMESPACE(std)
string getText()
const = 0;
82 virtual void initialize(
int t,
const ANTLR_USE_NAMESPACE(std)
string& txt) = 0;
83 virtual void initialize(
RefAST t) = 0;
84 virtual void initialize(
RefToken t) = 0;
86#ifdef ANTLR_SUPPORT_XML
90 virtual void initialize( ANTLR_USE_NAMESPACE(std)istream& in ) = 0;
99 virtual void setText(
const ANTLR_USE_NAMESPACE(std)
string& txt) = 0;
104 virtual ANTLR_USE_NAMESPACE(std)
string toString()
const = 0;
108 virtual ANTLR_USE_NAMESPACE(std)
string toStringTree()
const = 0;
110#ifdef ANTLR_SUPPORT_XML
116 virtual bool attributesToStream( ANTLR_USE_NAMESPACE(std)ostream& out )
const = 0;
122 virtual void toStream( ANTLR_USE_NAMESPACE(std)ostream &out )
const = 0;
130 friend ANTLR_USE_NAMESPACE(std)ostream& operator<<( ANTLR_USE_NAMESPACE(std)ostream& output,
const RefAST& ast );
138 AST& operator=(
const AST& other);
142#ifdef ANTLR_SUPPORT_XML
143inline ANTLR_USE_NAMESPACE(std)ostream& operator<<( ANTLR_USE_NAMESPACE(std)ostream& output,
const RefAST& ast )
145 ast->toStream(output);
150extern ANTLR_API RefAST nullAST;
151extern ANTLR_API AST*
const nullASTptr;
153#ifdef NEEDS_OPERATOR_LESS_THAN
156inline bool operator<( RefAST l, RefAST r )
158 return nullAST == l ? ( nullAST == r ? false : true ) : l->getType() < r->getType();
162#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
virtual RefAST getFirstChild() const =0
Get the first child of this node; null if no children.
virtual const char * typeName(void) const =0
Return the type name for this AST node. (for XML output)
virtual bool equalsTree(RefAST t) const =0
Is tree rooted at 'this' equal to 't'? The siblings of 'this' are ignored.
virtual RefAST getNextSibling() const =0
Get the next sibling in line after this one.
virtual int getType() const =0
Get the token type for this node.
virtual std ::vector< RefAST > findAllPartial(RefAST t)=0
Walk the tree looking for all subtrees.
virtual bool equalsTreePartial(RefAST t) const =0
Is 't' a subtree of the tree rooted at 'this'? The siblings of 'this' are ignored.
virtual bool equals(RefAST t) const =0
Is node t equal to this in terms of token type and text?
virtual std::string toStringList() const =0
Print out a child-sibling tree in LISP notation.
virtual void initialize(int t, const std ::string &txt)=0
Various initialization routines.
virtual void setType(int type)=0
Set the token type for this node.
virtual void setNextSibling(RefAST n)=0
Set the next sibling after this one.
virtual size_t getNumberOfChildren() const =0
Get the number of children. Returns 0 if the node is a leaf.
virtual std::string getText() const =0
Get the token text for this node.
virtual void addChild(RefAST c)=0
Add a node to the end of the child list for this node.
virtual std::string toString() const =0
Return this AST node as a string.
virtual void setText(const std ::string &txt)=0
Set the token text for this node.
virtual std ::vector< RefAST > findAll(RefAST t)=0
Walk the tree looking for all exact subtree matches.
virtual bool equalsList(RefAST t) const =0
Is t an exact structural and equals() match of this tree.
virtual bool equalsListPartial(RefAST t) const =0
Is 't' a subtree of this list? The siblings of the root are NOT ignored.
virtual void setFirstChild(RefAST c)=0
Set the first child of a node.
virtual RefAST clone(void) const =0
Clone this AST node.