[antlr-interest] ANTLR 3.0.1: invalid character column in a mismatch character error message.
Francis ANDRE
francis.andre.kampbell at orange.fr
Sun Aug 10 13:33:25 PDT 2008
>> 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...
>
> Hi!
>
> On Aug 10, 2008, at 9:14 PM, Francis ANDRE wrote:
>
>> This is incoherent.... The reported erroneous line starts at 1
>> while column starts at 0!!
>
> well. call it convention.
>
>> BTW, the common user (the one not scientist but simply middle average
>> Cobol programmer) start each column at 1. So how can this could be
>> changed??
>
>
> 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.
> changing it: you can override the error reporting methods in your
> generated parser and simply add 1 to the column (charPositionInLine).
> does that sound helpful?
>
> cheers,
> -k
More information about the antlr-interest
mailing list