A Modelica compiler written in modern C++ with Python bindings.
- Parsing using ANTLR4 C++ Runtime.
- Listener based generators decoupled from the AST, easy to compile Modelica to new targets.
- Lisp string printing LispListener.
- Listener based compiler
- C++17 used throughout, minimal copying, low memory footprint, and fast.
- Python bindings planned.
- Parsing with ANTLR.
- Lisp listener for AST string output.
- Bouncing ball end-to-end prototype from Modelica -> Casadi. Simulation in Casadi or using sundials directly.
- Flesh out missing language element.
- NuSMV output for state machines to support model checking.
- Python bindings.
- Doxygen API Documentation
This command line just prints the LISP generator output currently, but it will be extended to support various generators.
$ ./cymoca -h
Cymoca Modelica Compiler 0.0.9-60-g9dd7a23
usage: cymoca [options] model.mo
Options:
Generic options:
-h [ --help ] print help message
$ ./cymoca ./test/models/BouncingBall.mo
(class(dict of comp( v(Real))(parameter g(Real))( x(Real))
)(list of eq(=(der((x)))(v))(=(der((v)))(-(g)))(when(eq block(<(x)(0))(list of eq(=(v)(-(v))))))))
- Binaries are provided here: releases.
- The cymoca-...-Linux.zip is statically linked so it should work on all linux variants and Mac out of the box given the following dependencies are met:
- Dependencies
- glibc 2.2.5
-
You can build cymoca from source using cmake. You will need the following dependencies:
-
Dependencies
-
A quick example of building with cmake:
git clone https://github.com/jgoppert/cymoca
cd cymoca
mkdir -p build
cd build && cmake -DWITH_TEST=ON ..
make -j4
ctest
cpack -G DEB
sudo dpkg -i cymoca*.deb
cymoca my_model.mo
-
Coding standard: Google
- Changes:
- Use m_name instead of name_ for class members to make leading autocomplete nicer to work with.
- Prefer getName() to name() for getter so that all attributes are also easy to acces with get
- Prefer setName() to set_name() for setter
- Changes:
-
IDE Recommendations
- Vim - reliable, fast
- autocomplete working with youcompleteme
- project config with localvim, see .lvimrc
- QtCreator - nice debugging and analysis
- VSCode - nice gui, not as quick with analysis tips, antlr support
- CLion - confused by some macros, but useful for overriding functions, antlr support
- Vim - reliable, fast
-
If you want to get started, feel free to make a PR. The easiest place to start is with a new generator:
- Lisp example LispListener.
- cymoca::ast::listener::Base
- BSD-3-clause, open source and free for commercial use. LICENSE