Token.hpp
Go to the documentation of this file.00001 #ifndef INC_Token_hpp__ 00002 #define INC_Token_hpp__ 00003 00004 /* ANTLR Translator Generator 00005 * Project led by Terence Parr at http://www.jGuru.com 00006 * Software rights: http://www.antlr.org/RIGHTS.html 00007 * 00008 * $Id: Token.hpp,v 1.2 2003/05/02 00:36:19 okellogg Exp $ 00009 */ 00010 00011 #include <antlr/config.hpp> 00012 #include <antlr/RefCount.hpp> 00013 #include <string> 00014 00015 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 00016 namespace antlr { 00017 #endif 00018 00023 class ANTLR_API Token; 00024 typedef RefCount<Token> RefToken; 00025 00026 class ANTLR_API Token { 00027 public: 00028 // constants 00029 #ifndef NO_STATIC_CONSTS 00030 static const int MIN_USER_TYPE = 4; 00031 static const int NULL_TREE_LOOKAHEAD = 3; 00032 static const int INVALID_TYPE = 0; 00033 static const int EOF_TYPE = 1; 00034 static const int SKIP = -1; 00035 #else 00036 enum { 00037 MIN_USER_TYPE = 4, 00038 NULL_TREE_LOOKAHEAD = 3, 00039 INVALID_TYPE = 0, 00040 EOF_TYPE = 1, 00041 SKIP = -1 00042 }; 00043 #endif 00044 00045 // each Token has at least a token type 00046 int type; //=INVALID_TYPE; 00047 00048 public: 00049 // the illegal token object 00050 static RefToken badToken; // = new Token(INVALID_TYPE, "<no text>"); 00051 00052 Token(); 00053 Token(int t); 00054 Token(int t, const ANTLR_USE_NAMESPACE(std)string& txt); 00055 00056 virtual int getColumn() const; 00057 virtual int getLine() const; 00058 virtual ANTLR_USE_NAMESPACE(std)string getText() const; 00059 virtual int getType() const; 00060 00061 virtual void setColumn(int c); 00062 00063 virtual void setLine(int l); 00064 virtual void setText(const ANTLR_USE_NAMESPACE(std)string& t); 00065 virtual void setType(int t); 00066 00067 virtual ANTLR_USE_NAMESPACE(std)string toString() const; 00068 00069 virtual ~Token(); 00070 private: 00071 Token(const Token&); 00072 const Token& operator=(const Token&); 00073 }; 00074 00075 #ifdef NEEDS_OPERATOR_LESS_THAN 00076 inline operator<(RefToken l,RefToken r); //{return true;} 00077 #endif 00078 00079 extern ANTLR_API RefToken nullToken; 00080 00081 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 00082 } 00083 #endif 00084 00085 #endif //INC_Token_hpp__