[antlr-interest] Minor suggestion re. Java output

Jim Idle jimi at temporal-wave.com
Mon Feb 4 20:35:02 PST 2008



> -----Original Message-----
> From: Olivier Lefevre [mailto:lefevrol at yahoo.com]
> Sent: Monday, February 04, 2008 4:29 PM
> To: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Minor suggestion re. Java output
> 
> Jim Idle wrote:
> > 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.
> 
> In that case what is the purpose of
> 
> options {
>          output = AST;
>          ASTLabelType=CommonTree;
> }
> 
> -- O.L.

Errr... to tell the code generator what to cast the output to from 
'object', which was what the original discussion was about! Your point 
might have been better phrased without the output=AST, which is 
superfluous to your question don't you think?

Ironically, ASTLabelType is not required in the C target, which is the 
least object oriented target for obvious reasons. These reasons may 
actually indicate that requiring a certain base level interface is 
reasonable, but what Ter has implemented has the maximum adaptability 
for the smallish price of having to cast; he doesn't want to assume the 
very latest language constructs, where such things might reasonably be 
avoided. I think that most people would have to agree that this is the 
gestalt that a programming tool should adopt.

A few things to bear in mind:

 - Remember that the Java code target is 1.4;
 - The code is put together by the string template hence it is a view 
and cannot know anything about the model;
 - All the elements of the output can be derived from, hence these 
questions are about being lazy. I am all for development tools allowing 
one to be lazy, but only as lazy as possible. There is a bigger view to 
consider here;

Your post here smacks a little of 'trying to catch someone out'. I only 
post here to try to help people, so I don't see the point of your 
innuendo. I don't know everything about every aspect of ANTLR, but I am 
versed in a lot of the reasons that things are the way they are and 
could give more technical explanations if warranted. Additionally, I 
don't try to defend a position that ANTLR currently occupies just 
because Ter did it that way and I happen to like the bloke. I am 
perfectly happy to call for improvements, but why term your question 
like that? I would not do you the discourtesy of saying that you dont 
know what you are talking about, even though you don't seem to have all 
the information.

The advantage of just a few people authoring a tool is that it tends to 
be good quality and consistent, the disadvantage is a limited bandwidth. 


Jim



More information about the antlr-interest mailing list