[antlr-interest] ANTLR 3.0.1: invalid character column in a mismatch character error message.

Jim Idle jimi at temporal-wave.com
Tue Aug 12 15:51:54 PDT 2008


On Wed, 2008-08-13 at 09:37 +1200, Gavin Lambert wrote:

> At 09:31 12/08/2008, Terence Parr wrote:
>  >oh, right.  Well, yeah, people expect column...problem is what 
> to
>  >do with tabs etc...can override message handler though
> 
> True, tabs could get tricky.
> 
> Still, couldn't the lexer have a setTabSize() method or 
> something?  Default it to 8, since that's the official standard 
> tab size (even though most people usually reduce it), and let the 
> driver code (or ANTLRworks) modify as needed.  Then ANTLR can 
> generate errors using the "true" column number instead of the char 
> position, which is fairly meaningless to an end user.
> 
> And yes, the handler can be overridden.  But if it behaves as 
> people expect out of the box then it'll lead to less confusion, 
> especially for ANTLR newbies.  And I think there's already enough 
> things to confuse newbies as it is ;)
> 
> I guess this means that the token would have to track both column 
> number and char position, though, since one cannot be simply 
> derived from the other.  (Actually, on that note: does it also 
> track the absolute position in the char stream, instead of that 
> relative to the start of line?  That could also be useful, if not.)


Once you start adding all these traces then you find the lexers generate
3 tokens a minute. The base information is all there and I think FAQ #1
just needs to be: "Why you need your own error message printing
function."

The C runtime does track the absolute address of the start of the line
that the token exists on though as this is very useful for error message
printers and is just a sinlge assignment at a strategic place. Absolute
position is already tracked in all runtimes.

Jim

> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080812/3a06cc5c/attachment-0001.html 


More information about the antlr-interest mailing list