[antlr-interest] Found an error with UNARY_MINUS and typecast injava.g

Mark Bednarczyk voytechs at yahoo.com
Tue Jun 7 05:09:14 PDT 2005


I will then. I first want to do some more checks and run npl.g
with inherited java.g against my existing NPL programs to see if
there are any other problems I can find and I'll submit patches
for everything at the same time, that is if I find anything
else.

Here is a link to my protocols.npl definition file:

http://tinyurl.com/7up6x

http://cvs.sourceforge.net/viewcvs.py/jnetstream/jnetstream/conf
ig/protocols.npl?rev=1.9.4.5&view=markup


Cheers,
mark...

>-----Original Message-----
>From: antlr-interest-bounces at antlr.org
>[mailto:antlr-interest-bounces at antlr.org]On Behalf Of
>Terence Parr
>Sent: Monday, June 06, 2005 9:14 PM
>To: ANTLR Interest
>Subject: Re: [antlr-interest] Found an error with
>UNARY_MINUS and
>typecast injava.g
>
>
>
>On Jun 6, 2005, at 5:59 PM, Mark Bednarczyk wrote:
>
>> I found an error in the logic of java.g when it
>comes to parsing
>> UNARY_MINUS and UNARY_PLUS after a typecast. Who do
>I report the
>> problem to?
>>
>> Here is an example:
>> -(int)2 != (int)-2;
>>
>> Generates this AST tree:
>> ( [AST ROOT,<<0>>] ( EXPR ( [!=,<NOT_EQUAL>] (
>[-,<UNARY_MINUS>]
>> ( [(,<TYPECAST] ( TYPE [int,<IDENT>] ) [2,<NUM_INT>] ) ) (
>> [-,<MINUS>] [int,<IDENT>] [2,<NUM_NT>] ) ) ) )
>>
>> You can see that on the lefthand side of the expression it
>> generates the correct tree, UNARY_MINUS, TYPECAST , IDENT and
>> the NUM_INT. Then on the right things go wrong, I get a MINUS
>> instead of UNARY_MINUS, a IDENT instead of a TYPECAST with
>> IDENT.
>>
>> I don't mind creating a patch for this and
>submitting it, as I
>> would like this problem fixed in the java.g grammar
>instead of
>> in my NPL.g file as I'm just inheriting and would like to be
>> upgradable to new versions of java.g and keep number of
>> overrides of underlying java grammar in my NPL grammar to a
>> minimum.
>
>Hi Mark,
>
>Send me the tweak to the rule and I'll update the grammar.
>
>Ter
>--
>CS Professor & Grad Director, University of San Francisco
>Creator, ANTLR Parser Generator, http://www.antlr.org
>Cofounder, http://www.jguru.com
>
>




More information about the antlr-interest mailing list