[antlr-interest] ambigous lexer tokens
Gavin Lambert
antlr at mirality.co.nz
Thu Jun 28 05:25:03 PDT 2007
At 22:20 28/06/2007, Wincent Colaiuta wrote:
>Well, here's one (untested) idea: one way might be to modify
your
>WS rule to increment a "column" counter whenever a run of spaces
>is seen; you'd have to set up the column counter in your
>@lexer::members section (exactly how you set up and initialize
>that variable is dependent on your target language):
>
> WS : ' '+ { column++; };
Actually, I'm pretty sure that v3 tracks the column for you, so
there's no need to do it manually. How you get hold of it varies
by target language, though, but it's usually a property/field of
the lexer class, I think.
In fact I vaguely remember there being an example script for a
column-sensitive language (Fortran, maybe? Not sure) either in
the v3 examples bundle or on the Wiki.
(Sorry for being so vague; it's after midnight.)
More information about the antlr-interest
mailing list