Some of Stef's Stuff

An (almost) complete Xtext grammar for Modelica

by Stefano on 2016.02.16, no comments

Want create site? Find Free WordPress Themes and plugins.

Few notes on how to implement the Modelica Language Specification in Xtext

Modelica, Xtext and EMF

Modelica is a language for modeling of physical systems built on object-oriented constructs to facilitate reuse of modeling knowledge. Modelica language, in the scope of this exercise, is just another domain specific language (DSL).

Xtext is a framework for development of programming languages and domain-specific languages.

Existing resources

The topic of this article has been covered by others. The following list is a reference to similar resources found online:

  • ModelicaML – the project provides an UML profile for Modelica and a set of tools for models development and model to model translation. The project uses Xtext as framework for the development of specialized editors and defines a Xtext grammar linked to an existing Modelica EMF model. The Xtext grammar is available from the repository of the MDT project
  • OneModelica – is a promising project of an Eclipse-based Modelica IDE. The specialized editors are derived using Xtext starting from an optimised implementation of the language specification. OneModelica source code has not been released (yet?) but the Xtext grammar is available in Appendix A of the dissertation An Integrated Development Environment with Enhanced Domain-Specific Interactive Model Validation by Roland Samlus (however, a first attempt to compile the grammar at hand was unsuccessful)

Xtext Grammar

The Xtext grammar of the Modelica language is available on GitHub. This particular implementation tries to be as much as possible compliant with the language specification version 3.3 rev.1, with the exceptions detailed below.

  1. different implementation of comments
  2. addition of unary arithmetic to deal with signed numbers
  3. custom implementation of Annotation (to be completed)


Did you find apk for android? You can find new Free Android Games and apps.

Leave a Reply

Your email address will not be published. Required fields are marked *