Skip to content
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

OMTypedParser does not understand variable length arrays #138

Open
ericchapman opened this issue Jun 7, 2021 · 0 comments · May be fixed by #147
Open

OMTypedParser does not understand variable length arrays #138

ericchapman opened this issue Jun 7, 2021 · 0 comments · May be fixed by #147

Comments

@ericchapman
Copy link

ericchapman commented Jun 7, 2021

I am using OMPython version 3.3.0, Python version 3.8. When calling "getComponents", the OMTypedParser breaks if a parameter has a variable length array. See below

test.py

from OMPython import OMCSessionZMQ


if __name__ == "__main__":
    model = """
    model Test
      parameter Real TEST[:,2] = [0,1;100,2];
    end Test;
    """

    omc = OMCSessionZMQ()
    omc.sendExpression("loadString(\"{}\")".format(model))

    # Breaks
    print(omc.sendExpression("getComponents(Test)"))

Error:

Traceback (most recent call last):
  File ".../test.py", line 15, in <module>
    print(omc.sendExpression("getComponents(Test)"))
  File ".../venv/lib/python3.8/site-packages/OMPython/__init__.py", line 778, in sendExpression
    answer = OMTypedParser.parseString(result)
  File ".../venv/lib/python3.8/site-packages/OMPython/OMTypedParser.py", line 120, in parseString
    res = omcGrammar.parseString(string)
  File ".../venv/lib/python3.8/site-packages/pyparsing.py", line 1955, in parseString
    raise exc
  File ".../venv/lib/python3.8/site-packages/pyparsing.py", line 3814, in parseImpl
    raise ParseException(instring, loc, self.errmsg, self)
pyparsing.ParseException: Expected end of text, found '{'  (at char 0), (line:1, col:1)

If I replace ":" with "2", the issue goes away and returns the expected result.

ericchapman added a commit to ericchapman/OMPython that referenced this issue Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant