Skip to content

Commit

Permalink
Add non-normative paragraph about pretty-printing
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikt-ma committed Feb 16, 2022
1 parent 2e6d432 commit a1822fa
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions chapters/operatorsandexpressions.tex
Expand Up @@ -121,6 +121,14 @@ \section{Operator Precedence and Associativity}\label{operator-precedence-and-as
\end{lstlisting}
\end{nonnormative}

\begin{nonnormative}
The operator precedence table is useful when generating textual representations of Modelica expression trees.
When doing this, attention must be paid to the rule that the unary additive operators are only allowed for the first term in a sum.
A naive implementation might not produce all the required parentheses for an expression tree such as \lstinline!1 + (-1)!, as it might think that the higher precedence of the unary operator makes the parentheses redundant.
A trick that solves this problem is to instead treat the additive unary operators as left associative with the same precedence as the binary additive operators.
\end{nonnormative}


\section{Evaluation Order}\label{evaluation-order}

A tool is free to solve equations, reorder expressions and to not evaluate expressions if their values do not influence the result (e.g.\ short-circuit evaluation of \lstinline!Boolean! expressions).
Expand Down

0 comments on commit a1822fa

Please sign in to comment.