[antlr-interest] Removing unnecessary casts

Terence Parr parrt at cs.usfca.edu
Sun May 23 17:29:52 PDT 2010


yup. set option ASTLabelType
Ter
On May 23, 2010, at 5:25 PM, Andreas Stefik wrote:

> The only option I have set is:
> 
> options {
> 	output=AST;
> }
> 
>> From your question, I'm assuming I'm doing something wrong here?
> 
> Stefik
> 
> 
> On Sun, May 23, 2010 at 7:06 PM, Terence Parr <parrt at cs.usfca.edu> wrote:
>> have you set ASTLabelType?
>> Ter
>> On May 23, 2010, at 1:21 PM, Andreas Stefik wrote:
>> 
>>> Hi folks,
>>> 
>>> I'm going through my compiler finally removing some warnings and other
>>> minor issues, as we bug fix and generally get ready for release. I was
>>> wondering, when ANTLR generates code (Java target), it generates a
>>> great of things "like" the following:
>>> 
>>> Object IF50_tree=null;
>>> 
>>> IF50_tree = (Object)adaptor.create(IF50);
>>> 
>>> 
>>> Now, since IF50_tree is defined as an object, the second statement's
>>> cast to type Object is redundant, which then throws a warning in the
>>> compiler output. Is there any way to turn off the duplicate cast,
>>> thereby making ANTLR generate, instead of the above, the following:
>>> 
>>> IF50_tree = adaptor.create(IF50);
>>> 
>>> This would remove the warnings. It's not a big deal, but since ANTLR
>>> generates approximately 100 of these warnings (all caused by the same
>>> issue), it sometimes gets in the way me digging through and finding
>>> real problems.
>>> 
>>> Thoughts?
>>> 
>>> Stefik
>>> 
>>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>> 
>> 
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>> 



More information about the antlr-interest mailing list