source: trunk/yao/share/antlr-2.7.7/lib/cpp/antlr/CommonToken.hpp @ 1

Last change on this file since 1 was 1, checked in by lnalod, 15 years ago

Initial import of YAO sources

File size: 1.7 KB
Line 
1#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: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/CommonToken.hpp#2 $
9 */
10
11#include <antlr/config.hpp>
12#include <antlr/Token.hpp>
13#include <string>
14
15#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
16namespace antlr {
17#endif
18
19class ANTLR_API CommonToken : public Token {
20public:
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
68protected:
69        // most tokens will want line and text information
70        int line;
71        int col;
72        ANTLR_USE_NAMESPACE(std)string text;
73
74private:
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__
Note: See TracBrowser for help on using the repository browser.