Pardon me for butting in. And I have never used the C code generator, but.....
On Wed, 2010-05-19 at 14:06 -0700, Alan Condit wrote: > which I assume, based on the comment, is generated from this rule: > line : line_number? segment+ K_NEWLINE > -> ^(STMT segment+) > | line_number? K_NEWLINE > -> > | oword_stmt > -> ^(STMT oword_stmt) > ; > > The grammar is for parsing an existing language not one of my invention, > and grammatically the newlines delineate a semantic block therefore must > be known by the parser, but empty lines are discarded and therefore > should not be in the tree. having an empty RHS of the -> rewrite operator feels well unusual. i am not sure that ANTLR permits a rule which produces no tree when output=AST is present.... Maybe try (untested): line : line_number? ( segment+ -> ^(STMT segment+) )? K_NEWLINE | oword_stmt -> ^(STMT oword_stmt) ; but i do not know what would happen when no segment is present for the above rule.... have you considered building a dummy tree node for the empty case and then your tree walker can just ignore it? not sure that i have really helped any, sorry. -jbb 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 il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.