[antlr-interest] ANTLRWorks 2 (for ANTLR v4)

Wujek Srujek wujek.srujek at googlemail.com
Mon Sep 12 08:41:05 PDT 2011


Hi.
I think the @rulecatch has to be specified per rule, which makes it at least
cumbersome for pretty much all grammars. Please correct me if I am wrong.
How about the lexer?
Do you mean failing on first error is useless? I think it is not - for
example, we have a simple DSL for path evaluation (something like GPath from
groovy) and we translate short path expressoins it to some other
representation that is then evaluated by unified EL with our custom
resolvers (no, the native EL syntax was not what was needed, hence we
translate). I don't want any recovery here, with some artificial tokens
inserted for me - I want the whole path to fail. As I was not the only one
who searched for an answer (the ANTLR site has a dedicated site for it) I
guess it is not so uncommon.
I agree that recovery is nice in some cases, but not in all of them.

Thank you for your answer.

wujek


On Mon, Sep 12, 2011 at 5:26 PM, Sam Harwell <sharwell at pixelminegames.com>wrote:

> This is easy for a parser. Just add the following to your grammar.
>
> @rulecatch{}
>
> Aside from answering the single question "In the input recognized by this
> grammar? (yes/no)", this is a rather useless thing to do. There are many,
> many other ways to approach error handling that are more appropriate for
> any
> other task.
>
> Sam
>
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org
> [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Wujek Srujek
> Sent: Monday, September 12, 2011 4:18 AM
> To: antlr-interest Interest
> Subject: Re: [antlr-interest] ANTLRWorks 2 (for ANTLR v4)
>
> I am new to ANTLR3 and haven't yet got a lot of experience with it. The one
> thing that is bugging me, though, is how hard it was to make sure ANTLR
> doesn't perform any recovery and fails on first error with checked
> exceptions. And it involved a nasty trick with sneaky throwing... I would
> love to see it made easier.
>
> wujek
>
>
>


More information about the antlr-interest mailing list