Loading ...
Sorry, an error occurred while loading the content.

Pb with tree walker

Expand Messages
  • jcdur
    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:. {
    Message 1 of 1 , Sep 30, 2004
    • 0 Attachment
      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.
    Your message has been successfully submitted and would be delivered to recipients shortly.