I have recently been implementing a Modelica parser and ran into an issue with the grammar as a result of the definition of statement within the grammar. The rule is defined as:
statement :
( component-reference ( ":=" expression | function-call-args )
| "(" output-expression-list ")" ":="
component-reference function-call-args
| break
| return
| if-statement
| for-statement
| while-statement
| when-statement
)
description
However, this then causes parsing to fail on statements such as:
der(a) := expression;
This is because component-reference does not allow der(a) on the left hand side of the assignment.
The problem can be fixed by replacing component-reference with result-reference in the statement definition. result-reference is defined within the grammar but does not appear in any of the rules and hence it is never used within the grammar.
I have recently been implementing a Modelica parser and ran into an issue with the grammar as a result of the definition of
statementwithin the grammar. The rule is defined as:However, this then causes parsing to fail on statements such as:
der(a) := expression;This is because
component-referencedoes not allowder(a)on the left hand side of the assignment.The problem can be fixed by replacing
component-referencewithresult-referencein the statement definition.result-referenceis defined within the grammar but does not appear in any of the rules and hence it is never used within the grammar.