How do I make ANTLR build a lexer that uses my own token class?

Ric Klaren

You can set the factory used to generate Tokens with a call to setTokenObjectFactory. Check out the java/C++ file for CharScanner. Or, tell the lexer what class you want to use:

public static void main(String[] args) {
  InstrLexer lexer =
    new InstrLexer(new DataInputStream(System.in));

Caveat: you probably have to do a lot of casting in your grammar actions.