[antlr-interest] Minor suggestion re. Java output

Jim Idle jimi at temporal-wave.com
Sat Feb 2 13:21:57 PST 2008


A tree is not guaranteed to be any particular type or interface as the 
tree adaptor can produce anything it likes. Hence it must be an object. 
This is explained in the code etc.

Jim

> -----Original Message-----
> From: Olivier Lefevre [mailto:lefevrol at yahoo.com]
> Sent: Saturday, February 02, 2008 12:13 PM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Minor suggestion re. Java output
> 
> To make things a little nicer in client code,
> ANTLR could covariantly specialize return types
> in return classes. E.g., when you have
> 
> options {
>          output = AST;
>          ASTLabelType=CommonTree;
> }
> 
> in the grammar the xxx_return classes in the
> Parser could have a method
> 
>     public CommonTree getTree() { return tree; }
> 
> instead of
> 
>     public Object getTree() { return tree; }
> 
> That way we wouldn't need to cast. Since one
> goal of ANTLR is to emit code that doesn't look
> too wildly different from what one might have
> written by hand I think it makes sense to try
> to make the code more idiomatic.
> 
> Regards,
> 
> -- O.L.
> 




More information about the antlr-interest mailing list