[antlr-interest] ANTLR 3.0.1: invalid character column in a mismatch character error message.
Gavin Lambert
antlr at mirality.co.nz
Thu Aug 14 14:43:29 PDT 2008
At 13:05 14/08/2008, Kay Röpke wrote:
>I don't get tired maintaining that handling all this should
>be in user code, not in the default generated code.
>It's not hard to add, not everyone needs it, and in the face of
>syntax errors speed is not the primary concern anymore - so
>it's not a huge problem going back and doing the extra bit of
>computation to format an error message.
You're right, it's not hard to do -- provided
you're still in the lexer. Once you get out of
the lexer though it could be trickier, depending
on where you're getting your character stream
from (it might no longer be accessible).
But my main point in trying to get it as a
standard implementation is that the default error
messages are currently suffering from it, and
implementing it "properly" should help to avoid
some newbie-confusion. Why force everyone to go
look up how to add this sort of functionality to
their code when almost *everyone* is going to
need it at least once?
>Another thing: How often do your recognizers communicate with
>other tools via text messages? (i.e. via printing line/col info
>so that the other tool has to parse your output)
>Mine most often are compiled into the application that needs a
>parser, and thus I'm primarily interested in
the actual character
>index into the text buffer, not the column it is displayed in.
>Might just be me, but I guess not many people
are writing command
>line tools that get invoked and need to
communicate line/col info
>that way.
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* :)
>P.S.: Did anyone else notice that in the time we've discussing
>this, everyone of us could've written the code and supplied to
>interested parties? ;)
Yes :) And I'd be happy to do just that, if I
could be assured that it would end up as a
standard part of the runtime. I *really* don't
think it should be a separate addon.
More information about the antlr-interest
mailing list