[antlr-interest] potentially stupid question

Martin Probst mail at martin-probst.com
Thu Oct 20 07:09:27 PDT 2005


Hi,

> What I also need is the offset, from the beginning of the input
> stream/buffer. I noticed a mark() method in the Parser base class, but
> I'm not sure if this is what I want to use.

No, that one is used for rewinding the stream afaik. But it should be
fairly easy to modify your Lexer to keep track of the character/byte
offset in the file. I'm not completely sure where, but there is some
place where the Lexer increases the column count by one. 

Just override the method and add another field ('offset') and increase
that one too, but don't set it to zero on a line break. Should do the
trick.

Martin



More information about the antlr-interest mailing list