ANTLR Support Libraries 2.7.1+
|
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: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/CommonToken.hpp#2 $ 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 virtual ANTLR_USE_NAMESPACE(std)string getText() const 00027 { 00028 return text; 00029 } 00030 00032 virtual void setText(const ANTLR_USE_NAMESPACE(std)string& s) 00033 { 00034 text = s; 00035 } 00036 00041 virtual int getLine() const 00042 { 00043 return line; 00044 } 00049 virtual int getColumn() const 00050 { 00051 return col; 00052 } 00053 00055 virtual void setLine(int l) 00056 { 00057 line = l; 00058 } 00060 virtual void setColumn(int c) 00061 { 00062 col = c; 00063 } 00064 00065 virtual ANTLR_USE_NAMESPACE(std)string toString() const; 00066 static RefToken factory(); 00067 00068 protected: 00069 // most tokens will want line and text information 00070 int line; 00071 int col; 00072 ANTLR_USE_NAMESPACE(std)string text; 00073 00074 private: 00075 CommonToken(const CommonToken&); 00076 const CommonToken& operator=(const CommonToken&); 00077 }; 00078 00079 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 00080 } 00081 #endif 00082 00083 #endif //INC_CommonToken_hpp__