[antlr-interest] @rulecatch in a C environment

Pierre Attar pat at tireme.fr
Tue Apr 8 06:14:04 PDT 2008


Hi,

I want to catch recognition errors on my parsing. In order to achieve 
this, I've creating the following rulecatch:

@rulecatch {
    pANTLR3_EXCEPTION exe = EXCEPTION;
    if(NULL != exe) {
        char    buffer[100];
        sprintf(buffer, "\%s", exe->name);
        cout << "Got an exception in parsing recognition: " << buffer;;
    }
}

This works fine except that when nothing is provided, the generation is :
    if (HASEXCEPTION())
    {PREPORTERROR();
        PRECOVER(); }
    else
    {{resultTree= doc;}}

... where the line is an @after clause.


My problem ? As soon as I put my rulecatcher, the after clause is no 
more generated.

I would be very glad to understand what I've done wrong here and also, 
if someone have a sample I may clone, it would help me.

Thanks a lot, Pierre






More information about the antlr-interest mailing list