×

Implementation of a modelica compiler using JastAdd attribute grammars. (English) Zbl 1187.68139

Summary: We have implemented a compiler for key parts of Modelica, an object-oriented language supporting equation-based modeling and simulation of complex physical systems. The compiler is extensible, to support experiments with emerging tools for physical models. To achieve extensibility, the implementation is done declaratively in JastAdd, a metacompilation system supporting modern attribute grammar mechanisms such as reference attributes and nonterminal attributes.This paper reports on experiences from this implementation. For name and type analyses, we illustrate how declarative design strategies, originally developed for a Java compiler, could be reused to support Modelica’s advanced features of multiple inheritance and structural subtyping. Furthermore, we present new general design strategies for declarative generation of target ASTs from source ASTs. We illustrate how these strategies are used to resolve a generics-like feature of Modelica called modifications, and to support flattening, a fundamental part of Modelica compilation. To validate that the approach is practical, we have compared the execution speed of our compiler to two existing Modelica compilers.

MSC:

68N20 Theory of compilers and interpreters
68Q42 Grammars and rewriting systems
PDF BibTeX XML Cite
Full Text: DOI

References:

[1] The Modelica Association, The Modelica Association Home Page, http://www.modelica.org. 2009
[2] Hedin, G.; Magnusson, E.: Jastadd: an aspect-oriented compiler construction system, Science of computer programming 47, No. 1, 37-58 (2003) · Zbl 1038.68031
[3] T. Ekman, G. Hedin, The JastAdd extensible Java compiler, in: Proceedings of OOPSLA 2007, 2007 · Zbl 1147.68437
[4] Ekman, T.; Hedin, G.: Modular name analysis for Java using jastadd, Lncs 4143 (2006)
[5] J. åkesson, Tools and languages for optimization of large-scale systems, Ph.D. thesis, Department of Automatic Control, Lund University, Sweden, Nov. 2007
[6] K.J. åström, H. Elmqvist, S.E. Mattsson, Evolution of continuous-time modeling and simulation, in: Proceedings of the 12th European Simulation Multiconference, ESM’98, Society for Computer Simulation International, Manchester, UK, 1998, pp. 9–18
[7] M. Andersson, S. Mattsson, D. Brück, T. Schönthal, OmSim–An integrated environment for object-oriented modelling and simulation, in: Proceedings of the IEEE/IFAC Joint Symposium on Computer-Aided Control System Design, CACSD’94, Tucson, Arizona, 1994, pp. 285–290
[8] The Modelica Association, Modelica–a unified object-oriented language for physical systems modeling, language specification, version 3.1, Tech. rep., Modelica Association, 2009
[9] Fritzson, P.: Principles of object-oriented modeling and simulation with modelica 2.1, (2004)
[10] Dynasim AB, Dynasim AB Home Page, http://www.dynasim.se. 2009
[11] PELAB, The OpenModelica Project, http://www.ida.liu.se/ pelab/modelica/OpenModelica.html. 2009
[12] Modelon AB, JModelica Home Page, http://www.jmodelica.org. 2009
[13] Knuth, D. E.: Semantics of context-free languages, Mathematical systems theory 2, No. 2, 127-145 (1968) · Zbl 0169.01401
[14] Hedin, G.: Reference attributed grammars, Informatica (Slovenia) 24, No. 3, 301-317 (2000) · Zbl 0968.68074
[15] Kiczales, G.; Hilsdale, E.; Hugunin, J.; Kersten, M.; Palm, J.; Griswold, W. G.: An overview of aspect J, Lncs 2072, 327-355 (2001)
[16] Ingalls, D. H. H.: A simple technique for handling multiple polymorphism, , 347-349 (1986)
[17] Object Management Group, Unified Modeling Language, http://www.uml.org/. 2007
[18] T. Ekman, Extensible Compiler Construction, Ph.D. thesis, Lund University, Sweden, Jun. 2006
[19] Vogt, H. H.; Swierstra, S. D.; Kuiper, M. F.: Higher order attribute grammars, , 131-145 (1989) · Zbl 0789.68088
[20] Farrow, R.: Linguist-86: yet another translator writing system based on attribute grammars, , 160-171 (1982)
[21] Gamma, E. H.; Johnson, R.; Vlissides, J. R.: Design patterns: elements of reusable object-oriented software, (1995)
[22] G. Hedin, J. åkesson, T. Ekman, Extending languages by leveraging compilers - from Modelica to Optimica, IEEE Software, 2009 (submitted for publication)
[23] Haugwitz, S.; Kesson, J. å; Hagander, P.: Dynamic start-up optimization of a plate reactor with uncertainties, Journal of process control (2008)
[24] H. Danielsson, Vehicle path optimisation, Master’s Thesis ISRN LUTFD2/TFRT–5797–SE, Department of Automatic Control, Lund University, Sweden, Jun. 2007
[25] H. Hultgren, H. Jonasson, Automatic calibration of vehicle models, Master’s Thesis ISRN LUTFD2/TFRT–5794–SE, Department of Automatic Control, Lund University, Sweden, Jun. 2007
[26] J. åkesson, M. Gäfvert, H. Tummescheit, Jmodelica–an open source platform for optimization of modelica models, in: Proceedings of MATHMOD 2009 - 6th Vienna International Conference on Mathematical Modelling, TU Wien, Vienna, Austria, 2009
This reference list is based on information provided by the publisher or from digital mathematics libraries. Its items are heuristically matched to zbMATH identifiers and may contain data conversion errors. It attempts to reflect the references listed in the original paper as accurately as possible without claiming the completeness or perfect precision of the matching.