[antlr-interest] c-target tree creation

Jim Idle jimi at temporal-wave.com
Thu Jan 7 14:24:27 PST 2010


Actually the nil node should never be there so there must be something awry with your grammar. Try making sure that your tope rule looks like:

top : myrule EOF! ;

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Christian Hoffmann
> Sent: Thursday, January 07, 2010 2:04 PM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] c-target tree creation
> 
> Hi,
> 
> I'm stumbling over a unhappy circumstance. Normaly a tree is built
> witch a
> nil node and the children. But if the parser regognises just one line,
> the nil node is not used (probably there are no children).
> 
> Example 1 - generated tree has just one node
>   Source:
>     int a;
>   AST:
>     <TOK_VAR_DEF(99) at line 2,
>       <TOK_VAR_TYPE(100) at line 2, int(49) at line 2>,
>       <TOK_VAR_DECL(101) at line 2, a(122) at line 2>
>     >
> 
> 
> Example 2 - generated tree has two nodes
>   Source:
>     int a;
>     int b;
>   AST:
>     <nil(0) at line 2,
>       <TOK_VAR_DEF(99) at line 2,
>         <TOK_VAR_TYPE(100) at line 2, int(49) at line 2>,
>         <TOK_VAR_DECL(101) at line 2, a(122) at line 2>
>       >,
>       <TOK_VAR_DEF(99) at line 3,
>         <TOK_VAR_TYPE(100) at line 3, int(49) at line 3>,
>         <TOK_VAR_DECL(101) at line 3, b(122) at line 3>
>       >
>     >
> 
> 
> I think it would be easier for walking in a loop if the nil-node is
> always created. Is this possible in future versions?
> 
> Regards,
> Christian
> 
> --
> Christian Hoffmann
> Ützenkamp 4
> 38118 Braunschweig
> Tel: 0171/7300609
> Web: www.c-hoffmann.de
>      www.logical-arts.de
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address





More information about the antlr-interest mailing list