KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > persistence > antlr > Token


1 package persistence.antlr;
2
3 /* ANTLR Translator Generator
4  * Project led by Terence Parr at http://www.jGuru.com
5  * Software rights: http://www.antlr.org/license.html
6  *
7  */

8
9 /** A token is minimally a token type. Subclasses can add the text matched
10  * for the token and line info.
11  */

12 public class Token implements Cloneable JavaDoc {
13     // constants
14
public static final int MIN_USER_TYPE = 4;
15     public static final int NULL_TREE_LOOKAHEAD = 3;
16     public static final int INVALID_TYPE = 0;
17     public static final int EOF_TYPE = 1;
18     public static final int SKIP = -1;
19
20     // each Token has at least a token type
21
int type = INVALID_TYPE;
22
23     // the illegal token object
24
public static Token badToken = new Token(INVALID_TYPE, "<no text>");
25
26     public Token() {
27     }
28
29     public Token(int t) {
30         type = t;
31     }
32
33     public Token(int t, String JavaDoc txt) {
34         type = t;
35         setText(txt);
36     }
37
38     public int getColumn() {
39         return 0;
40     }
41
42     public int getLine() {
43         return 0;
44     }
45
46     public String JavaDoc getFilename() {
47         return null;
48     }
49
50     public void setFilename(String JavaDoc name) {
51     }
52
53     public String JavaDoc getText() {
54         return "<no text>";
55     }
56
57     public void setText(String JavaDoc t) {
58     }
59
60     public void setColumn(int c) {
61     }
62
63     public void setLine(int l) {
64     }
65
66     public int getType() {
67         return type;
68     }
69
70     public void setType(int t) {
71         type = t;
72     }
73
74     public String JavaDoc toString() {
75         return "[\"" + getText() + "\",<" + type + ">]";
76     }
77 }
78
Popular Tags