[antlr-interest] Re: AST generation

Tak-po Li takpoli at hotmail.com
Wed Feb 16 12:47:35 PST 2005



Thanks, Bryan and Derek, you show me another way (besides ^ and !) to 
construct the AST tree.  It looks we will have more control this way.

Tak


>From: Bryan Ewbank <ewbank at gmail.com>
>Reply-To: Bryan Ewbank <ewbank at gmail.com>
>To: Tak-po Li <takpoli at hotmail.com>
>Subject: Re: [antlr-interest] Re: AST generation
>Date: Tue, 15 Feb 2005 10:24:03 -0500
>
>One thing you might consider is making the AST regular, so that the
>second child of module is *always* the list_of_ports.
>
>I've used something like this (using C++):
>
>   list_of_ports
>         : (LPAREN! name_of_port (COMMA! name_of_port)* RPAREN!)?
>             { ## = #( #[LIST_OF_PORTS,"LIST_OF_PORTS"], ## ); }
>         ;
>
>This ensures that there will always be a LIST_OF_PORTS node in the
>tree, but it will have no children if there are no ports.
>
>More importantly, it also eliminates a special case from processing
>the parent node, "module", because it guarantees a specific tree shape
>and number of children for that node.
>
>On Mon, 14 Feb 2005 16:24:05 -0500, Tak-po Li <takpoli at hotmail.com> wrote:
> > list_of_ports
> >         : (LPAREN^ name_of_port (COMMA! name_of_port)* RPAREN!)?
> >         ;
> > module  : "module"^ name_of_module  list_of_ports SEMI!
> >                 (module_item)*
> >                 "endmodule"!
> >         ;
> >
> > AST tree is generated correctly.  However, one of the node is "(" which 
>is
> > generated by LPAREN^ statement.  Could I change "(" to something else in 
>AST
> > generation that I would have less problem in AST tree walk later?
> >
> > I am new to Antlr.  Could someone help?  Thanks.
> >
> >
> > Tak
> >
> >




More information about the antlr-interest mailing list