[antlr-interest] @rulecatch overriding @after [C target]

Jim Idle jimi at temporal-wave.com
Sat Aug 18 07:26:07 PDT 2007


Not so much intentional as that there are no exceptions as such so I
have not really addressed this. Probably something to look in to as I
thought it would just work at some point. Maybe moving things around
recently in the rule generation template has broken this.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Matt Barringer
> Sent: Friday, August 17, 2007 4:30 PM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] @rulecatch overriding @after [C target]
> 
> Hello,
> 
> It seems that @rulecatch causes @after to be ignored when using the C
> target in ANTLR 3.0.1.  For example, with a grammar that does not have
> an
> @rulecatch block like:
> 
> exampleRule
> 	@after {
> 		/* Stuff goes here */
> 	}
> 	: TOKEN
> 	;
> 
> The code generated will be:
> 
>     if (HASEXCEPTION())
>     {
>         PREPORTERROR();
>         PRECOVER();
>     }
>     else
>     {
>         {
> 		/* Stuff goes here */
>         }
>     }
> 
> 
> But when using a grammar *with* @rulecatch like:
> 
> @rulecatch {
> 	if (HASEXCEPTION())
> 	{
> 		/* Catch exceptions here */
> 	}
> }
> 
> exampleRule
> 	@after {
> 		/* Stuff goes here */
> 	}
> 	: TOKEN
> 	;
> 
> the generated code will be simply be:
> 
>         if (HASEXCEPTION())
>         {
>                 /* Catch exceptions here */
>         }
> 
> 
> Is that intentional?  I haven't tried any of the other output targets
> to
> see what their behaviour is.
> 
> Thanks,
> Matt


More information about the antlr-interest mailing list