[antlr-interest] Why stream name can't be printed out when error occurs(ANTLR C)?

Jim Idle jimi at temporal-wave.com
Wed May 25 14:46:48 PDT 2011


Well you could, but I think there are some obvious problems:

1) What line number do you use?
2) If the tree node spans two files, which file do you use?
3) How many other things do we need to set up?

So, the standard thing to do is create your own error message output that
decides whether to use the token that comes before in the token stream,
the token that comes afterwards, the first child token that is not itself
virtual, and if so, then do you mean depth first or breadth first? Etc
etc? That is why I am telling you that I can't do anything generic. So, if
you need error messages in the tree parser, then you have to code it up
yourself.

Are you sure that you need virtual tokens in the tree if you need to know
where they are in relation to the real tokens? To be honest, if you are
getting errors on the tree nodes, then  just make the debugger break in
the message handler so that you have the stack trace, and then for
production mode, you just want an "Internal compiler error - please report
...."

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Petteri Räty
> Sent: Wednesday, May 25, 2011 1:08 PM
> To: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Why stream name can't be printed out when
> error occurs(ANTLR C)?
>
> On 05/25/2011 11:02 PM, Jim Idle wrote:
> > So, it is a bug in the tree grammar and you have not implemented an
> > error message handler that can help you in development. I cannot
> > create an error handler that is all things to all men - hence the
> > supplied default just tries to use lots of ways to gather
> information,
> > so you can decide what is needed for your specific case.
> >
> > Jim
> >
>
> But is there something preventing virtual tokens from associating to
> input so that the default just works? If not I could look at creating a
> patch to make it work.
>
> Regards,
> Petteri
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address


More information about the antlr-interest mailing list