README
Grammar::Modelica
Raku grammar for parsing the Modelica Language Specification, based primarily on Appendix B concrete syntax rules.
What this project provides
A modular Modelica grammar under
lib/Grammar/Modelica*Parsing support for key language areas (lexical conventions, expressions, equations, class definitions, etc.)
Test suite in
t/covering the main grammar components
Quick start
zef install --deps-only .Parse a snippet:
raku -Ilib -e "use Grammar::Modelica; say so Grammar::Modelica.parse('model A end A;')"Run tests
raku -Ilib t/Modelica.tor run the full suite:
prove -e "raku -Ilib" -r tDocker workflow
Run tests in a container without installing Raku locally:
docker build --no-cache --progress=plain -t grammar-modelica-test . 2>&1
docker run --rm grammar-modelica-test 2>&1Build and run the project test image:
docker build -t grammar-modelica-test .
docker run --rm grammar-modelica-testIf you have make available, convenience targets are provided:
make docker-build
make docker-test
make docker-shelldocker-shell mirrors your idea of launching an interactive Rakudo container, but pre-mounts this repository as /app so you can run commands directly against project files.
Parse the Modelica Standard Library (MSL)
This repository includes examples/parseThemAll.p6, a bulk parser runner intended for full-library validation.
What it does
Recursively finds all
.mofiles under a directoryParses each file with Grammar::Modelica.parse(...)
Prints
OK,FAIL, orERRORper filePrints a final summary line:
passed=<n> failed=<n> total=<n>Exits with code
0only when all files pass
Local run against pinned MSL v4.0.0 (Docker)
git clone --depth 1 --branch v4.0.0 https://github.com/modelica/ModelicaStandardLibrary.git _deps/ModelicaStandardLibrary
docker build -t grammar-modelica-test .
docker run --rm \
-v "$PWD:/app" \
-w /app \
grammar-modelica-test \
raku -Ilib examples/parseThemAll.p6 _deps/ModelicaStandardLibrary | tee msl-parse.logWindows cmd.exe variant:
if not exist _deps\ModelicaStandardLibrary\NUL git clone --depth 1 --branch v4.0.0 https://github.com/modelica/ModelicaStandardLibrary.git _deps\ModelicaStandardLibrary
docker build -t grammar-modelica-test .
docker run --rm -v "%cd%:/app" -w /app grammar-modelica-test raku -Ilib examples/parseThemAll.p6 _deps/ModelicaStandardLibrary > msl-parse.log 2>&1If terminal streaming is unreliable, always inspect msl-parse.log for complete output.
CI
CI is configured with GitHub Actions (.github/workflows/ci.yml) and runs through Docker to keep local and CI execution paths aligned.
Current CI flow:
Build Docker image
Run regular test suite
Clone Modelica Standard Library at pinned tag
v4.0.0Run full MSL parse via examples/parseThemAll.p6
Upload parse log artifact (
msl-parse-log) for diagnostics
Repository layout
lib/Grammar/Modelica.rakumodā top-level grammar entry pointlib/Grammar/Modelica/ā grammar modules by syntax domaint/ā tests and regressionsexamples/ā small parsing examples
Current status
The project is stable and test-backed, with ongoing modernization work focused on:
modern Raku conventions
parser performance improvements
richer parse actions / AST-oriented outputs