Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
8 changes: 5 additions & 3 deletions chapters/statements.tex
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ \section{Statements}\label{statements}
\begin{lstlisting}[language=grammar]
statement :
( component-reference ( ":=" expression | function-call-args )
| der "(" component-reference ")" ":=" expression
| "(" output-expression-list ")" ":="
component-reference function-call-args
Copy link
Collaborator

@henrikt-ma henrikt-ma Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align with how it is written in the grammar, or take the opportunity to replace outdated duplicated grammar with cross reference to \cref{equations1}.

More generally, I would actually be in favor of making each production rule in syntax.tex its own listing, with a systematic way of creating a cross reference to a specific production rule with something like \cref{production:statement}. With precise cross references like that, the need to duplicate the production in other places of the document is more or less eliminated.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the simple reference; a more precise cross-referencing would be good, but I think that should be a separate PR and prioritized.

| break
Expand All @@ -106,11 +107,12 @@ \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
( component-reference | der "(" component-reference ")" ) ":=" expression
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without "repeating" the grammar:

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 restriction that \lstinline!der! is not allowed inside \lstinline!function! classes also applies to assignments.)
The right-hand side of the \lstinline!:=! is evaluated, and the resulting value is stored into the left-hand side variable or derivative.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied that without the middle-line, and some update of the next paragraph (that already contained the restriction on derivatives.)

\end{lstlisting}

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 +121,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
1 change: 1 addition & 0 deletions chapters/syntax.tex
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ \subsection{Equations}\label{equations1}
statement-or-procedure :
component-reference ":=" expression
| component-reference function-call-args
| der "(" component-reference ")" ":=" expression

if-equation :
if expression then
Expand Down