L1Main.java
import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.Token;
public class L1Main {
public static void main(String[] args) throws Exception {
ANTLRStringStream input=new ANTLRStringStream(" a ab 123456 abc abcd abcde zz ");
L1 lexer = new L1(input);
int i=0;
Token token;
while( (token=lexer.nextToken()).getType() !=Token.EOF) {
System.out.println(i+++": ("+token.getType()+",#"+token.getText()+"#)");
}
}
}
Output
0: (5,# #)
a
1: (6,#a #)
ab
2: (6,#ab #)
3: (7,#1#)
4: (7,#2#)
5: (7,#3#)
6: (7,#4#)
7: (7,#5#)
8: (7,#6#)
9: (5,# #)
abc
10: (6,#abc #)
abcd
11: (6,#abcd #)
abcde
12: (6,#abcde #)
zz
13: (6,#zz #)