| 1 |
#ifndef INC_CommonAST_hpp__ |
| 2 |
#define INC_CommonAST_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$ |
| 9 |
*/ |
| 10 |
|
| 11 |
#include <antlr/config.hpp> |
| 12 |
#include <antlr/BaseAST.hpp> |
| 13 |
|
| 14 |
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE |
| 15 |
namespace antlr { |
| 16 |
#endif |
| 17 |
|
| 18 |
class ANTLR_API CommonAST : public BaseAST { |
| 19 |
public: |
| 20 |
CommonAST() |
| 21 |
: BaseAST() |
| 22 |
, ttype( Token::INVALID_TYPE ) |
| 23 |
, text() |
| 24 |
{ |
| 25 |
} |
| 26 |
|
| 27 |
CommonAST( RefToken t ) |
| 28 |
: BaseAST() |
| 29 |
, ttype( t->getType() ) |
| 30 |
, text( t->getText() ) |
| 31 |
{ |
| 32 |
} |
| 33 |
|
| 34 |
CommonAST( const CommonAST& other ) |
| 35 |
: BaseAST(other) |
| 36 |
, ttype(other.ttype) |
| 37 |
, text(other.text) |
| 38 |
{ |
| 39 |
} |
| 40 |
|
| 41 |
virtual ~CommonAST() |
| 42 |
{ |
| 43 |
} |
| 44 |
|
| 45 |
virtual const char* typeName( void ) const |
| 46 |
{ |
| 47 |
return CommonAST::TYPE_NAME; |
| 48 |
} |
| 49 |
|
| 50 |
/// Clone this AST node. |
| 51 |
virtual RefAST clone( void ) const |
| 52 |
{ |
| 53 |
CommonAST *ast = new CommonAST( *this ); |
| 54 |
return RefAST(ast); |
| 55 |
} |
| 56 |
|
| 57 |
virtual ANTLR_USE_NAMESPACE(std)string getText() const |
| 58 |
{ |
| 59 |
return text; |
| 60 |
} |
| 61 |
virtual int getType() const |
| 62 |
{ |
| 63 |
return ttype; |
| 64 |
} |
| 65 |
|
| 66 |
virtual void initialize( int t, const ANTLR_USE_NAMESPACE(std)string& txt ) |
| 67 |
{ |
| 68 |
setType(t); |
| 69 |
setText(txt); |
| 70 |
} |
| 71 |
|
| 72 |
virtual void initialize( RefAST t ) |
| 73 |
{ |
| 74 |
setType(t->getType()); |
| 75 |
setText(t->getText()); |
| 76 |
} |
| 77 |
virtual void initialize( RefToken t ) |
| 78 |
{ |
| 79 |
setType(t->getType()); |
| 80 |
setText(t->getText()); |
| 81 |
} |
| 82 |
|
| 83 |
#ifdef ANTLR_SUPPORT_XML |
| 84 |
virtual void initialize( ANTLR_USE_NAMESPACE(std)istream& in ); |
| 85 |
#endif |
| 86 |
|
| 87 |
virtual void setText( const ANTLR_USE_NAMESPACE(std)string& txt ) |
| 88 |
{ |
| 89 |
text = txt; |
| 90 |
} |
| 91 |
virtual void setType( int type ) |
| 92 |
{ |
| 93 |
ttype = type; |
| 94 |
} |
| 95 |
|
| 96 |
static RefAST factory(); |
| 97 |
|
| 98 |
static const char* const TYPE_NAME; |
| 99 |
protected: |
| 100 |
int ttype; |
| 101 |
ANTLR_USE_NAMESPACE(std)string text; |
| 102 |
}; |
| 103 |
|
| 104 |
typedef ASTRefCount<CommonAST> RefCommonAST; |
| 105 |
|
| 106 |
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE |
| 107 |
} |
| 108 |
#endif |
| 109 |
|
| 110 |
#endif //INC_CommonAST_hpp__ |