A Modelica parser based on parser generator
Project description
===============================
modparc
===============================
.. image:: https://img.shields.io/pypi/v/modparc.svg
:target: https://pypi.python.org/pypi/modparc
.. image:: https://img.shields.io/travis/xie-dongping/modparc.svg
:target: https://travis-ci.org/xie-dongping/modparc
.. image:: https://readthedocs.org/projects/modparc/badge/?version=latest
:target: https://modparc.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
.. image:: https://pyup.io/repos/github/xie-dongping/modparc/shield.svg
:target: https://pyup.io/repos/github/xie-dongping/modparc/
:alt: Updates
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.
.. contents::
Quickstart
----------
Install the package from PyPI:
.. code-block:: bash
$ pip install modparc
To parse a Modelica source file `"your_modelica_file.mo"`:
.. code-block:: python
import modparc
model_definition = modparc.parse_file("your_modelica_file.mo")
To list all the equations in the `model_definition` instance:
.. code-block:: python
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:
.. code-block:: python
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.
The test cases used code from the `ModelicaByExample library (MIT License by Michael Tiller)`_.
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
.. _`ModelicaByExample`: https://github.com/xogeny/ModelicaBook
=======
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
modparc
===============================
.. image:: https://img.shields.io/pypi/v/modparc.svg
:target: https://pypi.python.org/pypi/modparc
.. image:: https://img.shields.io/travis/xie-dongping/modparc.svg
:target: https://travis-ci.org/xie-dongping/modparc
.. image:: https://readthedocs.org/projects/modparc/badge/?version=latest
:target: https://modparc.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
.. image:: https://pyup.io/repos/github/xie-dongping/modparc/shield.svg
:target: https://pyup.io/repos/github/xie-dongping/modparc/
:alt: Updates
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.
.. contents::
Quickstart
----------
Install the package from PyPI:
.. code-block:: bash
$ pip install modparc
To parse a Modelica source file `"your_modelica_file.mo"`:
.. code-block:: python
import modparc
model_definition = modparc.parse_file("your_modelica_file.mo")
To list all the equations in the `model_definition` instance:
.. code-block:: python
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:
.. code-block:: python
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.
The test cases used code from the `ModelicaByExample library (MIT License by Michael Tiller)`_.
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
.. _`ModelicaByExample`: https://github.com/xogeny/ModelicaBook
=======
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
modparc-0.2.1.tar.gz
(34.5 kB
view details)
Built Distribution
File details
Details for the file modparc-0.2.1.tar.gz
.
File metadata
- Download URL: modparc-0.2.1.tar.gz
- Upload date:
- Size: 34.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c837f05965402fd508ad0d133313c098bb311176d8ea8eaf021372d3d76aa04 |
|
MD5 | 225cd2083b3d4d1f8ccb90395a2ae6ad |
|
BLAKE2b-256 | 538005409bf0b468440496e43c450dd5bc2dd1f201fd8a1839510e5b95417b38 |
File details
Details for the file modparc-0.2.1-py2.py3-none-any.whl
.
File metadata
- Download URL: modparc-0.2.1-py2.py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb9a4ab0c940a1ff7c13ccdabf1181a945960f5786b9fc56c268a51dbe8044e2 |
|
MD5 | 9e125ab26fd04c74ef52d19b46b5882d |
|
BLAKE2b-256 | ce079d41249e58dd0e6cc00495b762ecc80b660a6b6dbfefec717183f506006e |