00001 #ifndef INC_Token_hpp__
00002 #define INC_Token_hpp__
00003
00004
00005
00006
00007
00008
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
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
00046 int type;
00047
00048 public:
00049
00050 static RefToken badToken;
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 extern ANTLR_API RefToken nullToken;
00076
00077 #ifdef NEEDS_OPERATOR_LESS_THAN
00078
00079
00080 inline bool operator<( RefToken l, RefToken r )
00081 {
00082 return nullToken == l ? ( nullToken == r ? false : true ) : l->getType() < r->getType();
00083 }
00084 #endif
00085
00086 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
00087 }
00088 #endif
00089
00090 #endif //INC_Token_hpp__