Skip to content

Commit

Permalink
Fixed a bug with unparsing of logical binary operators. Parenthesis a…
Browse files Browse the repository at this point in the history
…re no longer lost around expressions with operators of lower precedence.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2504 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
x02danhe committed Aug 31, 2006
1 parent 6b7ede7 commit 2ede317
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Compiler/Dump.mo
Expand Up @@ -3721,6 +3721,7 @@ algorithm
end matchcontinue;
end printNamedArgStr;


protected function printRow "function: printRow
Print an Expression list to the Print buffer.
Expand All @@ -3730,11 +3731,12 @@ algorithm
printListDebug("print_row", es, printExp, ",");
end printRow;


protected function expPriority "function: expPriority

Returns a priority number for an expression.
This function is used to output parenthesis when needed. eg 3(1+2) should output 3(1+2)
and not 31+2
This function is used to output parenthesis when needed, e.g., 3(1+2) should output 3(1+2)
and not 31+2.
"
input Absyn.Exp inExp;
output Integer outInteger;
Expand Down Expand Up @@ -3773,6 +3775,7 @@ algorithm
end matchcontinue;
end expPriority;


protected function parenthesize "function: parenthesize
Adds parentheisis to a string if expression and parent expression
Expand All @@ -3788,7 +3791,7 @@ algorithm
local
Ident str_1,str;
Integer pparent,pexpr;
case (str,pparent,pexpr) /* expressuion prio parent expr prio */
case (str,pparent,pexpr) /* expr, prio. parent expr, prio. expr */
equation
(pparent > pexpr) = true;
str_1 = Util.stringAppendList({"(",str,")"});
Expand All @@ -3798,6 +3801,7 @@ algorithm
end matchcontinue;
end parenthesize;


public function printExpStr "function: print_exp
This function prints a complete expression.
Expand Down Expand Up @@ -3877,7 +3881,7 @@ algorithm
p1 = expPriority(e1);
p2 = expPriority(e2);
s1_1 = parenthesize(s1, p1, p);
s2_1 = parenthesize(s2, p1, p);
s2_1 = parenthesize(s2, p2, p);
s = stringAppend(s1_1, sym);
s_1 = stringAppend(s, s2_1);
then
Expand Down

0 comments on commit 2ede317

Please sign in to comment.