This report gives a language definition and tutorial on how to model languages using MetaModelica 2.0 – an extension of Modelica 3.2 designed for efficient language modeling. Starting from an extremely simple language, a series of small languages are modeled by gradually adding features. Both interpretive and translational language semantics are modeled. Exercises with solutions are given.
The approach of allowing the modeling language to model language semantics in principle allows the definition of language semantics in libraries, which could be used to reverse the current trend of model compilers becoming very large and complex.
MetaModelica 2.0 builds on MetaModelica 1.0 which was the first Modelica language version that supports language modeling, and has been in extensive use since 2005, primarily in the development of the OpenModelica compiler.
The following version of MetaModelica, called MetaModelica 2.0, is described in this report. It is easier to use since it also supports the standard Modelica 3 language features as well as additional modeling features for expressiveness and conciseness. It is implemented within the OpenModelica compiler itself. This means that the OpenModelica compiler supporting MetaModelica 2.0 is bootstrapped, i.e., it compiles itself.
This work is strongly connected to the Modelica 4 effort announced by Modelica Association in September 2010, which includes moving language functionality into library packages to achieve more extensible and modular Modelica model compilers. The MetaModelica language features contribute to realizing that goal. The language features have been proven in large-scale usage in the packages within the OpenModelica compiler. However, much work still remains in improving the modularity and interface properties that are expected by library packages.
Linköping: Linköping University Electronic Press , 2011. , 297 p.