Git Product home page Git Product logo

monticore's Introduction

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.

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

Further Information

monticore's People

Contributors

maritabreuer avatar npichler avatar dienstknecht avatar rumpe avatar hoelldobler avatar butting avatar n-jansen avatar gvolkova avatar eikermann avatar oliverkautz avatar pedramnazari avatar sinkovec avatar jeromepfeiffer avatar twinragga avatar yesitsme avatar heimrobert avatar mistererwin avatar jonasboecker avatar schmalzing avatar simonvarga avatar kirchhof avatar vonwenckstern avatar ferdinandmehlan avatar themrmilchmann avatar roberteikermann avatar soberhoff avatar overleafer avatar se-fdr avatar lukas-netz avatar manuelpuetzer avatar

Watchers

 avatar

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.