KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > antlr > Token


1 package antlr;
2
3 /* ANTLR Translator Generator
4  * Project led by Terence Parr at http://www.jGuru.com
5  * Software rights: http://www.antlr.org/RIGHTS.html
6  *
7  * $Id: //depot/code/org.antlr/main/main/antlr/Token.java#5 $
8  */

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

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