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: [email protected] [mailto:antlr-interest- > [email protected]] On Behalf Of Christian Hoffmann > Sent: Thursday, January 07, 2010 2:04 PM > To: [email protected] > 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 List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
-- You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
