Skip to content

Incorrect definition of statement within the Modelica grammar #3764

@mdempse1

Description

@mdempse1

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions