[antlr-interest] Manual tree construction in 2.7.6 (buggy?)

F Reig fermin.reig at gmail.com
Mon Mar 27 14:27:55 PST 2006


Hi,

I'm using 2.7.6, generating C#, and I'm seeing something that looks like a bug.

In my source language, I can write

:DEFAULT x, 1;

and I want to translate that during parsing to:

:DEFAULT (:IF x == NIL; x := 1; :ENDIF;)

I construct the tree by hand like this:

decl_default!
    : d:DEFAULT i:IDENT COMMA e:exp SEMI

       {## = #(#d, #([IF,":IF"],
                     #([EQ_EQ,"=="],#i,#([NIL,"NIL"])),
                     #([STMTS,"STMTS"],
                           #([EXPR,"EXPR"], #([BECOMES,"BECOMES"],#i,#e))
                      )
                    )
              );
       }
    ;

When I dump the tree (or visualize it with antlr.astframe) I see this:

( :DEFAULT ( :IF ( == x NIL 1) ( STMTS ( EXPR ( BECOMES x NIL 1 )))))

That is, there is a spurious "1" in the test, and a spurious "NIL" in
the assignment. Yet, the tree constructor looks OK to me. Am I doing
something wrong, or is there a bug somewhere?

Thanks
Fermin


More information about the antlr-interest mailing list