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

Matt Barringer mbarringer at suse.de
Fri Aug 17 16:30:06 PDT 2007


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