KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > persistence > antlr > TokenWithIndex


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 /** This token knows what index 0..n-1 it is from beginning of stream.
9  * Designed to work with TokenStreamRewriteEngine.java
10  */

11 public class TokenWithIndex extends CommonToken {
12     /** Index into token array indicating position in input stream */
13     int index;
14
15     public TokenWithIndex() {
16     super();
17     }
18
19     public TokenWithIndex(int i, String JavaDoc t) {
20     super(i,t);
21     }
22
23     public void setIndex(int i) {
24         index = i;
25     }
26
27     public int getIndex() {
28         return index;
29     }
30
31     public String JavaDoc toString() {
32         return "["+index+":\"" + getText() + "\",<" + getType() + ">,line=" + line + ",col=" +
33 col + "]\n";
34     }
35 }
36
Popular Tags