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

Jim Idle jimi at temporal-wave.com
Wed Aug 13 09:22:51 PDT 2008


On Wed, 2008-08-13 at 20:26 +1200, Gavin Lambert wrote:


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

You have to add this information for each token, so you are increasing
the memory usage for everyone in the vague hope that the information,
which can be calculated anyway, is useful in certain situations. If
there are things that cannot be easily calculated, I would be all for
adding them.

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


Because there is no way to know what the tabs mean. We went through all
of this in v2 - sometimes the user has to do it themselves to get it
accurate.

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

It's not a difficult piece of code to write, but any generic
implementation just won't be useful enough I think. I might put
something in the C runtime, but if one cannot code this in a few
minutes, then it is unlikely one would have got that far ;-)

Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080813/ae5e1e10/attachment.html 


More information about the antlr-interest mailing list