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

Jim Idle jimi at temporal-wave.com
Mon Aug 11 10:10:03 PDT 2008


On Sun, 2008-08-10 at 22:33 +0200, Francis ANDRE wrote:

> >> column (charPositionInLine). does that sound helpful?
> Yes, indeed... but my request was more a change request to ANTLR than a 
> user fix..
> 
>  >> off the top of my head, i know two languages that start counting at 
> 1: pascal and lua. since i've forced myself to forget all the cobol i 
> ever knew, i simply accept that cobol is among those.
> 
> This has little to do with language or array definition and 
> references... It is more related to literature in general. In books, 
> there is no page 0, no line 0 and no column 0....  All coordinates are 
> (1,1) based..and when producing a listing reporting errors, it should 
> use also (1,1) coordinate for the common sense....
> 
> By the way... I think there is overusage of (0,0) based coordinate in 
> computer language... In effect, array indices should always start at 1. 
> It is an implementor's problem to adjust the indice by -1 to get an 
> indexes... because the first element of a vector is located at the 
> address 0... So to avoid this adjustment, computer language's designer 
> choose the easiest way for them (which is IMHO a bad side side effect 
> between the langage definitionand its implementation)!
> 
> So, IMHO, Pascal, Cobol, LUA, Algol, PL/1 are all using the right 
> indices way...


Suffice it to say that there is lots of literature on this and despite a
few dissenting voices, there are many reasons to use 0. Humans don't
necessarily do so because we are not taught to do that, though we
probably should be. A good article on why, by someone well
respected ;-), is here:

http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html

However, 2 minutes of overriding the reporting function (which is really
only for grammar developers doing debugging anyway), and you can make it
be 10 based if you like ;-)

Jim

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


More information about the antlr-interest mailing list