[antlr-interest] [bug?] @after block vs end-of-rule block (C runtime)

Jim Idle jimi at temporal-wave.com
Tue Jun 10 21:30:08 PDT 2008


On Wed, 2008-06-11 at 12:57 +0930, David Benn wrote:

> In ANTLR 3.1b1 with the C runtime, in a tree grammar I have this:
> 


You can't use @after in the C runtime, just do:

rule :
        ( X | Y |Z
        )
        {
            after code
        }

and you should get the same effect. I may decide to support @after (I
will review that tomorrow), but there are some issues to do with
exceptions and so on.

Ji

> st_def     
> scope {
>     STEntry* entry;
> }
>     :
>       (type IDENT
>       {
>           $st_def::entry = symtab->CreateSTEntry($type.text->chars,
>                 $IDENT.text->chars);
>       }
> 
>       st_spec?)
>       {
>           symtab->AddSTEntry($st_def::entry);
>       }
>     ;
> 
> which works fine. I would have thought that an @after block would also 
> work in this case
> 
> st_def     
> scope {
>     STEntry* entry;
> }
> @after {
>      symtab->AddSTEntry($st_def::entry);
> }
>     :
>       (type IDENT
>       {
>           $st_def::entry = symtab->CreateSTEntry($type.text->chars,
>                 $IDENT.text->chars);
>       }
> 
>       st_spec?)
>     ;
> 
> but it doesn't. I get a seg fault under Linux.
> 
> Is this because the st_def scope has gone away by the time the @after 
> block is called, or is this a bug in the C runtime?
> 
> Thanks.
> 
> Regards,
> 
> David
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080610/10b37f8e/attachment.html 


More information about the antlr-interest mailing list