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

Kay Röpke kroepke at classdump.org
Sun Aug 10 14:39:33 PDT 2008


Hi!

On Aug 10, 2008, at 10:33 PM, 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..

I don't think it should change, because it would be an incompatible  
change, in the sense that it would directly affect user code (esp. for  
syntax highlighters etc, and of course error handling).
Since it's very easy to override, my vote would be to leave it alone.
As for the inconsistency argument, yes, it's inconsistent, but I  
frankly I don't think it makes that much of a difference.

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

In computer science the majority of systems are 0-based. Although that  
stems from a time which is long in the past, it has carried over, so  
we simply have to deal with it. At least that's my opinion.

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


I didn't know that this helpful page existed: http://en.wikipedia.org/wiki/Comparison_of_programming_languages_%28array%29#Array_system_cross-reference_list
Clearly, the languages in major use today are favoring 0-based  
indices. And since I have to switch between 0 and 1-based languages  
very often, I'd wish Lua would just do away with the 1-based approach.  
It might be more "intuitive" if you read it as "the first element of  
the array" but I always think of a[n] as the "element n places from  
the beginning", so that's "intuitive" for me. Call me rotten by C ;)

Enough babbling, however. This is an argument neither side can "win",  
simply because there's no correct answer. For the reason given above,  
I think ANTLR should not change its behavior at this point.

cheers,
-k
-- 
Kay Röpke
http://classdump.org/








More information about the antlr-interest mailing list