Bootstrapping a Modelica Compiler aiming at Modelica 4

Martin Sjölund
Programming Environment Lab, Dept. Computer Science, Linköping University, Sweden

Peter Fritzson
Programming Environment Lab, Dept. Computer Science, Linköping University, Sweden

Adrian Pop
Programming Environment Lab, Dept. Computer Science, Linköping University, Sweden

Ladda ner artikelhttp://dx.doi.org/10.3384/ecp11063510

Ingår i: Proceedings of the 8th International Modelica Conference; March 20th-22nd; Technical Univeristy; Dresden; Germany

Linköping Electronic Conference Proceedings 63:58, s. 510-521

Visa mer +

Publicerad: 2011-06-30

ISBN: 978-91-7393-096-3

ISSN: 1650-3686 (tryckt), 1650-3740 (online)


What does it mean to bootstrap a compiler; and why do it? This paper reports on the first bootstrapping (i.e.; a compiler can compile itself) of a full-scale EOO (Equation-based Object-Oriented) modeling language such as Modelica. The Modelica language has been modeled/implemented in the OpenModelica compiler (OMC) using an extended version of Modelica called MetaModelica. OMC models the MetaModelica language and is now compiling itself with good performance. Benefits include a more extensible maintainable compiler; also making it easier to add functionality such as debugging support.

This work is in line with the recently started Modelica 4 design effort which includes moving implementation of language features from the compiler to a Modelica Core library; allowing compilers to become smaller while increasing correctness and portability.

A number of language constructs discussed for Modelica 4 are already supported in some form by the bootstrapped compiler. Future work includes adapting language constructs according to the Modelica 4 design effort and extracting and restructuring parts of the Modelica implementation from the OMC compiler to instead reside in a Modelica Core library; making the compiler smaller and more extensible.


Compilation; Modelica; MetaModelica; meta-programming; metamodeling; modeling; simulation


[1] Matthias Blume. The SML/NJ Bootstrap Compiler User Manual. July; 2001.

[2] David Broman and Peter Fritzson. Higher-Order Acausal Models. In Proceedings of the 2nd International Workshop on Equation-Based Object-Oriented Languages and Tools; (EOOLT’2008); Pathos; Cyprus; July 8; 2008. Published by Linköping University Electronic Press; http://www.ep.liu.se/ecp/024/; July 2008.

[3] David Broman. Meta-Languages and Semantics for Equation-Based Modeling and Simulation. Dissertation No 1333; www.ep.liu.se; Linköping University; October 1; 2010.

[4] Stefan Brus. Bootstrapping The OpenModelica Compiler: Implementing Functions As Arguments. Master thesis draft; 2009. www.ep.liu.se. Finalized Spring 2010.

[5] Emil Carlsson. Translating Natural Semantics to Meta-Modelica. Master Thesis; LITH-IDA-Ex--05/073—SE; Linköping University; October 2005.

[6] Peter Fritzson. Principles of Object-Oriented Modeling and Simulation with Modelica 2.1; 940 pages; Wiley-IEEE Press; 2004. doi: 10.1109/9780470545669.

[7] Peter Fritzson; Peter Aronsson; Håkan Lundvall; Kaj Nyström; Adrian Pop; Levon Saldamli; and David Broman. The OpenModelica Modeling; Simulation; and Software Development Environment. Simulation News Europe; 44/45; Dec. 2005. http://www.openmodelica.org

[8] Peter Fritzson; Adrian Pop; and Peter Aronsson. Towards Comprehensive Meta-Modeling and Meta-Programming Capabilities in Modelica. In Proc. of the 4th International Modelica Conference; Hamburg; Germany; March 7-8; 2005.

[9] Peter Fritzson. Language Modeling and Symbolic Transformations with Meta-Modelica. (Later versions[10]; [11]); www.ida.liu.se/~pelab/Modelica; and www.openmodelica.org Version 0.5; June 2005.

[10] Peter Fritzson. Modelica Meta-Programming and Symbolic Transformations - MetaModelica Programming Guide. (Slightly updated version of [9]; later update: [11]) http://www.openmodelica.org/index.php/developer/devdocumentation. June 2007.

[11] Peter Fritzson and Adrian Pop. Meta-Programming and Language Modeling with MetaModelica 1.0. (Almost identical to [10]; but tech. report). Technical reports in Computer and Information Science; No 9; Linköping University Electronic Press; http://www.ep.liu.se/PubList/Default.aspx?SeriesID=2550 ; January 2011.

[12] Peter Fritzson; Adrian Pop; and Martin Sjölund. Towards Modelica 4 Meta-Programming and Language Modeling with MetaModelica 2.0. Technical reports in Computer and Information Science; No 10; Linköping University Electronic Press; http://www.ep.liu.se/PubList/Default.aspx?SeriesID=2550 ; February 2011.

[13] Peter Fritzson; Adrian Pop; David Broman; Peter Aronsson. Formal Semantics Based Translator Generation and Tool Development in Practice. In Proceedings of ASWEC 2009 Australian Software Engineering Conference; Gold Coast; Australia; 2009. doi: 10.1109/ASWEC.2009.46.

[14] Peter Fritzson; Pavol Privitzer; Martin Sjölund; and Adrian Pop. Towards a text generation template language for Modelica. In Proceedings of the 7th International Modelica Conference; Como; Italy; Sept. 20-22; 2009

[15] J. Roger Hindley. The principal type scheme of an object in combinatory logic. Transactions of the American Mathematical Society; 146:29-60; Dec. 1969.

[16] Kenneth C. Louden. Programming Languages; Principles and Practice. ISBN 0-534-95341-7; Thomson Brooks/Cole; 2003.

[17] Robin Milner. A Theory of Type Polymorphism in Programming. Journal of Computer and System Sciences; 17:248-375; 1978. doi: 10.1016/0022-0000(78)90014-4.

[18] Robin Milner; Mads Tofte; Robert Harper and David MacQueen. The Definition of Standard ML; 128 pages; MIT Press; 1997.

[19] MLton. Installation Instructions. Jan. 2011. http://mlton.org/PortingMLton.

[20] Modelica Association. The Modelica Language Specification Version 3.2; March 2010. http://www.modelica.org.

[21] Modelica Association. Modelica Standard Library 3.1. Aug. 2009. http://www.modelica.org.

[22] Modelica Association. Minutes of the Modelica Design Meeting 67; www.modelica.org; Atlanta; Georgia; September 2010.

[23] Henrik Nilsson; John Peterson; and Paul Hudak. Functional Hybrid Modeling from an Object-Oriented Perspective. In Proc. of EOOLT’2007; LIU Electronic Press; www.ep.liu.se; Berlin; Germany; August; 2007.

[24] Ulf Nilsson and Jan Maluszynski. Logic; Programming and Prolog. Wiley; 1995.

[25] Objective Caml 3.12.0 installation notes. Aug; 2010. http://caml.inria.fr

[26] Martin Odersky; Lex Spoon; and Bill Venners. Programming in Scala. Artima Press; 2008.

[27] Terence Parr. ANTLR Parser Generator 3.3; Accessed November 2010. http://antlr.org/

[28] Mikael Pettersson. Compiling Natural Semantics; Department of Computer and Information Science; Linköping University; PhD Thesis No. 413; 1995. Published in Lecture Notes in Computer Science No 1549; Springer Verlag; 1999.

[29] Adrian Pop; Peter Fritzson; Andreas Remar; Elmir Jagudin; and David Akhvlediani. OpenModelica Development Environment with Eclipse Integration for Browsing; Modeling; and Debugging. In Proc 5th International Modelica Conf. (Modelica’ 2006); Vienna; Austria; Sept. 4-5; 2006.

[30] Adrian Pop and Peter Fritzson. MetaModelica: A Unified Equation-Based Semantical and Mathematical Modeling Language. In Proceedings of Joint Modular Languages Conference 2006 (JMLC2006) Published in Lecture Notes in Computer Science No 4228; ISSN 0302-9743; Springer Verlag. Jesus College; Oxford; England; Sept 13-15; 2006.

[31] Adrian Pop; Kristian Stavåker; and Peter Fritzson. Exception Handling for Modelica. In Proceedings of the 6th International Modelica Conference (Modelica’2008); Bielefeld; Germany; March.3-4; 2008.

[32] Adrian Pop. Integrated Model-Driven Development Environments for Equation-Based Object-Oriented Languages. www.ep.liu.se; PhD Thesis No. 1183; Linköping University; June 5; 2008.

[33] Martin Sjölund. Bidirectional External Function Interface Between Modelica/MetaModelica and Java. Master thesis; IDA/LITHEXA09/041SE; Aug 2009.

[34] Kristian Stavåker; Adrian Pop; and Peter Fritzson. Compiling and Using Pattern Matching in Modelica. In Proceedings of the 6th International Modelica Conference (Modelica’2008); Bielefeld; Germany; March.3-4; 2008.

[35] Guy L. Steele Jr. and Richard P. Gabriel. The Evolution of Lisp. In Proceedings of the Conference on History of Programming Languages. New York; April; 1993.

[36] Paul R. Wilson; Uniprocessor garbage collection techniques; Lecture Notes in Computer Science; Volume 637/1992; page 1-42. Springer Verlag. 1992.

[37] Dirk Zimmer. Equation-Based Modeling of Variable Structure Systems. PhD Dissertation; ETH Zürich; 219 pages; 2010.

Citeringar i Crossref