1 #ifndef INC_Token_hpp__
2 #define INC_Token_hpp__
4 /* ANTLR Translator Generator
5 * Project led by Terence Parr at http://www.jGuru.com
6 * Software rights: http://www.antlr.org/license.html
8 * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/Token.hpp#2 $
11 #include <antlr/config.hpp>
12 #include <antlr/TokenRefCount.hpp>
15 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
21 /** A token is minimally a token type. Subclasses can add the text matched
22 * for the token and line info.
28 #ifndef NO_STATIC_CONSTS
29 static const int MIN_USER_TYPE = 4;
30 static const int NULL_TREE_LOOKAHEAD = 3;
31 static const int INVALID_TYPE = 0;
32 static const int EOF_TYPE = 1;
33 static const int SKIP = -1;
37 NULL_TREE_LOOKAHEAD = 3,
54 Token(int t, const ANTLR_USE_NAMESPACE(std)string& txt)
64 virtual int getColumn() const;
65 virtual int getLine() const;
66 virtual ANTLR_USE_NAMESPACE(std)string getText() const;
67 virtual const ANTLR_USE_NAMESPACE(std)string& getFilename() const;
68 virtual int getType() const;
70 virtual void setColumn(int c);
72 virtual void setLine(int l);
73 virtual void setText(const ANTLR_USE_NAMESPACE(std)string& t);
74 virtual void setType(int t);
76 virtual void setFilename( const std::string& file );
78 virtual ANTLR_USE_NAMESPACE(std)string toString() const;
81 friend struct TokenRef;
84 int type; ///< the type of the token
86 Token(RefToken other);
87 Token& operator=(const Token& other);
88 Token& operator=(RefToken other);
93 extern ANTLR_API RefToken nullToken;
95 #ifdef NEEDS_OPERATOR_LESS_THAN
96 // RK: Added after 2.7.2 previously it was undefined.
97 // AL: what to return if l and/or r point to nullToken???
98 inline bool operator<( RefToken l, RefToken r )
100 return nullToken == l ? ( nullToken == r ? false : true ) : l->getType() < r->getType();
104 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
108 #endif //INC_Token_hpp__