GENERATING A MODELICA COMPILER FROM NATURAL SEMANTICS SPECIFICATIONS

The implementation of compilers and interpreters for non-trivial languages is a complex and error prone process, if done by hand. Therefore, formalisms and generator tools have been developed that allow automatic generation of compilers and interpreters from formal specifications. This offers two major advantages: • High level descriptions of language properties, rather than detailed programming of the translation process • High degree of correctness of generated implementations. The high level specifications are more concise and easier to read than a detailed implementation in some programming language Modelica is an object-oriented language for modeling of physical systems for the purpose of efficient simulation. The language unifies and generalizes previous object-oriented modeling languages. A Modelica model is defined in terms of classes containing equations and definitions. The semantics, i.e. the meaning of such a model is defined via translation of classes, instances and connections into a flat set of constants, variables and equations. This paper describes and defines a formal semantics for Modelica expressed in a high-level specification notation called natural semantics. A compiler generation system called RML produces a a Modelica translator from such a language specification. The generated translator is produced in ANSI C and has comparable performance as hand-written translators. The RML tool has also been used to produce compilers for Java, Pascal and few other languages.