Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 6 additions & 22 deletions chapters/statements.tex
Original file line number Diff line number Diff line change
Expand Up @@ -86,31 +86,15 @@ \section{Statements}\label{statements}
Names in a statement shall be found by looking up in the partially flattened enclosing class of the algorithm section.
\end{itemize}

The syntax of statements is as follows:
\begin{lstlisting}[language=grammar]
statement :
( component-reference ( ":=" expression | function-call-args )
| "(" output-expression-list ")" ":="
component-reference function-call-args
| break
| return
| if-statement
| for-statement
| while-statement
| when-statement
)
description
\end{lstlisting}
The syntax of statements is given by the production \lstinline[language=grammar]!statement! in \cref{equations1}.

\subsection{Simple Assignment Statements}\label{simple-assignment-statements}

The syntax of \firstuse[assignment statement!simple]{simple assignment statement} is as follows:
\begin{lstlisting}[language=grammar]
component-reference ":=" expression
\end{lstlisting}
A \firstuse[assignment statement!simple]{simple assignment statement} is an assignment statement where the left-hand side of the \lstinline!:=! is a component reference or a derivative.
The right-hand side of the \lstinline!:=! is evaluated, and the resulting value is stored into the left-hand side variable or derivative.

The \lstinline[language=grammar]!expression! is evaluated.
The resulting value is stored into the variable denoted by \lstinline[language=grammar]!component-reference!.
The resulting value is stored into the variable denoted by \lstinline[language=grammar]!component-reference! (or as its derivative).
An assignment to a derivative may only occur in a model or block.

The \lstinline!expression! must not have higher variability than the assigned component, see \cref{variability-of-expressions}.

Expand All @@ -119,7 +103,7 @@ \subsection{Simple Assignment Statements}\label{simple-assignment-statements}
\subsubsection{Assignments from Called Functions with Multiple Results}\label{assignments-from-called-functions-with-multiple-results}

There is a special form of assignment statement that is used only when the right-hand side contains a call to a function with multiple results.
The left-hand side contains a parenthesized, comma-separated list of variables receiving the results from the function call.
The left-hand side contains a parenthesized, comma-separated list of variables (or derivatives) receiving the results from the function call.
A function with $n$ results needs $m \leq n$ receiving variables on the left-hand side, and the variables are assigned from left to right.

\begin{lstlisting}[language=modelica]
Expand Down
5 changes: 3 additions & 2 deletions chapters/syntax.tex
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,9 @@ \subsection{Equations}\label{equations1}
description

statement-or-procedure :
component-reference ":=" expression
| component-reference function-call-args
component-reference function-call-args
| component-reference ":=" expression
| der "(" component-reference ")" ":=" expression

if-equation :
if expression then
Expand Down