Giter Club home page Giter Club logo

MontiCore - Language Workbench and Development Tool Framework

MontiCore is a language workbench for the efficient development of domain-specific languages (DSLs). It processes an extended grammar format which defines the DSL and generates Java components for processing the DSL documents. Examples for these components are parsers, AST classes, symboltables or pretty printers. This enables a user to rapidly define a language and use it together with the MontiCore-framework to build domain-specific tools.

Some MontiCore advantages are the reusability of predefined language components, conservative extension and composition mechanisms, and an optimal integration of handwritten code into the generated tools. Its grammar languages are comfortable to use.

Start here for developing with MontiCore.


[HKR21] Katrin Hölldobler, Oliver Kautz, Bernhard Rumpe:
MontiCore Language Workbench and Library Handbook: Edition 2021.
Shaker, 2021.

A Teaser for MontiCore

To show a little of MontiCore's capabilities, the following (incomplete) grammar might help:

grammar MyStatemachine extends Automata,                  // MontiCore grammar 
                               MCBasicTypes, SetExpressions, MCCommonLiterals {     
  start Automaton;

  // overriding a nonterminal (to add optional conditions):
  Transition = from:Name@State ":" Expression? "->" to:Name@State;

  // add new variants of expressions
  LogicalNotExpr implements Expression = "!" Expression;

  XorExpr        implements Expression =
        left:Expression "xor" right:Expression;

  scope LetExpr  implements Expression =
        "let" (VarDeclaration || ",")+ "in" Expression;

  symbol VarDeclaration = MCType? Name "=" Expression ;
}

The grammar language has a variety of mechanisms to define new nonterminals using constants "!", brackets (..), optionals ?, lists *, repetitions (..||..)+, etc. The grammar builds an extended version of Statemachines reusing existing grammar components, here Automata, MCBasicTypes, SetExpressions and MCCommonLiterals. The grammar has 5 productions introducing 4 new nonterminals and overrides Transition, which is inherited from Automata. Transition additionally has an optional Expression? as firing condition. LogicalNotExpr, XorExpr, and LetExpr extend the already existing Expression nonterminal and add new forms of expressions.

LetExpr introduces a new local variable, which is visible only in that scope (indicated by keyword). VarDeclaration defines the new place to define symbols (that have a Name). There is an extensive infrastructure to manage the definition of names, visibility, etc.

MontiCore compiles the above grammar into 78 classes with in total 18629 lines of code that define the complete frontend and a larger part of the backend of a statemachine processor. We now can write statemachines like:

statemachine PingPong {                                         // MyStatemachine
  state Ping, Pong;
  Ping : (speed > 14km/h && !missedBall) -> Pong
}

MontiCore provides versions of expressions that use SI Units like 240km/h or 14.2 m/s^2, but also Java expressions like 2_000_000 and other variants including appropriate type checks. We include these forms of expressions by importing their grammars.

Please note that in both cases (extension and overwriting existing nonterminals), we do not touch nor copy/paste the predefined grammars, but achieve an out-of-the-box reuse. Out-of-the-box reuse also includes reuse of predefined typechecks, code generation, etc. They only need to be extended to the added variants. Please also note that PlusExpr is mutually left-recursive. -- Yes, that works in MontiCore 6.

Quick Start

$ cd /usr/local
$ wget www.monticore.de/download/aut.tar.gz
$ tar -xf aut.tar.gz
$ cd mc-workspace
$ wget www.monticore.de/download/monticore-cli.jar
$ java -jar monticore-cli.jar -g Automata.mc4 -hcp hwc/ -mp monticore-cli.jar
$ javac -cp monticore-cli.jar -sourcepath "src/;out/;hwc/" src/automata/AutomataTool.java
$ java -cp "src/;out/;hwc/;monticore-cli.jar" automata.AutomataTool example/PingPong.aut PingPong.autsym

MontiCore has a Relaxed 3-Level License

Informal summary: The MontiCore Language Workbench deals with three levels of code (MontiCore LWB, tool derivates, product code). Each has its own licenses: (1) Product code generated by a MontiCore tool derivate is absolutely free for each form of use including commercial use without any license restriction. (2) Tool derivates created using the MontiCore language workbench mention that it is built using MontiCore. There is no other restriction. (BSD 3 Clause license) (3) Adaptations of MontiCore should mention MontiCore and results published back into this repository (LGPL license).

For details see Licenses.

More Information about MontiCore

  • MontiCore handbook. The handbook describes how to use MontiCore as an out-of-the-box language workbench, but also as grey box tooling framework. It thus also gives an overview over a number of core mechanisms of MontiCore.

  • List of core grammars. MontiCore concentrates on reuse. It therefore offers a set of predefined language components, usually identified through an appropriate component grammar allowing to define your own language as a composition of reusable assets efficiently. reusable assets are among others: several sets of literals, expressions, types, and statements, which are freely composable.

  • List of languages. This is a list of languages that can be used out of the box. Some of them are in development, others rather stable. Several of these languages are inspired by the UML/P (see [Rum16,Rum17]). These complete languages are usually composed of a number of language components.

  • This project is freely available software; you can redistribute the MontiCore language workbench according to the rules described in the licensing section.

  • Contributing to MontiCore: MontiCore is originally developed by the Software Engineering group at RWTH. Meanwhile, it is maintained by several groups and individual persons. If you want to contribute to MontiCore, please create a fork and issue corresponding pull requests. The RWTH and the Stuttgart development teams will review and merge changes. (A more open process for common development is currently in discussion and depends on interests from further people/groups.) You may also ask to become a member of the project.

  • If questions appear e.g. on building an interpreter, please contact [email protected].

Further Information

MontiCore's Projects

cd4analysis icon cd4analysis

A MontiCore language for defining class diagrams and related tooling. Detailed documentation can be found here: https://github.com/MontiCore/cd4analysis/blob/master/src/main/grammars/de/monticore/cd4analysis.md

feature-diagram icon feature-diagram

A MontiCore language for defining feature diagrams and related tooling.

javadsl icon javadsl

A Java Language and related tooling developed with MontiCore.

json icon json

A MontiCore language for defining JSON documents and related tooling. Detailed documentation can be found here: https://github.com/MontiCore/json/blob/master/src/main/grammars/de/monticore/lang/json.md

montiarc icon montiarc

MontiArc is a formal component and connector architecture description language for modeling software-intensive systems.

monticore icon monticore

MontiCore is a language workbench for an efficient development of domain-specific languages.

se-commons icon se-commons

SE Commons is a collection of utilities and tools arose from the development of MontiCore.

sequence-diagram icon sequence-diagram

A MontiCore language for defining sequence diagrams and related tooling. Detailed documentation can be found here: https://github.com/MontiCore/sequence-diagram/blob/master/src/main/grammars/de/monticore/lang/sd4development.md

siunits icon siunits

A MontiCore language for defining data types including units (SI units) and related tooling. Detailed documentation can be found here: https://github.com/MontiCore/siunits/blob/master/src/main/grammars/de/monticore/SIUnits.md

statecharts icon statecharts

The statecharts language project. This is a mirror only.

sysmlv2 icon sysmlv2

MontiCore implementation of the SysML v2 textual notation

ucd icon ucd

MontiCore Use Case Diagram Language

xml icon xml

A MontiCore language for defining XML artifacts and related tooling.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.