From 4f2938e595e292392c6c7d736466de02c364b4af Mon Sep 17 00:00:00 2001 From: HOS Date: Tue, 7 Oct 2025 09:33:53 +0200 Subject: [PATCH 1/3] Make the grammar more consistent, and explain rewrite based on feedback. --- chapters/syntax.tex | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/chapters/syntax.tex b/chapters/syntax.tex index e6d5be079..f62a802cb 100644 --- a/chapters/syntax.tex +++ b/chapters/syntax.tex @@ -258,7 +258,7 @@ \subsection{Modification}\label{modification} \subsection{Equations}\label{equations1} - +See below for how to rewrite two rules for recursive descent parsers. \begin{lstlisting}[language=grammar] equation-section : [ initial ] equation { some-equation ";" } @@ -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 @@ -289,6 +292,10 @@ \subsection{Equations}\label{equations1} ) description +statement-or-procedure : + component-reference ":=" expression function-call-args + | component-reference function-call-args + if-equation : if expression then { some-equation ";" } @@ -351,6 +358,16 @@ \subsection{Equations}\label{equations1} connect-equation : connect "(" component-reference "," component-reference ")" \end{lstlisting} +The given constructs equation-or-procedure and statement-or-procedure are not suitable for recursive descent parsers. + +A work-around is to use the following syntax with semantic checks to ensure that only the grammar above is accepted. +\begin{lstlisting}[language=grammar] +equation-or-procedure : + simple-expression ( "=" expression | function-call-args ) + +statement-or-procedure : + component-reference ( ":=" expression | function-call-args ) +\end{lstlisting} \subsection{Expressions}\label{expressions1} From bbb5e88eb23627fed0dc6198a8323eb71ddec824 Mon Sep 17 00:00:00 2001 From: HOS Date: Tue, 7 Oct 2025 09:45:48 +0200 Subject: [PATCH 2/3] Nonnormative --- chapters/syntax.tex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/chapters/syntax.tex b/chapters/syntax.tex index f62a802cb..8e761c9ba 100644 --- a/chapters/syntax.tex +++ b/chapters/syntax.tex @@ -358,6 +358,7 @@ \subsection{Equations}\label{equations1} connect-equation : connect "(" component-reference "," component-reference ")" \end{lstlisting} +\begin{nonnormative} The given constructs equation-or-procedure and statement-or-procedure are not suitable for recursive descent parsers. A work-around is to use the following syntax with semantic checks to ensure that only the grammar above is accepted. @@ -368,6 +369,7 @@ \subsection{Equations}\label{equations1} statement-or-procedure : component-reference ( ":=" expression | function-call-args ) \end{lstlisting} +\end{nonnormative} \subsection{Expressions}\label{expressions1} From 7499e04d20ffa401e7d66a0ffdba2d5f574fa5db Mon Sep 17 00:00:00 2001 From: HOS Date: Tue, 7 Oct 2025 09:46:30 +0200 Subject: [PATCH 3/3] AddWS --- chapters/syntax.tex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/chapters/syntax.tex b/chapters/syntax.tex index 8e761c9ba..a3a320363 100644 --- a/chapters/syntax.tex +++ b/chapters/syntax.tex @@ -358,10 +358,12 @@ \subsection{Equations}\label{equations1} connect-equation : connect "(" component-reference "," component-reference ")" \end{lstlisting} + \begin{nonnormative} The given constructs equation-or-procedure and statement-or-procedure are not suitable for recursive descent parsers. A work-around is to use the following syntax with semantic checks to ensure that only the grammar above is accepted. + \begin{lstlisting}[language=grammar] equation-or-procedure : simple-expression ( "=" expression | function-call-args )