title: Is there a way to make ANTLR4 use enums for generated tokens?
body: <p>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?</p>
  
  <p>This is a simplified example off the top of my head</p>
  
  <p>x.g4</p>
  
  <pre><code>A: 'a';
  B: 'b';
  </code></pre>
  
  <p>XLexer.java</p>
  
  <pre><code>public class XLexer extends Lexer{
     public static final int A = 1, B = 2;
  }
  </code></pre>
  
  <p>I would prefer for XLexer to instead contain</p>
  
  <pre><code>public class XLexer extends Lexer{
    public static enum Token{
      A(1), B(2)
    }
  }
  </code></pre>
  
  <p>This is useful for debugging purposes when dumping tokens. Right now the token name is not printed, instead only the integer representation is provided.</p>
  
  <pre><code>[@-1,0:0='a',&lt;1&gt;,1:0]
  </code></pre>
  
  <p>A more readable version would have &lt;A&gt; instead of &lt;1></p>
  
  <pre><code>[@-1,0:0='a',&lt;A&gt;,1:0]
  </code></pre>