[antlr-interest] Bug with tree construction

Terence Parr parrt at cs.usfca.edu
Wed Nov 16 09:54:18 PST 2005


On Nov 16, 2005, at 6:56 AM, Martin Probst wrote:

> Hi,
> I have the following code in a grammar file:
>
> varDefn:
>   kd:Kdefine_variable^ q:bindVar! (td:typeDeclaration!)?
>   { ... }
>   ( COLON_EQUALS! expr
>   | ext:Kexternal
>       { ... }
>   )

Hi Martin, I just tried this grammar:

a: A^ b! (c!)?
   {;}
   ( E! expr
   | D {;}
   )
;

and it generates correct code (nothing like what you have).  Very  
odd!  Relevant chunks:

             tmp1_AST = astFactory.create(LT(1));
             astFactory.makeASTRoot(currentAST, tmp1_AST);
             match(A);

correct.

                 match(E);
                 expr();
                 astFactory.addASTChild(currentAST, returnAST);

correct.

Hmm...using  2.7.6rc1 (2005-11-04).  Perhaps we've fixed something in  
2.7.6 but I doubt it.

Ter



More information about the antlr-interest mailing list