An Extended Symbol Table Infrastructure to Manage the Composition of Output-Specific Generator Information

Reading time: 5 minute
...

📝 Abstract

Code generation is regarded as an essential part of model-driven development (MDD) to systematically transform the abstract models to concrete code. One current challenges of templatebased code generation is that output-specific information, i.e., information about the generated source code, is not explicitly modeled and, thus, not accessible during code generation. Existing approaches try to either parse the generated output or store it in a data structure before writing into a file. In this paper, we propose a first approach to explicitly model parts of the generated output. These modeled parts are stored in a symbol for efficient management. During code generation this information can be accessed to ensure that the composition of the overall generated source code is valid. We achieve this goal by creating a domain model of relevant generator output information, extending the symbol table to store this information, and adapt the overall code generation process.

💡 Analysis

Code generation is regarded as an essential part of model-driven development (MDD) to systematically transform the abstract models to concrete code. One current challenges of templatebased code generation is that output-specific information, i.e., information about the generated source code, is not explicitly modeled and, thus, not accessible during code generation. Existing approaches try to either parse the generated output or store it in a data structure before writing into a file. In this paper, we propose a first approach to explicitly model parts of the generated output. These modeled parts are stored in a symbol for efficient management. During code generation this information can be accessed to ensure that the composition of the overall generated source code is valid. We achieve this goal by creating a domain model of relevant generator output information, extending the symbol table to store this information, and adapt the overall code generation process.

📄 Content

Andreas Oberweis, Ralf Reussner (Hrsg.): Modellierung 2016, Lecture Notes in Informatics (LNI), Gesellschaft f¨ur Informatik, Bonn 2016 133 An Extended Symbol Table Infrastructure to Manage the Composition of Output-Specific Generator Information Pedram Mir Seyed Nazari1, Alexander Roth1, Bernhard Rumpe1 Abstract: Code generation is regarded as an essential part of model-driven development (MDD) to systematically transform the abstract models to concrete code. One current challenges of template- based code generation is that output-specific information, i.e., information about the generated source code, is not explicitly modeled and, thus, not accessible during code generation. Existing approaches try to either parse the generated output or store it in a data structure before writing into a file. In this paper, we propose a first approach to explicitly model parts of the generated output. These modeled parts are stored in a symbol for efficient management. During code generation this information can be accessed to ensure that the composition of the overall generated source code is valid. We achieve this goal by creating a domain model of relevant generator output information, extending the symbol table to store this information, and adapt the overall code generation process. Keywords: Symbol Table, Output-Specific Generator Information, Code Generation 1 Introduction In model-driven development (MDD) code generation is an essential part to systematically generate detailed code from abstract input models. To bridge the gap between problem do- main (abstract models) and solution domain (concrete code), MDD lifts the input models to primary artifacts in the development process. Regardless of the importance, code gen- erator development is still a labor-intense and time-consuming task, where approaches to explicitly manage output-specific information are still lacking. Explicitly management of output-specific code generator information, i.e., information about the generated source code, is essential for code generation to ensure that the gen- erated source code is valid, i.e., well-formed. More importantly, it is necessary in the de- velopment process of code generators to split development tasks and in the maintenance phase as a documentation. For example, consider Java code is generated from UML class diagrams [Ru11]. In order to access parts of those generated Java classes are to be accessed during code generator runtime, the information of the relation of class diagram elements to Java elements is required such as class instantiation via the factory pattern [Ga95] versus direct instantiation via new-constructs. Current code generator frameworks, e.g., [Me15, Xt15, Ac15, Je15], primarily focus on the code generation process and the development of code generators but mainly neglect explicit modeling of code generator output. Moreover, round-trip engineering [MER99] 1 RWTH Aachen University, Software Engineering, http://www.se-rwth.de [MSNRR16] P. Mir Seyed Nazari, A. Roth, B. Rumpe: An Extended Symbol Table Infrastructure to Manage the Composition of Output-Specific Generator Information. In: Modellierung 2016 Conference, LNI P-254, pp. 133–140. Bonner Köllen Verlag, 2016. www.se-rwth.de/publications 134 Pedram Mir Seyed Nazari, Alexander Roth, Bernhard Rumpe and reverse engineering [CC90] try to recreate models from the generated output. An ap- proach to explicitly model information, which is exchanged during code generation, has been presented [JMS08]. However, the output still needs to either be first generated or approaches to address the required parts of the generated source code are lacking. Hence, in this paper we present our approach to make output-specific code generator infor- mation explicit. As this information is dependent on the used input and output language, we present a preliminary domain model for a code generator that uses a variant of UML class diagrams [OM15] as input and Java as output. In this domain model, we use existing approaches [Ru11, Ru12] to map elements of UML class diagrams to Java code and pro- vide an extension to manage Java object instantiation and field access via accessors and mutators. By making such information explicit, we enable code generator developers to exchange this information during development. Moreover, we make this information ac- cessible at generation-time by extending the symbol table and the code generation process to allow storing arbitrary information. Hence, we first introduce the basic concepts of symbol tables and code generation used in the MontiCore framework in Section 2. Then, we present our approach to manage output- specific code generator information by extending the symbol table and the code generation process (Section 3). Finally, we conclude our paper in Section 5. 2 Symbol Table and Code Generation As the foundation for all aspects of language definition, language processing, and template- based code generation, we use the MontiCore language workb

This content is AI-processed based on ArXiv data.

Start searching

Enter keywords to search articles

↑↓
ESC
⌘K Shortcut