diff --git a/chapters/statements.tex b/chapters/statements.tex index 62f7e153a..469e19453 100644 --- a/chapters/statements.tex +++ b/chapters/statements.tex @@ -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}. @@ -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] diff --git a/chapters/syntax.tex b/chapters/syntax.tex index fa5414aab..b400f8fef 100644 --- a/chapters/syntax.tex +++ b/chapters/syntax.tex @@ -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