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

Gavin Lambert antlr at mirality.co.nz
Wed Aug 13 01:26:54 PDT 2008


[Merging thread branches a bit...]

At 09:50 13/08/2008, Terence Parr wrote:
 >> 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.
 >
 >that was how v2 worked I think...still was trouble ;)

Yeah, but v2 *only* did that.  I think v3 should still keep the 
line position (that's still useful) -- but it should have the 
column as well.  It's not that much more work and it'd be handy 
whether for the default or for custom error handlers.  (Might even 
be useful for some kinds of syntax highlighting too.)


At 10:51 13/08/2008, Jim Idle wrote:
>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."

Hardly.  One or two extra ints containing information that's 
basically already known at token generation time?  I doubt that'd 
leave a noticeable dent.  (Well, ok, I guess the stream position 
might have to be a longlong, or fpos_t, or whatever.  Still.)

And even if you do implement your own error handling function -- 
why force it to do all the work of scanning the characters on the 
line looking for and expanding tabs just to get a column number, 
when the lexer already had to pass those same tabs in order to 
generate the error in the first place?

At minimum there should be a function in the runtime you can call 
to do this for you.  I don't see why each driver program needs to 
re-invent the wheel.



More information about the antlr-interest mailing list