Dsl Engineering 1

Total Page:16

File Type:pdf, Size:1020Kb

Dsl Engineering 1 dsl engineering 1 DSL Engineering Designing, Implementing and Using Domain-Specific Languages Markus Voelter with Sebastian Benz Christian Dietrich Birgit Engelmann Mats Helander Lennart Kats Eelco Visser Guido Wachsmuth (c) 2010 - 2013 Markus Voelter Feedback, Slides, and other updates at http://dslbook.org This PDF book is donationware: while you can get the PDF for free from dslbook.org, I would highly appreciate if you used the Donate button on that website to send over some amount of money you deem appropriate for what you get from the book. Thank you! A printed version of this book is available as well. Please go to http://dslbook.org to find links to various Amazon stores where you can buy the print version. Contents I Introduction 5 1 About this Book 7 1.1 Thank You! . 7 1.2 This book is Donationware . 8 1.3 Why this Book . 9 1.4 What you will Learn . 10 1.5 Who should Read this Book . 10 1.6 About the Cover . 11 1.7 Feedback, Bugs and Updates . 11 1.8 The Structure of the Book . 11 1.9 How to Read the Book . 12 1.10 Example Tools . 13 1.11 Case Studies and Examples . 14 2 Introduction to DSLs 23 2.1 Very Brief Introduction to the Terminology . 23 2.2 From General Purpose Languages to DSLs . 25 2.3 Modeling and Model-Driven Development . 29 2.4 Modular Languages . 32 2.5 Benefits of using DSLs . 38 2.6 Challenges . 41 2.7 Applications of DSLs . 45 2.8 Differentiation from other Works and Approaches 48 II DSL Design 51 3 Conceptual Foundations 55 3.1 Programs, Languages and Domains . 55 3.2 Model Purpose . 59 3.3 The Structure of Programs and Languages . 61 4 dslbook.org 3.4 Parsing versus Projection . 65 4 Design Dimensions 67 4.1 Expressivity . 68 4.2 Coverage . 78 4.3 Semantics and Execution . 80 4.4 Separation of Concerns . 100 4.5 Completeness . 109 4.6 Language Modularity . 114 4.7 Concrete Syntax . 130 5 Fundamental Paradigms 139 5.1 Structure . 139 5.2 Behavior . 147 5.3 Combinations . 156 6 Process Issues 159 6.1 DSL Development . 159 6.2 Using DSLs . 166 III DSL Implementation 171 7 Concrete and Abstract Syntax 175 7.1 Fundamentals of Free Text Editing and Parsing . 177 7.2 Fundamentals of Projectional Editing . 186 7.3 Comparing Parsing and Projection . 187 7.4 Characteristics of AST Formalisms . 194 7.5 Xtext Example . 198 7.6 Spoofax Example . 205 7.7 MPS Example . 210 8 Scoping and Linking 219 8.1 Scoping in Spoofax . 221 8.2 Scoping in Xtext . 227 8.3 Scoping in MPS . 232 9 Constraints 237 9.1 Constraints in Xtext . 239 9.2 Constraints in MPS . 240 9.3 Constraints in Spoofax . 245 10 Type Systems 251 10.1 Type Systems Basics . 252 10.2 Type Calculation Strategies . 253 dsl engineering 5 10.3 Xtext Example . 258 10.4 MPS Example . 261 10.5 Spoofax Example . 265 11 Transformation and Generation 269 11.1 Overview of the approaches . 270 11.2 Xtext Example . 272 11.3 MPS Example . 279 11.4 Spoofax Example . 288 12 Building Interpreters 295 12.1 Building an Interpreter with Xtext . 297 12.2 An Interpreter in MPS . 304 12.3 An Interpreter in Spoofax . 306 13 IDE Services 311 13.1 Code Completion . 311 13.2 Syntax Coloring . 314 13.3 Go-to-Definition and Find References . 319 13.4 Pretty-Printing . 321 13.5 Quick Fixes . 325 13.6 Refactoring . 327 13.7 Labels and Icons . 331 13.8 Outline . 332 13.9 Code Folding . 334 13.10Tooltips/Hover . 335 13.11Visualizations . 337 13.12Diff and Merge . 339 14 Testing DSLs 341 14.1 Syntax Testing . 342 14.2 Constraints Testing . 344 14.3 Semantics Testing . 347 14.4 Formal Verification . 354 14.5 Testing Editor Services . 361 14.6 Testing for Language Appropriateness . 365 15 Debugging DSLs 367 15.1 Debugging the DSL Definition . 367 15.2 Debugging DSL Programs . 374 16 Modularization, Reuse and Composition 391 16.1 Introduction . 391 16.2 MPS Example . 392 6 dslbook.org 16.3 Xtext Example . 412 16.4 Spoofax Example . 426 IV DSLs in Software Engineering 437 17 DSLs and Requirements 441 17.1 What are Requirements? . 441 17.2 Requirements versus Design versus Implemen- tation . 443 17.3 Using DSLs for Requirements Engineering . 445 17.4 Integration with Plain Text Requirements . 448 18 DSLs and Software Architecture 453 18.1 What is Software Architecture? . 453 18.2 Architecture DSLs . 455 18.3 Component Models . 466 19 DSLs as Programmer Utility 475 19.1 The Context . 476 19.2 Jnario Described . 477 19.3 Implementation . 480 19.4 Summary . 485 20 DSLs in the Implementation 487 20.1 Introduction . 487 20.2 Challenges in Embedded Software . 489 20.3 The mbeddr Approach . 491 20.4 Design and Implementation . 499 20.5 Experiences . 509 20.6 Discussion . 516 21 DSLs and Product Lines 519 21.1 Introduction . 519 21.2 Feature Models . 520 21.3 Connecting Feature Models to Artifacts . 521 21.4 From Feature Models to DSLs . 526 21.5 Conceptual Mapping from PLE to DSLs . 532 22 DSLs for Business Users 537 22.1 Intentional Software . 537 22.2 The Project Challenge . 538 22.3 The DSL-Based Solution . 539 22.4 Wrapping Up . 556 Part I Introduction 1 About this Book This book is about creating domain-specific languages. It covers three main aspects: DSL design, DSL implementa- tion and software engineering with DSLs. The book only looks at external DSLs and focuses mainly on textual syn- tax. The book emphasizes the use of modern language work- benches. It is not a tutorial for any specific tool, but it pro- vides examples and some level of detail for some of them: Xtext, MPS and Spoofax. The goal of the book is to provide a thorough overview of modern DSL engineering. The book is based on my own experience and opinions, but strives to be objective. 1.1 Thank You! Before I do anything else, I want to thank my reviewers. This book has profited tremendously from the feedback you sent me. It is a lot of work to read a book like this with sufficient concentration to give meaningful feedback. All of you did that, so thank you very much! Here is the list, in alphabetical order: Alexander Shatalin, Bernd Kolb, Bran Selic, Christa Schwan- ninger, Dan Ratiu, Domenik Pavletic, Iris Groher, Jean Bezivin, Jos Warmer, Laurence Tratt, Mats Helander, Nora Ludewig, Se- bastian Zarnekow and Vaclav Pech. I also want to thank the contributors to the book. They have added valuable perspectives and insights that I couldn’t have delivered myself. In particular: • Eelco Visser contributed significantly to the DSL design sec- tion. In fact, this was the part we started out with when we still had the plan to write the book together. It was initially 10 dslbook.org his idea to have a section on DSL design that is independent of implementation concerns and particular tools. • Guido Wachsmuth and Lennart Kats contributed all the ex- amples for the Spoofax language workbench and helped a lot with the fundamental discussions on grammars and parsing. • Mats Helander contributed the Business DSL case study with the Intentional Domain Workbench in Part IV of the book. • Birgit Engelmann and Sebastian Benz wrote the chapter on utility DSLs that features the JNario language based on Xtext and Xbase. • Christian Dietrich helped me with the language modular- ization examples for Xtext and Xbase. Also, Moritz Eysholdt has contributed a section on his Xpext testing framework. Finally, some parts of this book are based on papers I wrote with other people. I want to thank these people for letting me use the papers in the book: Bernd Kolb, Domenik Pavletic, Daniel Ratiu and Bernhard Schaetz. A special thank you goes to my girlfriend Nora Ludewig. She didn’t just volunteer to provide feedback on the book, she also had to endure all kinds of other discussions around the topic all the time. Thanks Nora! Alex Chatziparaskewas, Henk Kolk, Magnus Christerson and Klaus Doerfler allowed me to use "their" applications as examples in this book. Thank you very much! I also want to thank itemis, for whom I have worked as an independent consultant for the last couple of years. The expe- rience I gained there, in particular while working with MPS in the LWES research project, benefitted the book greatly! Finally, I want to thank my copyeditor Steve Rickaby. I had worked with Steve on my pattern books and I really wanted to work with him again on this one – even though no publisher is involved this time. Luckily he was willing to work with me directly. Thank you, Steve! 1.2 This book is Donationware This book is available as a print version and as a PDF version. You are currently reading the PDF version. The print version dsl engineering 11 can be acquired Amazon. The specific links are available at http://dslbook.org. This book is not free even though you can download it from Donations are much simpler than http://dslbook.org without paying for it. I ask you to please paying for the book at the time when when you get it: you can check out go to the website and donate some amount of money you deem the contents before you pay, you can appropriate for the value you take from the book. You should pay whatever you think makes sense for you, and we all don’t have to deal also register the book at the website, so I can keep you up-to- with DRM and chasing down "illegal date with new versions.
Recommended publications
  • How to Develop Your Own Dsls in Eclipse Using Xtend and Xtext ?
    How to develop your own DSLs in Eclipse using Xtend and Xtext ? Daniel Strmečki | Software Developer 19.05.2016. BUSINESS WEB APPLICATIONS HOW TO DEVELOP YOUR OWN DSLS IN ECLIPSE USING XTEXT AND XTEND? Content 1. DSLs › What are DSLs? › Kinds of DSLs? › Their usage and benefits… 2. Xtend › What kind of language is Xtend? › What are its benefits compared to classic Java? 3. Xtext › What is a language development framework? › How to develop you own DSL? 4. Short demo 5. Conclusion 2 | 19.05.2016. BUSINESS WEB APPLICATIONS | [email protected] | www.evolva.hr HOW TO DEVELOP YOUR OWN DSLS IN ECLIPSE USING XTEXT AND XTEND? DSL acronym Not in a Telecommunications context: Digital Subscriber Line But in a Software Engineering context: Domain Specific Languages 3 | 19.05.2016. BUSINESS WEB APPLICATIONS | [email protected] | www.evolva.hr HOW TO DEVELOP YOUR OWN DSLS IN ECLIPSE USING XTEXT AND XTEND? Domain Specific Languages General-Purpose Languages (GPLs) › Languages broadly applicable across application domains › Lack specialized features for a particular domain › XML, UML, Java , C++, Python, PHP… Domain specific languages (DSLs) › Languages tailored to for an application in a specific domain › Provide substantial gains in expressiveness and ease of use in their domain of application › SQL, HTML, CSS, Logo, Mathematica, Marcos, Regular expressions, Unix shell scripts, MediaWiki, LaTeX… 4 | 19.05.2016. BUSINESS WEB APPLICATIONS | [email protected] | www.evolva.hr HOW TO DEVELOP YOUR OWN DSLS IN ECLIPSE USING XTEXT AND XTEND? Domain Specific Languages A novelty in software development › DSL for programming numerically controlled machine tools, was developed in 1957–1958 › BNF dates back to 1959 (M.
    [Show full text]
  • Expressive and Efficient Model Transformation with an Internal DSL
    Expressive and Efficient Model Transformation with an Internal DSL of Xtend Artur Boronat Department of Informatics, University of Leicester, UK [email protected] ABSTRACT 1 INTRODUCTION Model transformation (MT) of very large models (VLMs), with mil- Over the past decade the application of MDE technology in indus- lions of elements, is a challenging cornerstone for applying Model- try has led to the emergence of very large models (VLMs), with Driven Engineering (MDE) technology in industry. Recent research millions of elements, that may need to be updated using model efforts that tackle this problem have been directed at distributing transformation (MT). This situation is characterized by important MT on the Cloud, either directly, by managing clusters explicitly, or challenges [26], starting from model persistence using XMI serial- indirectly, via external NoSQL data stores. In this paper, we draw at- ization with the Eclipse Modeling Framework (EMF) [31] to scalable tention back to improving efficiency of model transformations that approaches to apply model updates. use EMF natively and that run on non-distributed environments, An important research effort to tackle these challenges was showing that substantial performance gains can still be reaped on performed in the European project MONDO [19] by scaling out that ground. efficient model query and MT engines, such as VIATRA[3] and We present Yet Another Model Transformation Language (YAMTL), ATL/EMFTVM [46], building on Cloud technology either directly, a new internal domain-specific language (DSL) of Xtend for defin- by using distributed clusters of servers explicitly, or indirectly, by ing declarative MT, and its execution engine.
    [Show full text]
  • On Modularity and Performances of External Domain-Specific Language Implementations Manuel Leduc
    On modularity and performances of external domain-specific language implementations Manuel Leduc To cite this version: Manuel Leduc. On modularity and performances of external domain-specific language implementa- tions. Software Engineering [cs.SE]. Université Rennes 1, 2019. English. NNT : 2019REN1S112. tel-02972666 HAL Id: tel-02972666 https://tel.archives-ouvertes.fr/tel-02972666 Submitted on 20 Oct 2020 HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés. THÈSE DE DOCTORAT DE L’UNIVERSITE DE RENNES 1 COMUE UNIVERSITE BRETAGNE LOIRE Ecole Doctorale N°601 Mathèmatique et Sciences et Technologies de l’Information et de la Communication Spécialité : Informatique Par Manuel LEDUC On modularity and performance of External Domain-Specific Language im- plementations Thèse présentée et soutenue à RENNES , le 18 Décembre 2019 Unité de recherche : Equipe DiverSE, IRISA Rapporteurs avant soutenance : Paul Klint, Professeur, CWI, Amsterdam, Pays-Bas Juan De Lara, Professeur, Université autonome de Madrid, Madrid, Espagne Composition du jury : Président : Olivier Ridoux, Professeur, Université de Rennes 1, Rennes, France Examinateurs : Nelly Bencomo, Lecturer in Computer Science, Aston University, Birmingham, Royaume-Uni Jean-Remy Falleri, Maître de conférences HDR, Université de Bordeaux, Bordeaux, France Gurvan Le Guernic, Ingénieur de recherche, DGA, Rennes, France Dir.
    [Show full text]
  • Open Source and Third Party Documentation
    Open Source and Third Party Documentation Verint.com Twitter.com/verint Facebook.com/verint Blog.verint.com Content Introduction.....................2 Licenses..........................3 Page 1 Open Source Attribution Certain components of this Software or software contained in this Product (collectively, "Software") may be covered by so-called "free or open source" software licenses ("Open Source Components"), which includes any software licenses approved as open source licenses by the Open Source Initiative or any similar licenses, including without limitation any license that, as a condition of distribution of the Open Source Components licensed, requires that the distributor make the Open Source Components available in source code format. A license in each Open Source Component is provided to you in accordance with the specific license terms specified in their respective license terms. EXCEPT WITH REGARD TO ANY WARRANTIES OR OTHER RIGHTS AND OBLIGATIONS EXPRESSLY PROVIDED DIRECTLY TO YOU FROM VERINT, ALL OPEN SOURCE COMPONENTS ARE PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. Any third party technology that may be appropriate or necessary for use with the Verint Product is licensed to you only for use with the Verint Product under the terms of the third party license agreement specified in the Documentation, the Software or as provided online at http://verint.com/thirdpartylicense. You may not take any action that would separate the third party technology from the Verint Product. Unless otherwise permitted under the terms of the third party license agreement, you agree to only use the third party technology in conjunction with the Verint Product.
    [Show full text]
  • Handcrafting a Triple Graph Transformation System to Realize Round-Trip Engineering Between UML Class Models and Java Source Code
    Handcrafting a Triple Graph Transformation System to Realize Round-trip Engineering Between UML Class Models and Java Source Code Thomas Buchmann and Sandra Greiner Chair of Applied Computer Science I, University of Bayreuth, Universitätsstrasse 30, 95440, Bayreuth, Germany Keywords: Round-trip Engineering, Model-driven Development, Xtend, Triple Graph Transformation Systems. Abstract: Model transformations are a mandatory requirement for model-driven development, a software engineering discipline, which has become more and more popular during the last decade. Over the years, the concept of unidirectional model transformations and corresponding tool support reached maturity since these kind of transformations are widely used in model-driven engineering, mainly for forward engineering and code generation. In incremental and iterative software engineering processes, forward engineering may be too restrictive since it resembles waterfall-like processes. Thus, bidirectional transformations are required, which aim to provide support for (incrementally) transforming one or more source model to one or more target model and vice versa from only one transformation description. However, they seem to be rarely used in model- driven software development as adequate tool support is missing. On the other hand, programming languages nowadays provide support for higher-level features like closures or lambda expressions which allow to describe transformation patterns in a declarative way. In this paper, we present an approach for round-trip engineering between UML class models and Java source code, which is realized with a triple graph transformation system written in the Xtend programming language. 1 INTRODUCTION and accompanying tools have emerged (Czarnecki and Helsen, 2006). We observe tools, which sup- During the last few years, model-driven software en- port unidirectional batch transformations, e.g.
    [Show full text]
  • Xtend Programming Language Agenda
    Agile Software Development Produced Eamonn de Leastar ([email protected]) by Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie Xtend Programming Language Agenda • Subtitle 3 4 Features (1) • Extension methods - enhance closed types with new functionality • Lambda Expressions - concise syntax for anonymous function literals • ActiveAnnotations - annotation processing on steroids • Operator overloading - make your libraries even more expressive • Powerful switch expressions - type based switching with implicit casts • Multiple dispatch - a.k.a. polymorphic method invocation 5 Features (2) • Template expressions - with intelligent white space handling • No statements - everything is an expression • Properties - shorthands for accessing and defining getters and setter • Type inference - you rarely need to write down type signatures anymore • Full support for Java generics - including all conformance and conversion rules • Translates to Java not bytecode - understand what is going on and use your code for platforms such as Android or GWT 6 Hello World xtend java class HelloWorld public class HelloWorld { { def static void main(String[] args) public static void main(String[] args) { { println("Hello World") System.out.println("Hello World"); } } } } 7 Selected Key Features • Java Interoperability • Expressions • Annotations • Type Inference • Literals • @Data • Conversion Rules • Casts • Classes • Field access & method invocation • Constructors • Constructor call • Fields • Lambda Expressions • Methods • If expression • Override • switch Expression • Inferred return types • return expression 8 Java Interoperability 9 Type inference • Xtend, like Java, is a statically typed language. • It completely supports Java's type system, including the primitive types like int or boolean, arrays and all the Java classes, interfaces, enums and annotations that reside on the class path.
    [Show full text]
  • Xtext User Guide
    Xtext User Guide Xtext User Guide Heiko Behrens, Michael Clay, Sven Efftinge, Moritz Eysholdt, Peter Friese, Jan Köhnlein, Knut Wannheden, Sebastian Zarnekow and contributors Copyright 2008 - 2010 Xtext 1.0 1 1. Overview .................................................................................................................... 1 1.1. What is Xtext? ................................................................................................... 1 1.2. How Does It Work? ............................................................................................ 1 1.3. Xtext is Highly Configurable ................................................................................ 1 1.4. Who Uses Xtext? ................................................................................................ 1 1.5. Who is Behind Xtext? ......................................................................................... 1 1.6. What is a Domain-Specific Language ..................................................................... 2 2. Getting Started ............................................................................................................ 3 2.1. Creating a DSL .................................................................................................. 3 2.1.1. Create an Xtext Project ............................................................................. 3 2.1.2. Project Layout ......................................................................................... 4 2.1.3. Build Your Own Grammar ........................................................................
    [Show full text]
  • Type Errors for the IDE with Xtext and Xsemantics Perience and Contributes to the Adoption of That Language
    Open Comput. Sci. 2019; 9:52–79 Research Article Open Access Lorenzo Bettini* Type errors for the IDE with Xtext and Xsemantics https://doi.org/10.1515/comp-2019-0003 perience and contributes to the adoption of that language. Received June 29, 2018; accepted February 11, 2019 However, developing a compiler and an IDE for a language from scratch is usually time consuming. Language work- Abstract: Providing IDE support for a programming lan- benches, a term coined by Martin Fowler in 2005 [1], are guage or a DSL (Domain Specific Language) helps the users software development tools designed to easily implement of the language to be more productive and to have an im- languages together with their IDE support. Xtext [2] is one mediate feedback on possible errors in a program. Static of the most popular language workbench. Starting from a types can drive IDE mechanisms such as the content as- grammar definition Xtext generates a parser, an abstract sist to propose sensible completions in a given program syntax tree (AST), and typical IDE mechanisms. While the context. Types can also be used to enrich other typical IDE main target of Xtext is Eclipse, a language developed with parts such as the Outline and the Hovering pop-ups. In this Xtext can be easily ported to other IDEs and editors. Xtext paper, we focus on statically typed imperative languages, comes with good defaults for all the above artifacts, di- adopting some form of type inference. We present a few rectly inferred from the grammar definition, and the lan- general patterns for implementing efficient type systems, guage developer can easily customize them all.
    [Show full text]
  • Script Alapú Járműbusz-Szimuláció
    SZAKDOLGOZAT-FELADAT Sándi Tamás (SMNQCY) szigorló villamosmérnök hallgató részére Script alapú járműbusz-szimuláció Napjaink prémium kategóriás személyautóinak működésében közel száz elektronikus vezérlőegység (ECU) játszik szerepet. Ezek között a kommunikáció szabványos autóipari protokollokon zajlik (CAN, FlexRay, LIN). Az így kapott összetett elosztott rendszer fejlesztésének elengedhetetlen részét képezi a vezérlőegységek kimerítő tesztelése. A tesztelés során a tesztelendő alkatrész által elvárt kommunikációs jeleket szimuláljuk. A tesztszekvenciák előállítására rendelkezésre áll a vállalatnál egy saját fejlesztésű kommunikációs eszköz (Gateway). Az eszköz számos szolgáltatást nyújt a felhasználó felé (CAN, FlexRay és LIN kommunikációs csatornák, valamint GPIO és A/D portok). A hallgató feladata egy olyan Eclipse alapú szoftvereszköz elkészítése, melynek segítségével a felhasználó egy erre a célra definiált szkriptnyelvben fogalmazhatja meg a Gateway által szimulálandó bonyolult kommunikációs szekvenciákat. Az eszköznek képesnek kell lennie továbbá az elkészített szkript alapján a Gatewayen futtatható kód generálására, valamint a hardverre való letöltése után annak futtatására is. A hallgató feladatának a következőkre kell kiterjednie: • Gyűjtse össze a gyakori használati eseteket (use case analízis), majd ezek alapján definiáljon egy kényelmesen használható domainspecifikus nyelvet a felmerülő igények kielégítésére. A szkriptnek lehetőséget kell nyújtania eseményvezérelt szekvenciák megfogalmazására is (pl.: üzenetek megérkezésére,
    [Show full text]
  • Xtend User Guide
    Xtend User Guide September 10, 2014 Contents I. Getting Started 5 1. Introduction 6 2. Hello World 7 3. The Movies Example 9 3.1. The Data . .9 3.2. Parsing The Data . 10 3.3. Answering Some Questions . 11 3.3.1. Question 1 : What Is The Number Of Action Movies? . 11 3.3.2. Question 2 : What Is The Year The Best Movie From The 80's Was Released? . 12 3.3.3. Question 3 : What Is The The Sum Of All Votes Of The Top Two Movies?................................. 13 II. Reference Documentation 14 4. Java Interoperability 15 4.1. Type Inference . 15 4.2. Conversion Rules . 15 4.3. Interoperability with Java . 16 5. Classes and Members 17 5.1. Package Declaration . 17 5.2. Imports . 17 5.3. Class Declaration . 18 5.4. Constructors . 19 5.5. Fields . 19 5.6. Methods . 20 5.6.1. Abstract Methods . 20 5.6.2. Overriding Methods . 21 5.6.3. Declared Exceptions . 21 5.6.4. Inferred Return Types . 21 5.6.5. Generic Methods . 22 2 5.6.6. Operator Declarations . 22 5.6.7. Dispatch Methods . 23 5.6.8. Create Methods . 26 5.7. Annotations . 28 5.8. Extension Methods . 29 5.8.1. Extensions from the Library . 29 5.8.2. Local Extension Methods . 30 5.8.3. Extension Imports . 30 5.8.4. Extension Provider . 31 5.9. Interface Declaration . 32 5.10. Annotation Type Declaration . 32 5.11. Enum Type Declaration . 32 5.12. Nested Type Declarations . 32 6. Expressions 34 6.1.
    [Show full text]
  • Xtext Documentation.Pdf
    Xtext Documentation September 26, 2014 Contents I. Getting Started 9 1. 5 Minutes Tutorial 10 1.1. Creating A New Xtext Project . 10 1.2. Generating The Language Infrastructure . 10 1.3. Try The Editor . 11 1.4. Conclusion . 12 2. 15 Minutes Tutorial 14 2.1. Create A New Xtext Project . 14 2.2. Write Your Own Grammar . 16 2.3. Generate Language Artifacts . 19 2.4. Run the Generated IDE Plug-in . 20 2.5. Second Iteration: Adding Packages and Imports . 20 3. 15 Minutes Tutorial - Extended 27 3.1. Writing a Code Generator With Xtend . 29 3.2. Unit Testing the Language . 34 3.3. Creating Custom Validation Rules . 35 4. Five simple steps to your JVM language 37 4.1. Step One: Create A New Xtext Project . 38 4.2. Step Two: Write the Grammar . 38 4.3. Step Three: Generate Language Artifacts . 43 4.4. Step Four: Define the Mapping to JVM Concepts . 43 4.5. Step Five : Try the Editor! . 48 II. Seven JVM Languages Built With Xbase 50 5. Introduction 51 5.1. Write the Grammar . 51 5.2. Map to Java . 51 5.3. CAUTION: This is Provisional API . 52 5.4. Common Requirements . 52 5.5. Getting the Code . 53 2 5.6. A Short Xtend Primer . 53 6. Scripting Language 57 6.1. Overview . 57 6.2. Running the Example . 58 6.3. Grammar . 58 6.4. Translation to Java . 59 7. Build Language 61 7.1. Overview . 61 7.2. Running the Example . 62 7.3. Grammar . 62 7.4.
    [Show full text]
  • Kotlin Срещу Scala – Сравнителен Анализ
    Computer and communications engineering, Vol. 14, No. 1/2020 Kotlin срещу Scala – сравнителен анализ Петко Данов Резюме: Представен само преди няколко години, Kotlin е един от многото езици, които използват виртуалната машина на Java, но в този кратък период придобива популярност. Scala е чист обектно-ориентиран език за програмиране, обединяващ в себе си предимствата на високо мащабируемите функционални езици за програмиране. Целта на настоящия документ е да сравни структурно двата езика и да идентифицира предимствата и недостатъците на всеки от тях. Ключови думи: Котлин, Скала, Програмни езици Kotlin vs Scala – а comparative study Petko Danov Abstract: Introduced just a few years ago, Kotlin is one of many languages that use the Java virtual machine, but it is gaining popularity in this short period. Scala is a pure object-oriented programming language that combines the advantages of highly scalable functional programming languages. The purpose of this paper is to compare the two languages structurally and to identify the advantages and disadvantages of each. Key words: Kotlin; Scala; Programming languages. 1. INTRODUCTION component-based applications [4]. Scala uses the so- called "actor model" to maintain modern parallelism. The development of the Kotlin programming This programming language also supports the so- language was started in 2010 by Jet Brains. The first called "lazy evaluation". With the inclusion of macros, stable version was released in February 2016, and in Scala is also distinguished by the creation of complex May 2017, Google included Kotlin in Android Studio internal domain-specific DSL languages. Scala also 3.0. Although it uses a JVM, it can also be compiled supports first-order operations and allows the use of into JavaScript and machine code [1].
    [Show full text]