Skip to content
18 changes: 15 additions & 3 deletions chapters/syntax.tex
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,20 @@ \subsection{Equations}\label{equations1}
[ initial ] algorithm { statement ";" }

some-equation :
( simple-expression "=" expression
( equation-or-procedure
| if-equation
| for-equation
| connect-equation
| when-equation
| component-reference function-call-args
)
description

equation-or-procedure :
simple-expression "=" expression
| component-reference function-call-args

statement :
( component-reference ( ":=" expression | function-call-args )
( statement-or-procedure
| "(" output-expression-list ")" ":="
component-reference function-call-args
| break
Expand All @@ -289,6 +292,10 @@ \subsection{Equations}\label{equations1}
)
description

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

if-equation :
if expression then
{ some-equation ";" }
Expand Down Expand Up @@ -352,6 +359,11 @@ \subsection{Equations}\label{equations1}
connect "(" component-reference "," component-reference ")"
\end{lstlisting}

\begin{nonnormative}
The productions \lstinline[language=grammar]!equation-or-procedure! and \lstinline[language=grammar]!statement-or-procedure! are not suitable for recursive descent parsers.
A work-around is to left-factor them and for \lstinline[language=grammar]!equation-or-procedure! introduce semantic checks to ensure that only the grammar above is accepted.
\end{nonnormative}

\subsection{Expressions}\label{expressions1}

\begin{lstlisting}[language=grammar]
Expand Down