OMPython icon indicating copy to clipboard operation
OMPython copied to clipboard

OMTypedParser does not understand variable length arrays

Open ericchapman opened this issue 4 years ago • 0 comments

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 avatar Jun 07 '21 13:06 ericchapman