[antlr-interest] Re: AST generation

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


Hi Loring,

Thanks for your help.

1. I try the following:

list_of_ports
         : (a:LPAREN^ name_of_port (COMMA! name_of_port)* RPAREN!)?
                    {a.setText("list_of_ports")}
         ;

Am I correct?  It seems it is not working for me.

2. As the usage of setType(), where can I find it is being defined?  Are all 
bits for external usage or some bits are reserved for (Antlr) internal 
usage?  Should I use getType() to get information back?  Could you point me 
to some examples?

Thanks again

Tak




>From: Loring Craymer <Loring.G.Craymer at jpl.nasa.gov>
>To: Tak-po Li <takpoli at hotmail.com>, antlr-interest at antlr.org
>Subject: Re: [antlr-interest] Re: AST generation
>Date: Mon, 14 Feb 2005 14:57:10 -0800
>
>You can setType() and setText() on any node.  That's usually the easy 
>solution.
>
>--Loring
>
>
>At 01:24 PM 2/14/2005, Tak-po Li wrote:
>
>
>>An example of module in Verilog looks as following:
>>
>>Module (A, B, C);
>>     .
>>     .
>>     .
>>endmodule;
>>
>>
>>I am using the following to generate the AST tree for the above:
>>
>>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