01: package antlr;
02:
03: /* ANTLR Translator Generator
04: * Project led by Terence Parr at http://www.cs.usfca.edu
05: * Software rights: http://www.antlr.org/license.html
06: */
07:
08: /** This token knows what index 0..n-1 it is from beginning of stream.
09: * 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 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 toString() {
32: return "[" + index + ":\"" + getText() + "\",<" + getType()
33: + ">,line=" + line + ",col=" + col + "]\n";
34: }
35: }
|