~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to lib/antlr/antlr/CommonToken.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2006-05-23 18:39:42 UTC
  • Revision ID: james.westby@ubuntu.com-20060523183942-hucifbvh68k2bwz7
Tags: upstream-3.3.2
Import upstream version 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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/RIGHTS.html
 
7
 *
 
8
 */
 
9
 
 
10
#include <antlr/config.hpp>
 
11
#include <antlr/Token.hpp>
 
12
#include <string>
 
13
 
 
14
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
 
15
namespace antlr {
 
16
#endif
 
17
 
 
18
class ANTLR_API CommonToken : public Token {
 
19
public:
 
20
        CommonToken();
 
21
        CommonToken(int t, const ANTLR_USE_NAMESPACE(std)string& txt);
 
22
        CommonToken(const ANTLR_USE_NAMESPACE(std)string& s);
 
23
 
 
24
        /// return contents of token
 
25
        ANTLR_USE_NAMESPACE(std)string getText() const
 
26
        {
 
27
                return text;
 
28
        }
 
29
 
 
30
        /// set contents of token
 
31
        void setText(const ANTLR_USE_NAMESPACE(std)string& s)
 
32
        {
 
33
                text = s;
 
34
        }
 
35
 
 
36
        /** get the line the token is at (starting at 1)
 
37
         * @see CharScanner::newline()
 
38
         * @see CharScanner::tab()
 
39
         */
 
40
        int getLine() const
 
41
        {
 
42
                return line;
 
43
        }
 
44
        /** gt the column the token is at (starting at 1)
 
45
         * @see CharScanner::newline()
 
46
         * @see CharScanner::tab()
 
47
         */
 
48
        int getColumn() const
 
49
        {
 
50
                return col;
 
51
        }
 
52
 
 
53
        /// set line for token
 
54
        void setLine(int l)
 
55
        {
 
56
                line = l;
 
57
        }
 
58
        /// set column for token
 
59
        void setColumn(int c)
 
60
        {
 
61
                col = c;
 
62
        }
 
63
 
 
64
        bool isInvalid() const
 
65
        {
 
66
                return type==INVALID_TYPE;
 
67
        }
 
68
 
 
69
        ANTLR_USE_NAMESPACE(std)string toString() const;
 
70
        static RefToken factory();
 
71
 
 
72
protected:
 
73
        // most tokens will want line and text information
 
74
        int line;
 
75
        int col;
 
76
        ANTLR_USE_NAMESPACE(std)string text;
 
77
 
 
78
private:
 
79
        CommonToken(const CommonToken&);
 
80
        const CommonToken& operator=(const CommonToken&);
 
81
};
 
82
 
 
83
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
 
84
}
 
85
#endif
 
86
 
 
87
#endif //INC_CommonToken_hpp__