Skip to content

Commit

Permalink
More compact contents of operator precedence table
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikt-ma committed Feb 16, 2022
1 parent 6cf9648 commit b9b64f0
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions chapters/operatorsandexpressions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ \section{Operator Precedence and Associativity}\label{operator-precedence-and-as
Operator precedence determines the order of evaluation of operators in an expression.
An operator with higher precedence is evaluated before an operator with lower precedence in the same expression.

The following table presents all the expression operators in order of precedence.
The following table presents the precedence and associativity of all the expression operators, consistent with and complementing information that can be derived from the Modelica grammar in \cref{modelica-concrete-syntax}.
\begin{table}[H]
\caption{%
Operators in order of precedence from highest to lowest, as derived from the Modelica grammar in \cref{modelica-concrete-syntax}.
Operators in order of precedence from highest to lowest.
All operators are binary except the postfix operators and those shown as unary together with \emph{expr}, the conditional operator, the array construction operator
% Beware that the array construction operator, normally expressed as \lstinline!{ }! needs escaped braces inside \caption.
% This isn't handled correctly by LaTeXML, as reported here:
Expand All @@ -47,24 +47,24 @@ \section{Operator Precedence and Associativity}\label{operator-precedence-and-as
\tablehead{Operator group} & \tablehead{Operator syntax} & \tablehead{Examples}\\
\hline
\hline
Postfix array index operator & \lstinline![]! & \lstinline!arr[index]!\\
Postfix array index & \lstinline![]! & \lstinline!arr[index]!\\
\hline
Postfix access operator & \lstinline!.! & \lstinline!a.b!\\
Postfix access & \lstinline!.! & \lstinline!a.b!\\
\hline
Postfix function call & \lstinline!$\mathit{funcName}$($\mathit{functionArguments}$)! & \lstinline!sin(4.36)!\\
Postfix function call & \lstinline!$\mathit{funcName}$($\mathit{args}$)! & \lstinline!sin(4.36)!\\
\hline
Array construction & \lstinline!{$\mathit{expressions}$}! & \lstinline!{2, 3}!\\
Horizontal concatenation & \lstinline![$\mathit{expressions}$]! & \lstinline![5, 6]!\\
Vertical concatenation & \lstinline![$\mathit{expressions}$; $\mathit{expressions}\ldots$]! & \lstinline![2, 3; 7, 8]!\\
Array construction & \lstinline!{$\mathit{exprs}$}! & \lstinline!{2, 3}!\\
Horizontal concatenation & \lstinline![$\mathit{exprs}$]! & \lstinline![5, 6]!\\
Vertical concatenation & \lstinline![$\mathit{exprs}$; $\mathit{exprs}\ldots$]! & \lstinline![2, 3; 7, 8]!\\
\hline
Exponentiation & \ \lstinline!^! & \lstinline!2 ^ 3!\\
\hline
Multiplicative & \lstinline!* /! & \lstinline!2 * 3!, \lstinline!2 / 3!\\
Elementwise multiplicative & \lstinline!.* ./! & \lstinline![1, 2; 3, 4] .* [2, 3; 5, 6]!\\
Elementwise multiplicative & \lstinline!.* ./! & \lstinline!{1, 2, 3} .* {2, 3, 5}!\\
\hline
Additive & \lstinline!+ -! & \lstinline!1 + 2!\\
Additive unary & \lstinline!+$\mathit{expr}$ -$\mathit{expr}$! & \lstinline!-0.5!\\
Array elementwise additive & \lstinline!.+ .-! & \lstinline![1, 2; 3, 4] .+ [2, 3; 5, 6]!\\
Elementwise additive & \lstinline!.+ .-! & \lstinline!{1, 2, 3} .+ {2, 3, 5}!\\
\hline
Relational & \lstinline!< <= > >= == <>! & \lstinline!a < b!, \lstinline!a <= b!, \lstinline!a > b!, \ldots\\
\hline
Expand Down

0 comments on commit b9b64f0

Please sign in to comment.