[antlr-interest] Pb with tree walker

jcdur Jean-Claude.Durand at imag.fr
Thu Sep 30 11:05:28 PDT 2004


New to antlr, I am trying some examples of tree walking; I got some trouble with this
simple one which prints an AST:

imprimerArbre[int indent]:
	#( nc:.	
			{ 	for(int i=1;i<=indent*3; i++)
					cout<<' ';
				cout<<nc->getText()<<endl;
			}
			( imprimerArbre[indent+1] )*
	) 	
	;

As I hoped "toStringList" prints the true AST:

 ( Foret ( Arbre ( Structure ( 1 ( 2 3 4 ) ) ) ( Decoration ( FORME ' ' ) ( UL 'ULTXT' ) ) ( 
Decoration ( FORME 'ANLAGEKOSTEN' ) ( KSY GN ) ) ( Decoration ( FORME ' ' ) ( UL '.' ) ) ( 
Decoration ( FORME 'ANLAGEKOSTEN' ) ( SF GOV ) ) ) )

and "ImprimerArbre" only prints:

   Foret
      Arbre
         Structure
            1
               2
                  3
                  4

and not the siblings of the node Structure (ie the Decoration subtrees).  And the sibling of
3 is printed !

Thanks a lot,
Jean-Claude. 





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list