ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/antlr/CommonToken.hpp
Revision: 2469
Committed: Fri Dec 2 15:38:03 2005 UTC (18 years, 7 months ago) by tim
File size: 1674 byte(s)
Log Message:
End of the Link --> List
Return of the Oject-Oriented
replace yacc/lex parser with antlr parser

File Contents

# User Rev Content
1 tim 2469 #ifndef INC_CommonToken_hpp__
2     #define INC_CommonToken_hpp__
3    
4     /* ANTLR Translator Generator
5     * Project led by Terence Parr at http://www.jGuru.com
6     * Software rights: http://www.antlr.org/license.html
7     *
8     * $Id: CommonToken.hpp,v 1.1 2005-12-02 15:38:02 tim Exp $
9     */
10    
11     #include <antlr/config.hpp>
12     #include <antlr/Token.hpp>
13     #include <string>
14    
15     #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
16     namespace antlr {
17     #endif
18    
19     class ANTLR_API CommonToken : public Token {
20     public:
21     CommonToken();
22     CommonToken(int t, const ANTLR_USE_NAMESPACE(std)string& txt);
23     CommonToken(const ANTLR_USE_NAMESPACE(std)string& s);
24    
25     /// return contents of token
26     virtual ANTLR_USE_NAMESPACE(std)string getText() const
27     {
28     return text;
29     }
30    
31     /// set contents of token
32     virtual void setText(const ANTLR_USE_NAMESPACE(std)string& s)
33     {
34     text = s;
35     }
36    
37     /** get the line the token is at (starting at 1)
38     * @see CharScanner::newline()
39     * @see CharScanner::tab()
40     */
41     virtual int getLine() const
42     {
43     return line;
44     }
45     /** gt the column the token is at (starting at 1)
46     * @see CharScanner::newline()
47     * @see CharScanner::tab()
48     */
49     virtual int getColumn() const
50     {
51     return col;
52     }
53    
54     /// set line for token
55     virtual void setLine(int l)
56     {
57     line = l;
58     }
59     /// set column for token
60     virtual void setColumn(int c)
61     {
62     col = c;
63     }
64    
65     virtual ANTLR_USE_NAMESPACE(std)string toString() const;
66     static RefToken factory();
67    
68     protected:
69     // most tokens will want line and text information
70     int line;
71     int col;
72     ANTLR_USE_NAMESPACE(std)string text;
73    
74     private:
75     CommonToken(const CommonToken&);
76     const CommonToken& operator=(const CommonToken&);
77     };
78    
79     #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
80     }
81     #endif
82    
83     #endif //INC_CommonToken_hpp__