[antlr-interest] Lexer - Counting from zero

Thiago Arrais thiago.arrais at gmail.com
Wed Nov 23 19:24:31 PST 2005


I am writing a lexer with Antlr and I need it to keep track of the
line and column information. The standard way didn't suffice my needs,
because I needed to start the count at 0, not at 1. So, I overrid the
makeToken() method on my Lexer to reduce the coordinates by one.

It works, but I don't like it. Just seems too hacky for me. Is there
some standard way to do that? I browsed through the docs and the list
archives but the only advice I found was to override the consume()
method (on the manual). That looked even hackier to me.

Cheers,

Thiago Arrais


More information about the antlr-interest mailing list