@@ -1907,16 +1907,16 @@ public
1907
1907
) + ")" ;
1908
1908
case END () then "end" ;
1909
1909
1910
- case MULTARY () guard(listEmpty(exp. inv_arguments)) then multaryString (exp. arguments, exp, exp. operator, false );
1910
+ case MULTARY () guard(listEmpty(exp. inv_arguments)) then multaryFlatString (exp. arguments, exp, exp. operator, false );
1911
1911
1912
1912
case MULTARY () guard(listEmpty(exp. arguments) and Operator . isDashClassification(Operator . getMathClassification(exp. operator)))
1913
- then "-" + multaryString (exp. inv_arguments, exp, exp. operator);
1913
+ then "-" + multaryFlatString (exp. inv_arguments, exp, exp. operator);
1914
1914
1915
- case MULTARY () guard(listEmpty(exp. arguments)) then "1/" + multaryString (exp. inv_arguments, exp, exp. operator);
1915
+ case MULTARY () guard(listEmpty(exp. arguments)) then "1/" + multaryFlatString (exp. inv_arguments, exp, exp. operator);
1916
1916
1917
- case MULTARY () then multaryString (exp. arguments, exp, exp. operator) +
1917
+ case MULTARY () then multaryFlatString (exp. arguments, exp, exp. operator) +
1918
1918
Operator . symbol(Operator . invert(exp. operator)) +
1919
- multaryString (exp. inv_arguments, exp, exp. operator);
1919
+ multaryFlatString (exp. inv_arguments, exp, exp. operator);
1920
1920
1921
1921
case BINARY () then operandFlatString(exp. exp1, exp, true ) +
1922
1922
Operator . symbol(exp. operator) +
@@ -2049,8 +2049,8 @@ public
2049
2049
if operand_prio > operator_prio then
2050
2050
parenthesize := true ;
2051
2051
elseif operand_prio == operator_prio then
2052
- parenthesize := if lhs then isNonAssociativeExp(operand) else not
2053
- isAssociativeExp(operand);
2052
+ parenthesize := if lhs then isNonAssociativeExp(operand)
2053
+ else not isAssociativeExp(operand);
2054
2054
end if ;
2055
2055
end if ;
2056
2056
@@ -2063,15 +2063,28 @@ public
2063
2063
input list< Expression > arguments;
2064
2064
input Expression exp;
2065
2065
input Operator operator;
2066
- input Boolean useParanthesis = true ;
2066
+ input Boolean parenthesize = true ;
2067
2067
output String str;
2068
2068
algorithm
2069
2069
str := stringDelimitList(list(operandString(e, exp, false ) for e in arguments), Operator . symbol(operator));
2070
- if useParanthesis and listLength(arguments) > 1 then
2070
+ if parenthesize and listLength(arguments) > 1 then
2071
2071
str := "(" + str + ")" ;
2072
2072
end if ;
2073
2073
end multaryString;
2074
2074
2075
+ function multaryFlatString
2076
+ input list< Expression > arguments;
2077
+ input Expression exp;
2078
+ input Operator operator;
2079
+ input Boolean parenthesize = true ;
2080
+ output String str;
2081
+ algorithm
2082
+ str := stringDelimitList(list(operandFlatString(e, exp, false ) for e in arguments), Operator . symbol(operator));
2083
+ if parenthesize and listLength(arguments) > 1 then
2084
+ str := "(" + str + ")" ;
2085
+ end if ;
2086
+ end multaryFlatString;
2087
+
2075
2088
function priority
2076
2089
input Expression exp;
2077
2090
input Boolean lhs;
@@ -2088,6 +2101,9 @@ public
2088
2101
case RELATION () then 6 ;
2089
2102
case RANGE () then 10 ;
2090
2103
case IF () then 11 ;
2104
+ case CAST () then priority(exp. exp, lhs);
2105
+ case BOX () then priority(exp. exp, lhs);
2106
+ case UNBOX () then priority(exp. exp, lhs);
2091
2107
else 0 ;
2092
2108
end match;
2093
2109
end priority;
@@ -6072,6 +6088,18 @@ public
6072
6088
then
6073
6089
json;
6074
6090
6091
+ case MULTARY ()
6092
+ algorithm
6093
+ json := JSON . emptyObject();
6094
+ json := JSON . addPair("$kind" , JSON . makeString("multary_op" ), json);
6095
+ json := JSON . addPair("args" ,
6096
+ JSON . makeArray(list(toJSON(a) for a in exp. arguments)), json);
6097
+ json := JSON . addPair("inv_args" ,
6098
+ JSON . makeArray(list(toJSON(a) for a in exp. inv_arguments)), json);
6099
+ json := JSON . addPair("op" , JSON . makeString(Operator . symbol(exp. operator, spacing = "" )), json);
6100
+ then
6101
+ json;
6102
+
6075
6103
case IF ()
6076
6104
algorithm
6077
6105
json := JSON . emptyObject();
0 commit comments