MPS 3.4 Tutorials

Total Page:16

File Type:pdf, Size:1020Kb

MPS 3.4 Tutorials MPS 3.4 Tutorials Formatted by Space2Latex from the MPS wiki 2016-09-30 i Credits The MPS user guide has evolved thanks to numerous big and small contributions of many contributors. Although most of the work has beed done by the individual members of the MPS core team, external MPS users have done their share, as well. On this page we list the prominent external contributors, who have helped evolve the user guide: • Markus Voelter • Marco Lombardo Contents Front cover i Credits i Contents ii I Start 1 1 Fast Track to MPS 2 1.1 Ten steps to mastery..............................................2 1.2 Step 1 - Install MPS...............................................2 1.3 Step 2 - MPS from the programmer’s perspective...............................2 1.4 Step 3 - MPS from the language designer’s perspective............................3 1.5 Step 4 - Creating your first language.....................................4 1.6 Step 5 - Why MPS...............................................5 1.7 Step 6 - Projectional editing tips and tricks..................................5 1.8 Step 7 - Shapes tutorial.............................................5 1.9 Step 8 - Calculator tutorial...........................................6 1.9.1 The Calculator tutorial in JavaScript..................................6 1.10 Step 9 - Other sample projects.........................................7 1.11 Step 10 - Generator tutorial...........................................8 1.12 Reviewing the progress.............................................8 1.13 Moving up the ladder..............................................9 1.14 Documentation sources.............................................9 1.14.1 Books.................................................. 10 1.14.2 Cookbooks................................................ 10 1.14.3 User guides............................................... 10 1.14.4 Screencasts............................................... 10 1.14.5 Guided Trainings............................................ 10 1.14.6 General documentation......................................... 10 1.14.7 Glossary................................................. 11 II Introduction 12 2 Shapes - an introductory MPS tutorial 13 2.1 Prerequisities.................................................. 13 2.2 Goal....................................................... 13 2.3 Create a new project.............................................. 14 2.4 Languages and programs under the hood.................................... 16 2.5 Graphical shape................................................. 17 2.6 Circle....................................................... 19 2.7 Square...................................................... 22 2.8 Canvas...................................................... 22 2.9 An early test ride................................................ 24 2.10 Editors...................................................... 26 2.10.1 Shape.................................................. 27 2.10.2 Circle.................................................. 27 2.10.3 Square.................................................. 28 2.10.4 Canvas.................................................. 29 2.11 Second run.................................................... 30 ii CONTENTS iii 2.12 Coloring..................................................... 30 2.12.1 Concept for colors............................................ 31 2.12.2 Pre-defined colors............................................ 31 2.12.3 First touch on dependencies...................................... 33 2.12.4 Concept for color reference....................................... 35 2.12.5 Updating Shape............................................. 37 2.13 Embedding the editor component........................................ 38 2.14 A third run.................................................... 38 2.15 Generator.................................................... 39 2.15.1 Parametrizing the template....................................... 49 2.15.2 Drawing shapes............................................. 51 2.15.3 Generating circles............................................ 53 2.15.4 Parametrization............................................. 59 2.15.5 Reducing Squares............................................ 64 2.15.6 A more robust generation for Squares................................. 65 2.16 Generating code................................................. 67 2.17 Running the code................................................ 69 2.18 What to do next................................................. 72 III Generator 73 3 Generator Demos 74 3.1 Generator Tutorial................................................ 74 3.2 How to Use This Documentation........................................ 74 3.3 Setting-Up Demo Project............................................ 74 3.3.1 New Project............................................... 74 3.3.2 New Demo Solution........................................... 76 3.3.3 New Test Model............................................. 77 3.4 Test Generation................................................. 78 3.5 What’s Inside.................................................. 78 3.5.1 Generator User Guide Demo1...................................... 78 3.5.2 Generator User Guide Demo2...................................... 78 3.5.3 Generator User Guide Demo3...................................... 78 3.5.4 Generator User Guide Demo4...................................... 78 3.5.5 Generator User Guide Demo5...................................... 78 3.5.6 Generator User Guide Demo6...................................... 79 3.5.7 Generator User Guide Demo7...................................... 79 4 Generator User Guide Demo1 80 4.1 Generator User Guide Demo 1......................................... 80 4.2 New Language.................................................. 80 4.3 New Generator.................................................. 81 4.4 Root Mapping Rule............................................... 81 4.5 Property-macro................................................. 82 4.6 The main() method............................................... 83 4.7 SWITCH-macro................................................. 84 4.8 Getting Ready for the First Test........................................ 86 4.9 Generating Test Model............................................. 86 5 Generator User Guide Demo2 88 5.1 Generator User Guide Demo 2......................................... 88 5.2 New Language.................................................. 88 5.3 Conditional Root Rule.............................................. 89 5.4 LOOP-macro.................................................. 91 5.5 Running First Test................................................ 91 5.6 Abandon Root Rule............................................... 92 CONTENTS iv 6 Generator User Guide Demo3 93 6.1 Generator User Guide Demo 3......................................... 93 6.2 New Language.................................................. 93 6.3 addContent(container)............................................. 93 6.4 Generating components............................................. 94 6.5 Inserting components.............................................. 96 6.6 New Test Model................................................. 99 6.7 Adding an $IF$ macro.............................................. 100 6.8 Reusable template................................................ 101 6.9 MAP_SRC-macro................................................ 102 6.10 INCLUDE-macro................................................. 103 6.11 Testing what we have.............................................. 104 6.12 Reference-macro (Resolving by Name)..................................... 104 6.13 The final test.................................................. 106 7 Generator User Guide Demo4 107 7.1 Generator User Guide Demo 4......................................... 107 7.2 New Language.................................................. 107 7.3 Template for Panel............................................... 107 7.4 First Test.................................................... 108 7.5 Restricting the LOOP macro to root elements................................. 109 7.6 COPY_SRC-macro............................................... 111 7.7 Reduction Rule................................................. 112 7.8 Final Test.................................................... 114 8 Generator User Guide Demo5 116 8.1 Generator User Guide Demo 5......................................... 116 8.2 New Language.................................................. 116 8.3 New Test Model................................................. 116 8.4 Pre-processing Script.............................................. 117 8.5 First Test.................................................... 118 8.6 Utility Classes in Generator........................................... 118 8.7 Post-processing Script.............................................. 119 8.8 Second Test................................................... 120 9 Generator User Guide Demo6 121 9.1 Generator User Guide Demo 6......................................... 121 9.2 The core idea.................................................. 121 9.3 New Language.................................................. 121 9.4 New Test Model................................................. 122 9.5 Generator.................................................... 123 9.6 Reduction Rules................................................
Recommended publications
  • An MPS Implementation for Simplic
    An MPS implementation for SimpliC Raphaël Castanier D11, Lund University, Sweden [email protected] Abstract a structure that allows better flexibility for language design, The goal of this study was to evaluate JetBrains language including extension and visualisation [9]. editor provided as an Open Source project called MPS (Meta- MPS represents programs in tree models stored in XML Programming System). One way to evaluate MPS perfor- files. The tree represents the structure of program and each mances for designing simple language compiler was to imple- node is called concept. Each concept can have hierarchical ment the SimpliC language in MPS through its projectional inheritance and specific rules, allowing complex structure editor. We will present in this paper what a projectional constructions. Thus, the program can be represented in the editor is and its opportunities for language design. Then editor, i.e. projected, into different views, using editor aspects. we will introduce basic concepts of language design in MPS For instance, the same program can be projected into textual through our SimpliC implementation, and discuss the lessons notation, diagram editor or symbolic editor [7]. Moreover, we learned from this. We also discuss an evaluation of this constraints and behaviours add rules to construct program process and present related academic work. structure. Finally, previous aspects of language contruction enable MPS to perform a lot of static analysis such as type 1 Introduction checking, name analysis and code generation. For educational purpose, we used a C-like language called Designing compilers is a complex task, requiring different SimpliC. SimpliC is a reduced-concepts language with most steps.
    [Show full text]
  • Alembicue: a Projectional Editor & IDE for Container Application Architecture
    Computer Science 18COC251 B627091 Alembicue: A projectional editor & IDE for container application architecture George Garside Supervisor: Dr. Daniel Reidenbach Loughborough University Summer 2019 Abstract The lack of a competent integrated development environment for Docker is a detriment to the field of containerisation and cloud computing. This project documents the development of Alembicue, a projectional and productive Docker IDE, implementing a more formally specified language definition, representative of what is necessary to create imagesfor use with a containerisation platform. Alembicue guarantees syntactic correctness with a projectional editor mutating an abstract syntax tree, incorporating contextual intentions and quick fixes to suggest and automatically apply standards and best practices. Alembicue’s launch has been a success, being received well by the community with tens of thousands of interested visitors to the project page, and elated testimonials from those having used the application and the innovative concepts portrayed within. Acknowledgements I would like to thank my supervisor, Dr. Daniel Reidenbach, for his consistent support and valuable feedback on my work. I would also like to thank my family and friends for their support in my studies. ii alembicate, v. 1627. transitive. Chiefly figurative: to produce, refine, or transform (an idea, emotion, etc.) as if in an alembic. Cf. alembicated adj. cue, n.2 1553. 1c. A stimulus or signal to perception, articulation, or other physiological response. Oxford English Dictionary (1989). alembicue, n. 2019. Chiefly emblematic: the juncture of the production of imagery and the container articulation process founded on the aforesaid. With apologies to linguists. iii Contents I Foundation 1 1 Introduction 2 1.1 Overview .
    [Show full text]
  • Deep, Seamless, Multi-Format, Multi-Notation Definition and Use of Domain-Specific Languages
    Deep, Seamless, Multi-format, Multi-notation Definition and Use of Domain-specific Languages Inauguraldissertation zur Erlangung des akademischen Grades eines Doktors der Naturwissenschaften der Universität Mannheim vorgelegt von Diplom-Wirtschaftsinformatiker Ralph Gerbig aus Worms Mannheim, 2017 Dekan: Professor Dr. Heinz Jürgen Müller, Unversität Mannheim Referent: Professor Dr. Colin Atkinson, Unversität Mannheim Korreferent: Professor Dr. Juan de Lara, Universidad Autónoma de Madrid Tag der mündlichen Prüfung: 24. Februar 2017 To Valerie. Acknowledgments I thank Colin Atkinson for the supervision and the support he provided during the last six exciting years. We had a lot of open minded and fruitful discussi- ons and he gave invaluable guidance and feedback on this dissertation and the Melanee tool. I also thank Juan de Lara, my second supervisor, for his input to this dis- sertation and the joint research. Especially, I want to thank him for hosting one of my students at the Universidad Autónoma de Madrid and the support he gave to this student during his master thesis. I thank all the students who contributed towards the success of this dis- sertation in the form of seminars and bachelor/master theses and as student assistants. Especially, I want to thank Nicole Wesemeyer, Katharina Markert, Daniel Gritzner and Dominik Kantner for their outstanding contributions to the Melanee tool. I thank Bastian Kennel, for supervising my diploma (cf. master) thesis on the topic of deep modeling. This built the foundation for all following research leading to the Melanee tool as it is today and the approach described in the dissertation. I thank Mathias Fritzsche for the opportunity to join him for an internship at SAP Research in Belfast where I had my first taste of research, model-driven development and Eclipse Plug-in development.
    [Show full text]
  • Jetbrains MPS As a Tool for Extending Java
    JetBrains MPS as a Tool for Extending Java Vaclav Pech Alex Shatalin Markus Voelter JetBrains JetBrains independent/Itemis [email protected] [email protected] [email protected] Abstract bench [8], MetaEdit+1, Eclipse Xtext 2 and Spoofax 3 (for a JetBrains MPS is an integrated environment for language brief comparison of some of these tools see Related Work in Section 4). For a general overview of language workbenches, engineering. It allows language designers to define new pro- 4 gramming languages, both general-purpose and domain- please refer to the Language Workbench Competition . specific, either as standalone entities or as modular exten- Real-world use of MPS As a real-world proof of MPS, sions of already existing ones. Since MPS leverages the con- JetBrains has built YouTrack 5, a web-based bug tracking cept of projectional editing, non-textual and non-parseable application. It heavily relies on an MPS-based set of lan- syntactic forms are possible, including tables or mathemat- guages for web application development and database map- ical symbols. This tool paper introduces MPS and shows ping { Webr-DNQ. In less than three years YouTrack became how its novel approach can be applied to Java development. an important part of JetBrains' product portfolio, validating Special attention will be paid to the ability to modularize the LOP idea as well as its implementation in MPS. More and compose languages. on how YouTrack benefits from LOP can be found in [9]. Categories and Subject Descriptors D.2.6 [Software The MPS team cooperated with several universities to Engineering]: Programming Environments - Programmer help them adopt MPS as a tool for language design research.
    [Show full text]