[antlr-interest] ANTLR 3 Tab Size

Gavin Lambert antlr at mirality.co.nz
Fri Sep 14 14:15:23 PDT 2007


At 08:53 15/09/2007, Terence Parr wrote:
 >Howdy.  Instead of column, v3 using notion of raw
 >charPositionInLine.  ANTLR should not be interpreting/expanding
 >tabs I decided.

But then won't everyone need to write their own tab-tracking code 
in order to display the column at which an error occurred?

If people don't want tabs "expanded" in the internal column count, 
then it's simple to set the tab size to 1 character.  Having ANTLR 
keep track of the column (including expanding tabs) is probably 
the most useful thing to do.  (You could even track both of them 
if you want, at the cost of one extra integer field per token.)

Of course, having said that, since tab size is frequently an 
editor setting, IDEs are about the only things that can reliably 
specify a tab size.  (If your command-line compiler specifies a 
tab size of 4 characters and the user's editor specifies one of 
three characters, then you're going to give them the wrong column 
anyway.)



More information about the antlr-interest mailing list