[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fix for wrong precedence order
dava generates wrong Java code (ommiting parentheses) for expressions
that containtwo operations with same precedence such as 2 * (i / 2).
To fix the problem, the comparison of precedence between this and the
subexpression should be <= instead of < in method needsBracketRight().
(See attached diff.)
Haruyuki Kawabe
Haruyuki.Kawabe@unisys.co.jp
*** PrecedenceTest.java.orig Wed Sep 24 13:22:09 2003
--- PrecedenceTest.java Wed Sep 24 13:21:35 2003
***************
*** 46,52 ****
if( !(sub instanceof Precedence) ) return false;
Precedence subP = (Precedence) sub;
Precedence exprP = (Precedence) expr;
! if( subP.getPrecedence() < exprP.getPrecedence() ) return true;
if( subP.getPrecedence() == exprP.getPrecedence() ) {
if( exprP instanceof SubExpr ) return true;
if( exprP instanceof DivExpr ) return true;
--- 46,52 ----
if( !(sub instanceof Precedence) ) return false;
Precedence subP = (Precedence) sub;
Precedence exprP = (Precedence) expr;
! if( subP.getPrecedence() <= exprP.getPrecedence() ) return true;
if( subP.getPrecedence() == exprP.getPrecedence() ) {
if( exprP instanceof SubExpr ) return true;
if( exprP instanceof DivExpr ) return true;