Skip to content

Commit

Permalink
Improve operator spacing in AbsynDump (#9616)
Browse files Browse the repository at this point in the history
Fixes #9611
  • Loading branch information
perost committed Oct 28, 2022
1 parent 4a4cbe3 commit be1f2bf
Show file tree
Hide file tree
Showing 37 changed files with 846 additions and 847 deletions.
34 changes: 17 additions & 17 deletions OMCompiler/Compiler/Template/AbsynDumpTpl.tpl
Expand Up @@ -777,7 +777,7 @@ match exp
let lhs_str = dumpOperand(exp1, e, true)
let rhs_str = dumpOperand(exp2, e, false)
let op_str = dumpOperator(op)
'<%lhs_str%> <%op_str%> <%rhs_str%>'
'<%lhs_str%><%op_str%><%rhs_str%>'
case e as UNARY(__) then
let exp_str = dumpOperand(exp, e, false)
let op_str = dumpOperator(op)
Expand All @@ -786,7 +786,7 @@ match exp
let lhs_str = dumpOperand(exp1, e, true)
let rhs_str = dumpOperand(exp2, e, false)
let op_str = dumpOperator(op)
'<%lhs_str%> <%op_str%> <%rhs_str%>'
'<%lhs_str%><%op_str%><%rhs_str%>'
case e as LUNARY(__) then
let exp_str = dumpOperand(exp, e, false)
let op_str = dumpOperator(op)
Expand All @@ -795,7 +795,7 @@ match exp
let lhs_str = dumpOperand(exp1, e, true)
let rhs_str = dumpOperand(exp2, e, false)
let op_str = dumpOperator(op)
'<%lhs_str%> <%op_str%> <%rhs_str%>'
'<%lhs_str%><%op_str%><%rhs_str%>'
case IFEXP(__) then dumpIfExp(exp)
case CALL(function_=Absyn.CREF_IDENT(name="$array")) then
let args_str = dumpFunctionArgs(functionArgs)
Expand Down Expand Up @@ -1004,29 +1004,29 @@ end dumpMatchCase;
template dumpOperator(Absyn.Operator op)
::=
match op
case ADD(__) then '+'
case SUB(__) then '-'
case ADD(__) then ' + '
case SUB(__) then ' - '
case MUL(__) then '*'
case DIV(__) then '/'
case POW(__) then '^'
case UPLUS(__) then '+'
case UMINUS(__) then '-'
case ADD_EW(__) then '.+'
case SUB_EW(__) then '.-'
case ADD_EW(__) then ' .+ '
case SUB_EW(__) then ' .- '
case MUL_EW(__) then '.*'
case DIV_EW(__) then './'
case POW_EW(__) then '.^'
case UPLUS_EW(__) then '.+'
case UMINUS_EW(__) then '.-'
case AND(__) then 'and'
case OR(__) then 'or'
case UPLUS_EW(__) then ' .+ '
case UMINUS_EW(__) then ' .- '
case AND(__) then ' and '
case OR(__) then ' or '
case NOT(__) then 'not'
case LESS(__) then '<'
case LESSEQ(__) then '<='
case GREATER(__) then '>'
case GREATEREQ(__) then '>='
case EQUAL(__) then '=='
case NEQUAL(__) then '<>'
case LESS(__) then ' < '
case LESSEQ(__) then ' <= '
case GREATER(__) then ' > '
case GREATEREQ(__) then ' >= '
case EQUAL(__) then ' == '
case NEQUAL(__) then ' <> '
end dumpOperator;

template dumpCref(Absyn.ComponentRef cref)
Expand Down
Expand Up @@ -32,7 +32,7 @@ end EqualityEquations;

// Result:
// Error processing file: EqualityEquations.mo
// [flattening/modelica/equations/EqualityEquations.mo:30:3-30:33:writable] Error: Tuple assignment only allowed for tuple of component references in lhs (in (x + 1, 3.0, z / y) = f(1.0, 2.0);).
// [flattening/modelica/equations/EqualityEquations.mo:30:3-30:33:writable] Error: Tuple assignment only allowed for tuple of component references in lhs (in (x + 1, 3.0, z/y) = f(1.0, 2.0);).
// Error: Error occurred while flattening model EqualityEquations
//
// # Error encountered! Exiting...
Expand Down
Expand Up @@ -26,7 +26,7 @@ end DisturbedResistance3;
// Error processing file: DisturbedResistance3.mo
// [flattening/modelica/modification/DisturbedResistance3.mo:21:3-21:31:writable] Notification: From here:
// [flattening/modelica/modification/DisturbedResistance3.mo:15:3-15:25:writable] Error: Duplicate elements (due to inherited elements) not identical:
// first element is: Real R = 1.0 + 0.1 * sin(time)
// first element is: Real R = 1.0 + 0.1*sin(time)
// second element is: parameter .Real R = 1.0
// Error: Error occurred while flattening model DisturbedResistance3
//
Expand Down
Expand Up @@ -22,7 +22,7 @@ end DisturbedResistance4;
// Error processing file: DisturbedResistance4.mo
// [flattening/modelica/modification/DisturbedResistance4.mo:17:3-17:31:writable] Notification: From here:
// [flattening/modelica/modification/DisturbedResistance4.mo:11:3-11:31:writable] Error: Duplicate elements (due to inherited elements) not identical:
// first element is: Real R = 1.0 + 0.1 * sin(time)
// first element is: Real R = 1.0 + 0.1*sin(time)
// second element is: final parameter .Real R = 1.0
// Error: Error occurred while flattening model DisturbedResistance4
//
Expand Down
2 changes: 1 addition & 1 deletion testsuite/flattening/modelica/operators/Terminal2.mo
Expand Up @@ -14,7 +14,7 @@ equation
end Terminal2;
// Result:
// Error processing file: Terminal2.mo
// [flattening/modelica/operators/Terminal2.mo:13:2-13:18:writable] Error: Cannot resolve type of expression 2.0 * terminal(). The operands have types Real, Boolean in component <NO COMPONENT>.
// [flattening/modelica/operators/Terminal2.mo:13:2-13:18:writable] Error: Cannot resolve type of expression 2.0*terminal(). The operands have types Real, Boolean in component <NO COMPONENT>.
// Error: Error occurred while flattening model Terminal2
//
// # Error encountered! Exiting...
Expand Down
4 changes: 2 additions & 2 deletions testsuite/flattening/modelica/types/Type3.mo
Expand Up @@ -15,8 +15,8 @@ end Type3;

// Result:
// Error processing file: Type3.mo
// [flattening/modelica/types/Type3.mo:13:3-13:15:writable] Error: Subscript i / 4 of type Real is not a subtype of Integer, Boolean or enumeration.
// [flattening/modelica/types/Type3.mo:13:3-13:15:writable] Error: Variable x[i / 4] not found in scope Type3.
// [flattening/modelica/types/Type3.mo:13:3-13:15:writable] Error: Subscript i/4 of type Real is not a subtype of Integer, Boolean or enumeration.
// [flattening/modelica/types/Type3.mo:13:3-13:15:writable] Error: Variable x[i/4] not found in scope Type3.
// Error: Error occurred while flattening model Type3
//
// # Error encountered! Exiting...
Expand Down
3 changes: 1 addition & 2 deletions testsuite/openmodelica/diff/RLC.mos
Expand Up @@ -19,8 +19,7 @@ res:=diffModelicaFileListings(before,list(),OpenModelica.Scripting.DiffFormat.pl
// "within;
// partial model PartialTwoPortRLC
// equation
// R_actual = R*(M + Modelica.Units.SI.Conversions.to_degC(T_heatPort))/
// (M + Modelica.Units.SI.Conversions.to_degC(T_ref));
// R_actual = R*(M + Modelica.Units.SI.Conversions.to_degC(T_heatPort))/(M + Modelica.Units.SI.Conversions.to_degC(T_ref));
// end PartialTwoPortRLC;
// "
// ""
Expand Down
10 changes: 5 additions & 5 deletions testsuite/openmodelica/interactive-API/ListExpressions.mos
Expand Up @@ -36,11 +36,11 @@ list(M); getErrorString();
// 0 = a - b - c - d;
// 0 = a + b + c + d;
// 0 = (a - b) + (c - d);
// 0 = a / (b / c);
// 0 = a / b / c;
// 0 = a * (b * c);
// 0 = a * b * c;
// 0 = a * ((a * b) / (c * d));
// 0 = a/(b/c);
// 0 = a/b/c;
// 0 = a*(b*c);
// 0 = a*b*c;
// 0 = a*((a*b)/(c*d));
// end M;"
// ""
// endResult

0 comments on commit be1f2bf

Please sign in to comment.