[antlr-interest] RE: newbie: how to use parse rule and nested curly

Bryan Ewbank ewbank at gmail.com
Tue Jun 14 05:09:28 PDT 2005


You add any extra nodes required in the tree in your actions.  For
example, to add a parent node "DUMMY" to your grammar, do this:

    startRule :
         ( acl | log | opt | WORDSTRING^ )*
         {
             // push everything down one level.
             ## = #( #[DUMMY,"DUMMY"], ## );
         }
    ;

This will take everything consumed and place it under one "dummy" root
node; I use this (at least) at the top level to ensure that I'm
passing around a tree rather than a list.

On 6/14/05, Ramon V. del Rosario <wincrt at yahoo.com> wrote:
> just 1 more problem how do we create dummy root? right
> now i'm adding a dummy token to the config file for it to work.
> 
> startRule :
>         document : DROOT^ (acl | log | opt | WORDSTRING^)*
> ;


More information about the antlr-interest mailing list