Skip to content

OMTypedParser does not understand variable length arrays #138

Description

@ericchapman

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

fromOMPythonimportOMCSessionZMQif__name__=="__main__":
model=""" model Test parameter Real TEST[:,2] = [0,1;100,2]; end Test; """omc=OMCSessionZMQ()
omc.sendExpression("loadString(\"{}\")".format(model))
# Breaksprint(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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions