This report gives a language definition and tutorial on how to model languages using MetaModelica 1.0 – an extended subset of Modelica 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 1.0 is 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.
MetaModelica 1.0 is strongly related to the RML specification language for Natural Semantics/Structural Operational Semantics, and is implemented using the RML compiler kernel but with a new compiler frontend. Thus, it lacks many standard language features in Modelica and requires a strictly functional modeling style.
The next version of MetaModelica, becoming available during the spring 2011, is implemented within the standard OpenModelica compiler. Therefore it also supports the standard Modelica 3 language features as well as additional features for expressiveness and conciseness.