00001 #ifndef INC_CommonToken_hpp__ 00002 #define INC_CommonToken_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: CommonToken.hpp,v 1.1 2004/10/08 16:27:34 dfisher Exp $ 00009 */ 00010 00011 #include <antlr/config.hpp> 00012 #include <antlr/Token.hpp> 00013 #include <string> 00014 00015 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 00016 namespace antlr { 00017 #endif 00018 00019 class ANTLR_API CommonToken : public Token { 00020 public: 00021 CommonToken(); 00022 CommonToken(int t, const ANTLR_USE_NAMESPACE(std)string& txt); 00023 CommonToken(const ANTLR_USE_NAMESPACE(std)string& s); 00024 00026 ANTLR_USE_NAMESPACE(std)string getText() const 00027 { 00028 return text; 00029 } 00030 00032 void setText(const ANTLR_USE_NAMESPACE(std)string& s) 00033 { 00034 text = s; 00035 } 00036 00041 int getLine() const 00042 { 00043 return line; 00044 } 00049 int getColumn() const 00050 { 00051 return col; 00052 } 00053 00055 void setLine(int l) 00056 { 00057 line = l; 00058 } 00060 void setColumn(int c) 00061 { 00062 col = c; 00063 } 00064 00065 bool isInvalid() const 00066 { 00067 return type==INVALID_TYPE; 00068 } 00069 00070 ANTLR_USE_NAMESPACE(std)string toString() const; 00071 static RefToken factory(); 00072 00073 protected: 00074 // most tokens will want line and text information 00075 int line; 00076 int col; 00077 ANTLR_USE_NAMESPACE(std)string text; 00078 00079 private: 00080 CommonToken(const CommonToken&); 00081 const CommonToken& operator=(const CommonToken&); 00082 }; 00083 00084 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 00085 } 00086 #endif 00087 00088 #endif //INC_CommonToken_hpp__