Lessons Learned from Translating Grammars Between Monticore and Xtext

Lessons Learned from Translating Grammars Between Monticore and Xtext

[DJK+19] M. Dalibor, N. Jansen, J. Kästle, B. Rumpe, D. Schmalzing, L. Wachtmeister, A. Wortmann: Mind the Gap: Lessons Learned from Translating Grammars Between MontiCore and Xtext. In: International Workshop on Domain-Specific Modeling (DSM'19), pp. 40-49, ACM, Athens, Oct. 2019. www.se-rwth.de/publications/ Mind the Gap: Lessons Learned from Translating Grammars between MontiCore and Xtext Manuela Dalibor, Nico Jansen, Johannes Kästle, Bernhard Rumpe, David Schmalzing, Louis Wachtmeister, Andreas Wortmann Software Engineering, RWTH Aachen University, Aachen, Germany www.se-rwth.de Abstract 1 Introduction Model-driven systems engineering relies on software lan- Large-scale model-driven systems engineering (MDSE) [18] guages that support different stakeholders. These languages often involves the collaboration of experts from various do- often operate in different technological spaces. Checking mains across space and time. These experts use various mod- consistency, tracing, and change propagation of models de- eling paradigms, software languages, and tools that oper- veloped by different stakeholders, thus demands methods to ate in different technological spaces. Translating models bridge the gaps between these spaces. Research on the inte- from one technological space into another is crucial for the gration of heterogeneous software languages often considers seamless and automated model processing required to make heterogeneity within specific technological spaces only. We MDSE projects successful. outline a systematic method to translate grammars between Software language engineering (SLE) is the discipline of the technological spaces of the MontiCore and Xtext lan- conceiving, engineering, maintaining, and evolving software guage workbench (LWB) and report observations on general languages [9]. Its subjects are software languages in differ- grammar translation challenges. We have realized this trans- ent shapes, including graphical, textual, and projectional lation in an automated toolchain and present lessons learned languages. Textual languages, i.e., languages whose models along the way. This can significantly facilitate bridging dif- are represented textually, have been successful in a variety of ferent technological spaces and, thus, improve model-driven domains, including automotive [5], cloud systems [26], robot- systems engineering. ics [19], and software engineering [21]. Such languages often are defined in terms of (context-free) grammars8 [ , 25, 28] CCS Concepts • Software and its engineering → Do- that define their structure (abstract syntax) and presentation main specific languages; Syntax. (concrete syntax) in an integrated fashion. Keywords Domain-specific languages, Grammarware, Gram- Automating translation of textual models between differ- mar Translation, Xtext, MontiCore ent technological spaces leveraging SLE techniques can be a ACM Reference Format: greatly facilitate automating model analyses and syntheses Manuela Dalibor, Nico Jansen, Johannes Kästle, Bernhard Rumpe, in MBSE projects. We, therefore, investigate the challenges David Schmalzing, Louis Wachtmeister, Andreas Wortmann. 2019. of translating the concrete syntax and the abstract syntax of Mind the Gap: Lessons Learned from Translating Grammars be- grammar-based languages between different technological tween MontiCore and Xtext. In Proceedings of the 17th ACM SIG- spaces. To this end, we discuss challenges in their trans- PLAN International Workshop on Domain-Specific Modeling (DSM lation, achievable language equivalencies, and discuss the ’19), October 20, 2019, Athens, Greece. ACM, New York, NY, USA, translation of various grammar constituents between the 10 pages. https://doi.org/10.1145/3358501.3361236 technological spaces of MontiCore and Xtext. The contribu- This research has partly received funding from the German Research Foun- tions of this paper, hence, are: dation (DFG) under grant no. EXC 2023 / 390621612. The responsibility for • A discussion of grammar translation challenges. the content of this publication is with the authors. • A systematic investigation of grammar translations Permission to make digital or hard copies of all or part of this work for based on the technological spaces of MontiCore [8] personal or classroom use is granted without fee provided that copies and Xtext [28]. are not made or distributed for profit or commercial advantage and that • Lessons learned about such transformations copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must The insights reported in this paper can support language be honored. Abstracting with credit is permitted. To copy otherwise, or engineers in systematically developing translations between republish, to post on servers or to redistribute to lists, requires prior specific other technological spaces by shedding light on typical chal- permission and/or a fee. Request permissions from [email protected]. lenges for these. DSM ’19, October 20, 2019, Athens, Greece In the remainder, Section 2 illustrates the challenges by © 2019 Copyright held by the owner/author(s). Publication rights licensed to ACM. example. Section 3 introduces preliminaries before Section 4 ACM ISBN 978-1-4503-6984-8/19/10...$15.00 discusses forms of model conservativity that imply different https://doi.org/10.1145/3358501.3361236 challenges for grammar translation. Afterward, Section 5 40 DSM ’19, October 20, 2019, Athens, Greece Dalibor et al. 01 grammar org.Automata with Terminals XG manual transformation between both LWBs is usually time- 02 Automaton : 'automaton' name =ID '{' (st+=State | tr+=Transition)* '}' ; 03 State : 'state' name =ID '<initial>'? '<final>'? ';' ; consuming and error-prone. DSL developers would have to 04 Transition : from=ID '-' input=ID '->' to=ID ';' ; ensure soundness and completeness of the translation, i.e., production rule automated Xtext grammar translation that the MontiCore language depicts exactly the set of models production rule MontiCore grammar that the Xtext language recognizes. Hence, they would have 01 package org; MCG to be experts in both technological spaces. To mitigate this, 02 grammar Automata extends MCBasics { 03 Automaton = "automaton" name:Name "{" (st:State | tr:Transition)* "}"; we investigate on bridging technological spaces for textual 04 State = "state" name:Name "<initial>"? "<final>"? ";" ; 05 Transition = from:Name "-" input:Name "->" to:Name ";" ; DSLs while considering the intricacies of the correspond- 06 } ing language workbenches. For instance, Figure 1 (bottom) Figure 1. Xtext grammar (top) for a simple automata DSL shows a MontiCore grammar that recognizes models that with states and transitions. Automatic translation into a cor- are syntactically identical to the original Xtext grammar. Ob- responding MontiCore grammar (bottom). taining this representation systematically and automated enables leveraging the combined advantages of both tech- nological spaces, i.e., benefiting from the editors generated discusses various cases of grammar element translation and for the Xtext version of this DSL and from the DSTLs at the outlines a systematic methodology for their translation. Sec- same time. This increases efficiency and productivity and tion 6 illustrates its application via a case study and Section 7 thus, fosters software language engineering [10]. presents lessons learned. Section 8 discusses observations, Section 9 highlights related work, and Section 10 concludes. 3 Preliminaries 2 Example MontiCore [8] is a workbench for engineering and compos- ing textual DSLs and facilitates language development by em- Consider a DSL for describing state-based behavior automata ploying context-free grammars (CFGs) for the integrated def- in the development of cyber-physical production systems inition of abstract and concrete syntax. From a CFG, Monti- (CPPS) as identified in [31]. There are various LWBs (e.g., Core generates model processing infrastructure, comprising MontiCore [8], Neverlang [25], Spoofax [15], or Xtext [28]) corresponding abstract syntax classes and a parser, as well as that support engineering such DSLs. Figure 1 (top) depicts symbol tables, visitors, model checking and code generation a simplified grammar for automata that was developed us- infrastructure. Models that adhere to a grammar definition ing the Xtext LWB as Xtext automatically generates editors are parsed into corresponding abstract syntax trees. After- for models of the DSL. Furthermore, Xtext operates in the ward, their symbol tables are created, which store essential technological space of Ecore [22], therefore model compar- information of model elements as symbols for easy access. ison tools [24], execution engines [2], and much more are Their well-formedness is checked via handcrafted context available. In this DSL, an automaton has a name and consists conditions using MontiCore’s model-checking infrastructure. of multiple states and transitions (l. 2). States again have a To facilitate modular DSL development, MontiCore supports name and can be marked as initial or final (l. 3). Finally, tran- language composition of language constituents via language sitions go from one state to another (identified via the state’s extension, embedding, and aggregation [8]. name) and have an input that defines on which pattern the Xtext [28] also is a workbench for engineering textual soft- transition is triggered (l. 4). But if the CPPS should change ware languages that is part of

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    10 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us