Skip to content

Commit 333d9ee

Browse files
Make the grammar more consistent, and explain rewrite based on feedback. (#3757)
* Make the grammar more consistent, and explain rewrite based on feedback. * Nonnormative * AddWS * Update chapters/syntax.tex * Apply suggestions from code review Co-authored-by: Henrik Tidefelt <[email protected]>
1 parent 1c0e702 commit 333d9ee

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

chapters/syntax.tex

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,17 +267,20 @@ \subsection{Equations}\label{equations1}
267267
[ initial ] algorithm { statement ";" }
268268

269269
some-equation :
270-
( simple-expression "=" expression
270+
( equation-or-procedure
271271
| if-equation
272272
| for-equation
273273
| connect-equation
274274
| when-equation
275-
| component-reference function-call-args
276275
)
277276
description
278277

278+
equation-or-procedure :
279+
simple-expression "=" expression
280+
| component-reference function-call-args
281+
279282
statement :
280-
( component-reference ( ":=" expression | function-call-args )
283+
( statement-or-procedure
281284
| "(" output-expression-list ")" ":="
282285
component-reference function-call-args
283286
| break
@@ -289,6 +292,10 @@ \subsection{Equations}\label{equations1}
289292
)
290293
description
291294

295+
statement-or-procedure :
296+
component-reference ":=" expression
297+
| component-reference function-call-args
298+
292299
if-equation :
293300
if expression then
294301
{ some-equation ";" }
@@ -352,6 +359,11 @@ \subsection{Equations}\label{equations1}
352359
connect "(" component-reference "," component-reference ")"
353360
\end{lstlisting}
354361

362+
\begin{nonnormative}
363+
The productions \lstinline[language=grammar]!equation-or-procedure! and \lstinline[language=grammar]!statement-or-procedure! are not suitable for recursive descent parsers.
364+
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.
365+
\end{nonnormative}
366+
355367
\subsection{Expressions}\label{expressions1}
356368

357369
\begin{lstlisting}[language=grammar]

0 commit comments

Comments
 (0)