In ANTLR4 the generated lexer in Java contains a public field for each token where the type of the field is a simple 'int'. Is there a reason why ANTLR4 does not use enums instead, or is there an option to make it use enums?
This is a simplified example off the top of my head
x.g4
A: 'a';
B: 'b';
XLexer.java
public class XLexer extends Lexer{
public static final int A = 1, B = 2;
}
I would prefer for XLexer to instead contain
public class XLexer extends Lexer{
public static enum Token{
A(1), B(2)
}
}
This is useful for debugging purposes when dumping tokens. Right now the token name is not printed, instead only the integer representation is provided.
[@-1,0:0='a',<1>,1:0]
A more readable version would have <A> instead of <1>
[@-1,0:0='a',<A>,1:0]