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

Mark Bednarczyk voytechs at yahoo.com
Mon Jun 6 17:59:42 PDT 2005


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.


Cheers,
mark...




More information about the antlr-interest mailing list