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

BaseAST.hpp

Go to the documentation of this file.
00001 #ifndef INC_BaseAST_hpp__
00002 #define INC_BaseAST_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: BaseAST.hpp,v 1.1 2004/10/08 16:27:34 dfisher Exp $
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 
00018 class ANTLR_API BaseAST;
00019 typedef ASTRefCount<BaseAST> RefBaseAST;
00020 
00021 class ANTLR_API BaseAST : public AST {
00022 public:
00023         BaseAST();
00024         BaseAST(const BaseAST& other);
00025 
00026         virtual ~BaseAST();
00027 
00029         virtual const char* typeName( void ) const;
00030 
00032         virtual RefAST clone( void ) const;
00033 
00035         virtual bool equals(RefAST t) const;
00036 
00040         virtual bool equalsList(RefAST t) const;
00041 
00044         virtual bool equalsListPartial(RefAST t) const;
00045 
00049         virtual bool equalsTree(RefAST t) const;
00050 
00054         virtual bool equalsTreePartial(RefAST t) const;
00055 
00060         virtual ANTLR_USE_NAMESPACE(std)vector<RefAST> findAll(RefAST t);
00061 
00066         virtual ANTLR_USE_NAMESPACE(std)vector<RefAST> findAllPartial(RefAST t);
00067 
00069         virtual void addChild(RefAST c);
00073         virtual size_t getNumberOfChildren() const;
00074 
00076         virtual RefAST getFirstChild() const
00077         {
00078                 return RefAST(down);
00079         }
00081         virtual RefAST getNextSibling() const
00082         {
00083                 return RefAST(right);
00084         }
00085 
00087         virtual ANTLR_USE_NAMESPACE(std)string getText() const
00088         {
00089                 return "";
00090         }
00092         virtual int getType() const
00093         {
00094                 return 0;
00095         }
00096 
00098         virtual void removeChildren()
00099         {
00100                 down = static_cast<BaseAST*>(static_cast<AST*>(nullAST));
00101         }
00102 
00104         virtual void setFirstChild(RefAST c)
00105         {
00106                 down = static_cast<BaseAST*>(static_cast<AST*>(c));
00107         }
00108 
00110         void setNextSibling(RefAST n)
00111         {
00112                 right = static_cast<BaseAST*>(static_cast<AST*>(n));
00113         }
00114 
00116         virtual void setText(const ANTLR_USE_NAMESPACE(std)string& txt);
00117 
00119         virtual void setType(int type);
00120 
00121 #ifdef ANTLR_SUPPORT_XML
00122 
00126         virtual bool attributesToStream( ANTLR_USE_NAMESPACE(std)ostream& out ) const;
00131         virtual void toStream( ANTLR_USE_NAMESPACE(std)ostream &out ) const;
00132 #endif
00133 
00135         virtual ANTLR_USE_NAMESPACE(std)string toString() const;
00136 
00138         virtual ANTLR_USE_NAMESPACE(std)string toStringList() const;
00139         virtual ANTLR_USE_NAMESPACE(std)string toStringTree() const;
00140 
00141         static const char* const TYPE_NAME;
00142 protected:
00143         RefBaseAST down;
00144         RefBaseAST right;
00145 private:
00146         void doWorkForFindAll(ANTLR_USE_NAMESPACE(std)vector<RefAST>& v,
00147                                                                  RefAST target,
00148                                                                  bool partialMatch);
00149 };
00150 
00153 inline bool BaseAST::equals(RefAST t) const
00154 {
00155         if (!t)
00156                 return false;
00157         return ((getType() == t->getType()) && (getText() == t->getText()));
00158 }
00159 
00160 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
00161 }
00162 #endif
00163 
00164 #endif //INC_BaseAST_hpp__

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