Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

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/license.html
00007  *
00008  * $Id: Token.hpp,v 1.1 2004/10/08 16:27:34 dfisher 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 extern ANTLR_API RefToken nullToken;
00076 
00077 #ifdef NEEDS_OPERATOR_LESS_THAN
00078 // RK: Added after 2.7.2 previously it was undefined.
00079 // AL: what to return if l and/or r point to nullToken???
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__

Generated on Wed Nov 3 12:59:05 2004 for Lemur Toolkit by doxygen1.2.18