[antlr-interest] Removing unnecessary casts

Terence Parr parrt at cs.usfca.edu
Sun May 23 17:06:35 PDT 2010


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



More information about the antlr-interest mailing list