[antlr-interest] ambigous lexer tokens

Wincent Colaiuta win at wincent.com
Thu Jun 28 05:48:21 PDT 2007


El 28/6/2007, a las 14:25, Gavin Lambert escribió:

> 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.

I didn't mean "column" in that sense (number of characters) but in  
the sense that his input has multiple vertical "columns" separated by  
whitespace:

col:   1            2  3       4         5   6   7  8     9
        drwxr-xr-x   23 tcurdt  tcurdt    782 Jun 24 22:54 ..

Cheers,
Wincent



More information about the antlr-interest mailing list