Skip to content

Computational Modeling Domain Specific Languages and Tools

Notifications You must be signed in to change notification settings

Model-Based-Design-Lab/cmlang

Repository files navigation

Computational Modeling Language Tools

GitHub: https://github.com/Model-Based-Design-Lab/cmlang

This repository contains the domain-specific-language tools related to [Computational Modeling]

Software

This repository contains two Java/Xtext based projects.

Languages and LSP Server

src/info.computationalmodeling.lang.parent

Contains the Xtext language definitions of the following domain-specific languages of models of computation:

  • Finite State Automata
  • Regular Expressions
  • Linear Temporal Logic
  • Markov Chains
  • Dataflow Graphs
  • Max-plus Algebra Models

It further contains a server for the Language Server Protocol (LSP) through standard I/O to facilitate the use of editors that support LSP. (In particular the Monaco based web editor of the Computational Modeling Workbench).

Code Generation Tools

src/info.computationalmodeling.lang.codegen.parent

This project contains a code generation tool for the various languages defined in the LSP project.

Depending on the model it generates one more of the following

  • Visualization using graphviz
  • Conversion to the SDF3 file format
  • Visualization in LaTeX
  • Conversion to Octave

Extensions for the files are assumed to be as follows:

  • .sdf for dataflow models, generating Graphviz and SDF3
  • .mpm for max-plus models, generating LaTeX
  • .fsa for finite state automata models, generating Graphviz
  • .dtmc for Markov Chain models, generating Octave and Graphviz
  • .ltl for Linear Temporal Logic models, generating LaTeX
  • .regex for regular expression models, generating LaTeX

Building the software

The software can be built from the command line or using the provided docker image. Note that the build creates both Linux and Windows scripts to run the Java based tools.

Command line build

Building from the command line requires a recent Java JDK and Gradle to be installed.

cd src\info.computationalmodeling.lang.parent\
./gradlew installDist
cd ..\info.computationalmodeling.lang.codegen.parent\
./gradlew installDist

The built language server can be found in: src/info.computationalmodeling.lang.parent/info.computationalmodeling.lang.ide/build/install/info.computationalmodeling.lang.ide

The built code generator can be found in: src/info.computationalmodeling.lang.codegen.parent/info.computationalmodeling.lang.codegen.compiler/build/install/info.computationalmodeling.lang.codegen.compiler

Building with Docker

Build the docker image:

The Dockerfile is located in the /src directory. In the /src directory, run the following command to build the image.

docker build -t cmlang .

Run the docker image using a mounted volume referred to as <volume-name> in the command below.

docker run -v <volume-name>:/output cmlang

After a successful run the results are in the mounted volume.

Using the Software

Note that the software requires a Java JRE to be installed on the host platform to run.

The LSP project produces a script to start the application in the bin directory after building. The script is called computational-modelling-language-server-stdio. When run, it accepts LSP clients on stdin and produces outputs on stdout.

The code generation project produces a script to start the application in the bin directory after building.

The tool is run with the following command-line.

codegen <input-file> <output-dir>

It will apply all code generation options it has for the type of input-file and writes corresponding output files in the directory output-dir.

References

This tool has been developed by the Model-Based Design Lab, https://computationalmodeling.info

GitHub: https://github.com/Model-Based-Design-Lab

Contact: Marc Geilen, m.c.w.geilen@tue.nl

License

This software is licensed under the MIT License