Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

AST.hpp

Go to the documentation of this file.
00001 #ifndef INC_AST_hpp__
00002 #define INC_AST_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: AST.hpp,v 1.1 2004/10/08 16:27:34 dfisher Exp $
00009  */
00010 
00011 #include <antlr/config.hpp>
00012 #include <antlr/ASTRefCount.hpp>
00013 #include <antlr/Token.hpp>
00014 #include <vector>
00015 #include <string>
00016 
00017 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
00018 namespace antlr {
00019 #endif
00020 
00021 struct ASTRef;
00022 
00023 class ANTLR_API AST {
00024 public:
00025         AST() : ref(0) {}
00026         AST(const AST&) : ref(0) {}
00027         virtual ~AST() {}
00028 
00030         virtual const char* typeName( void ) const = 0;
00032         virtual RefAST clone( void ) const = 0;
00034         virtual bool equals(RefAST t) const = 0;
00038         virtual bool equalsList(RefAST t) const = 0;
00039 
00042         virtual bool equalsListPartial(RefAST t) const = 0;
00046         virtual bool equalsTree(RefAST t) const = 0;
00050         virtual bool equalsTreePartial(RefAST t) const = 0;
00051 
00056         virtual ANTLR_USE_NAMESPACE(std)vector<RefAST> findAll(RefAST t) = 0;
00057 
00062         virtual ANTLR_USE_NAMESPACE(std)vector<RefAST> findAllPartial(RefAST t) = 0;
00063 
00065         virtual void addChild(RefAST c) = 0;
00067         virtual size_t getNumberOfChildren() const = 0;
00068 
00070         virtual RefAST getFirstChild() const = 0;
00072         virtual RefAST getNextSibling() const = 0;
00073 
00075         virtual ANTLR_USE_NAMESPACE(std)string getText() const = 0;
00077         virtual int getType() const = 0;
00078 
00082         virtual void initialize(int t, const ANTLR_USE_NAMESPACE(std)string& txt) = 0;
00083         virtual void initialize(RefAST t) = 0;
00084         virtual void initialize(RefToken t) = 0;
00085 
00086 #ifdef ANTLR_SUPPORT_XML
00087 
00090         virtual void initialize( ANTLR_USE_NAMESPACE(std)istream& in ) = 0;
00091 #endif
00092 
00094         virtual void setFirstChild(RefAST c) = 0;
00096         virtual void setNextSibling(RefAST n) = 0;
00097 
00099         virtual void setText(const ANTLR_USE_NAMESPACE(std)string& txt) = 0;
00101         virtual void setType(int type) = 0;
00102 
00104         virtual ANTLR_USE_NAMESPACE(std)string toString() const = 0;
00105 
00107         virtual ANTLR_USE_NAMESPACE(std)string toStringList() const = 0;
00108         virtual ANTLR_USE_NAMESPACE(std)string toStringTree() const = 0;
00109 
00110 #ifdef ANTLR_SUPPORT_XML
00111 
00116         virtual bool attributesToStream( ANTLR_USE_NAMESPACE(std)ostream& out ) const = 0;
00117 
00122         virtual void toStream( ANTLR_USE_NAMESPACE(std)ostream &out ) const = 0;
00123 
00130         friend ANTLR_USE_NAMESPACE(std)ostream& operator<<( ANTLR_USE_NAMESPACE(std)ostream& output, const RefAST& ast );
00131 #endif
00132 
00133 private:
00134         friend struct ASTRef;
00135         ASTRef* ref;
00136 
00137         AST(RefAST other);
00138         AST& operator=(const AST& other);
00139         AST& operator=(RefAST other);
00140 };
00141 
00142 #ifdef ANTLR_SUPPORT_XML
00143 inline ANTLR_USE_NAMESPACE(std)ostream& operator<<( ANTLR_USE_NAMESPACE(std)ostream& output, const RefAST& ast )
00144 {
00145         ast->toStream(output);
00146         return output;
00147 }
00148 #endif
00149 
00150 extern ANTLR_API RefAST nullAST;
00151 extern ANTLR_API AST* const nullASTptr;
00152 
00153 #ifdef NEEDS_OPERATOR_LESS_THAN
00154 // RK: apparently needed by MSVC and a SUN CC, up to and including
00155 // 2.7.2 this was undefined ?
00156 inline bool operator<( RefAST l, RefAST r )
00157 {
00158         return nullAST == l ? ( nullAST == r ? false : true ) : l->getType() < r->getType();
00159 }
00160 #endif
00161 
00162 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
00163 }
00164 #endif
00165 
00166 #endif //INC_AST_hpp__

Generated on Wed Nov 3 12:58:51 2004 for Lemur Toolkit by doxygen1.2.18