[antlr-interest] Removing unnecessary casts

Andreas Stefik stefika at gmail.com
Sun May 23 18:47:44 PDT 2010


I see. So, I changed to this:

options {
	output=AST;
	ASTLabelType = CommonTree;
}

if I just want the default Node (I don't need any special processing).
I went through the generated code and think I see what's going on.
Looks like it removed the warnings, and nothing seemed to explode in
the compiler, so I'll chalk that up to a win.

Thanks Terrence!

Stefik

On Sun, May 23, 2010 at 7:29 PM, Terence Parr <parrt at cs.usfca.edu> wrote:
> 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