A Modelica parser based on parser generator
Project description
modparc
modparc is a Modelica parser in Python based on parser combinator.
Free software: GNU General Public License v3
Source code: https://github.com/xie-dongping/modparc.
Documentation: https://modparc.readthedocs.io.
Quickstart
Install the package from PyPI:
$ pip install modparc
To parse a Modelica source file “your_modelica_file.mo”:
import modparc
model_definition = modparc.parse_file("your_modelica_file.mo")
To list all the equations in the model_definition instance:
all_equations = model_definition.search('Equation')
for equation in all_equations:
print(equation.code()) # The code of the equation as string
To get the name of the model loaded:
print(model_definition.name()) # get the name of the stored class
print(model_definition.class_type()) # get the type of the class
Features
Experimentally parses Modelica Standard Library 3.2.1
Search element of a certain class
Known Issues
Handling tokenization of Q-IDENT and comments, which comes first?
Assertion syntax not defined in Modelica specification
Default recursion depth is not enough for long vector literals
Cyclic import is neccessary for the Modelica syntax definition
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
History
0.1.5 (2016-10-22)
First release on PyPI.
0.2.0 (2016-10-22)
Get names and types of the defintions
Roundtripping of the defintions
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for modparc-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa79a45c6342a24722e0414572b8da2a30423f28cd0aca9c404983df6077a3c6 |
|
MD5 | a6eff9e0bd9748246691cb8a5bb8a58a |
|
BLAKE2b-256 | bb73fa968211d8edb370d09a886334089a71e423f2d36f84263d5a35f723a767 |