mirror of
https://git.code.sf.net/p/newrpl/sources
synced 2024-11-16 19:51:25 +01:00
Improved parenthesis of negative expressions.
This commit is contained in:
parent
b22c27e1e6
commit
770718f7d8
1 changed files with 19 additions and 0 deletions
19
compiler.c
19
compiler.c
|
@ -827,6 +827,16 @@ end_of_expression:
|
|||
// NO NEED FOR PARENTHESIS
|
||||
}
|
||||
else {
|
||||
// HANDLE SPECIAL CASE: ADD PARENTHESIS TO SEPARATE OPERATORS
|
||||
if(TI_TYPE(RetNum)==TITYPE_PREFIXOP) {
|
||||
if( (*(InfixOpTop-3)==INFIX_BINARYRIGHT) ||
|
||||
(*(InfixOpTop-3)==INFIX_POSTFIXARG) ||
|
||||
(*(InfixOpTop-3)==INFIX_PREFIXARG))
|
||||
rplDecompAppendChar('(');
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(TI_PRECEDENCE(*(InfixOpTop-5))<TI_PRECEDENCE(RetNum)) {
|
||||
if(TI_TYPE(*(InfixOpTop-5))!=TITYPE_FUNCTION) // DO NOT ADD PARENTHESIS TO FUNCTION ARGUMENTS!
|
||||
rplDecompAppendChar('(');
|
||||
|
@ -926,6 +936,15 @@ end_of_expression:
|
|||
// NO NEED FOR PARENTHESIS
|
||||
}
|
||||
else {
|
||||
// HANDLE SPECIAL CASE: ADD PARENTHESIS TO SEPARATE OPERATORS
|
||||
if(infixmode==INFIX_PREFIXARG) {
|
||||
if( (*(InfixOpTop-3)==INFIX_BINARYRIGHT) ||
|
||||
(*(InfixOpTop-3)==INFIX_POSTFIXARG) ||
|
||||
(*(InfixOpTop-3)==INFIX_PREFIXARG))
|
||||
rplDecompAppendChar(')');
|
||||
}
|
||||
|
||||
|
||||
if(TI_PRECEDENCE(*(InfixOpTop-5))<TI_PRECEDENCE(*(InfixOpTop-1))) {
|
||||
if(TI_TYPE(*(InfixOpTop-5))!=TITYPE_FUNCTION) // DON'T ADD PARENTHESIS TO FUNCTION ARGUMENTS
|
||||
rplDecompAppendChar(')');
|
||||
|
|
Loading…
Reference in a new issue