-
Notifications
You must be signed in to change notification settings - Fork 44
Make the grammar more consistent, and explain rewrite based on feedback. #3757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
We could also add: |
\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 ) | ||
|
||
statement-or-procedure : | ||
component-reference ( ":=" expression | function-call-args ) | ||
\end{lstlisting} | ||
\end{nonnormative} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I must say that I am actually sceptic about the idea of this non-normative section altogether. I generally don't expect Modelica parsers to be implemented exactly as presented in this chapter, as other formulations are better suited for more user-friendly parsing error messages.
I would expect that those working with recursive descent parsers will be able to figure out how to write their parsers, just like those using any other parsing technique.
I also see a risk that having these rules in the non-normative section will still add confusion to the reader who is not paying attention to the non-normative nature of these rules.
\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 ) | |
statement-or-procedure : | |
component-reference ( ":=" expression | function-call-args ) | |
\end{lstlisting} | |
\end{nonnormative} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thoughts:
- The current specification is problematic with two different ways to handle the same issue.
- There were complaints for the grammar, and I think the non-normative text would help with that. I basically see a clear benefit in making it easy for others to make a parser for the Modelica language, and giving a clear direction for it; and no real down-sides. Since the construct was used previously, it also helps with demonstrating a sense of backwards compatibility.
- There are still odd constructs in the grammar due to it being recursive-descent oriented.
Specifically the complaints was about diagnostics for the incorrect equation foo()=;
Or in summary, I don't see the problem with the non-normative section above, if people just add the productions from the non-normative text to their grammar without reading the text they will have a grammar with duplicate productions - and they should then realize the problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not against rewriting the production rules per se, but I'd like to hear exactly which ambiguity that was reported during the conference?
Co-authored-by: Henrik Tidefelt <[email protected]>
During the conference we got feedback that the grammar is ambiguous.
I understand that the problem is due to trying to make the grammar more logical - but: