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

Kay Röpke kroepke at classdump.org
Thu Aug 14 15:59:08 PDT 2008


On Aug 15, 2008, at 12:47 AM, Gerald Rosenberg wrote:

> At 02:43 PM 8/14/2008, Gavin Lambert wrote:
>
>> Perhaps this is our fundamental point of difference then.  I've  
>> written a couple of grammars that work the way you describe, but by  
>> far the most grammars I've written are used as little standalone  
>> mini-compilers, in order to turn a DSL into code compilable by some  
>> other host language (generally one of C/C++/C#).  These tend to get  
>> integrated into the build script as just another compilation step,  
>> so the only stuff visible to the outside are the generated code  
>> files themselves and whatever error messages get printed to the  
>> console.  Hence why I really want those messages to be *right* :)
>
> But isn't that the point.  There can never be any guarantee that a  
> fixed value will be *right* -- at best just a happenstance the tab  
> expansion set in whatever editor you are using matches some  
> arbitrary value implemented by Antlr -- and no matter what value is  
> chosen it will be likely wrong for the majority of users.
>
> Could add an grammar option to define tab size -- increase the  
> likelihood of being right, but still no guarantee.  Better solution  
> is to use an Antlr-aware editor.

ANTLR's Tool messages are only part of the problem. Your point gets  
even more relevant when talking about the error message of the  
_generated_ recognizers. At best tab-expansion can be used to print  
out an annotated portion of the faulty input, but it's equally  
"wrong" (compared to the current behavior) to use it to calculate a  
column, like you point out.

I'd hate another grammar option, btw. If configurable, it should be an  
attribute of BaseRecognizer settable only by a method call. It's not  
common enough to warrant an option, I think.

cheers,
-k

-- 
Kay Röpke
http://classdump.org/








More information about the antlr-interest mailing list