KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > antlr > CommonToken


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/CommonToken.java#6 $
8  */

9
10 public class CommonToken extends Token {
11     // most tokens will want line and text information
12
protected int line;
13     protected String JavaDoc text = null;
14     protected int col;
15
16     public CommonToken() {
17     }
18
19     public CommonToken(int t, String JavaDoc txt) {
20         type = t;
21         setText(txt);
22     }
23
24     public CommonToken(String JavaDoc s) {
25         text = s;
26     }
27
28     public int getLine() {
29         return line;
30     }
31
32     public String JavaDoc getText() {
33         return text;
34     }
35
36     public void setLine(int l) {
37         line = l;
38     }
39
40     public void setText(String JavaDoc s) {
41         text = s;
42     }
43
44     public String JavaDoc toString() {
45         return "[\"" + getText() + "\",<" + type + ">,line=" + line + ",col=" + col + "]";
46     }
47
48     /** Return token's start column */
49     public int getColumn() {
50         return col;
51     }
52
53     public void setColumn(int c) {
54         col = c;
55     }
56 }
57
Popular Tags