Implementing Domain-Specific Languages with Xtext and Xtend - Second Edition
eBook - ePub

Implementing Domain-Specific Languages with Xtext and Xtend - Second Edition

Lorenzo Bettini

  1. 426 páginas
  2. English
  3. ePUB (apto para móviles)
  4. Disponible en iOS y Android
eBook - ePub

Implementing Domain-Specific Languages with Xtext and Xtend - Second Edition

Lorenzo Bettini

Detalles del libro
Vista previa del libro

Información del libro

Learn how to implement a DSL with Xtext and Xtend using easy-to-understand examples and best practicesAbout This Book• Leverage the latest features of Xtext and Xtend to develop a domain-specific language.• Integrate Xtext with popular third party IDEs and get the best out of both worlds.• Discover how to test a DSL implementation and how to customize runtime and IDE aspects of the DSLWho This Book Is ForThis book is targeted at programmers and developers who want to create a domain-specific language with Xtext. They should have a basic familiarity with Eclipse and its functionality. Previous experience with compiler implementation can be helpful but is not necessary since this book will explain all the development stages of a DSL.What You Will Learn• Write Xtext grammar for a DSL;• Use Xtend as an alternative to Java to write cleaner, easier-to-read, and more maintainable code;• Build your Xtext DSLs easily with Maven/Tycho and Gradle;• Write a code generator and an interpreter for a DSL;• Explore the Xtext scoping mechanism for symbol resolution;• Test most aspects of the DSL implementation with JUnit;• Understand best practices in DSL implementations with Xtext and Xtend;• Develop your Xtext DSLs using Continuous Integration mechanisms;• Use an Xtext editor in a web applicationIn DetailXtext is an open source Eclipse framework for implementing domain-specific languages together with IDE functionalities. It lets you implement languages really quickly; most of all, it covers all aspects of a complete language infrastructure, including the parser, code generator, interpreter, and more.This book will enable you to implement Domain Specific Languages (DSL) efficiently, together with their IDE tooling, with Xtext and Xtend. Opening with brief coverage of Xtext features involved in DSL implementation, including integration in an IDE, the book will then introduce you to Xtend as this language will be used in all the examples throughout the book. You will then explore the typical programming development workflow with Xtext when we modify the grammar of the DSL.Further, the Xtend programming language (a fully-featured Java-like language tightly integrated with Java) will be introduced. We then explain the main concepts of Xtext, such as validation, code generation, and customizations of runtime and UI aspects. You will have learned how to test a DSL implemented in Xtext with JUnit and will progress to advanced concepts such as type checking and scoping. You will then integrate the typical Continuous Integration systems built in to Xtext DSLs and familiarize yourself with Xbase. By the end of the book, you will manually maintain the EMF model for an Xtext DSL and will see how an Xtext DSL can also be used in IntelliJ.Style and approach A step-by step-tutorial with illustrative examples that will let you master using Xtext and implementing DSLs with its custom language, Xtend.

Preguntas frecuentes

¿Cómo cancelo mi suscripción?
Simplemente, dirígete a la sección ajustes de la cuenta y haz clic en «Cancelar suscripción». Así de sencillo. Después de cancelar tu suscripción, esta permanecerá activa el tiempo restante que hayas pagado. Obtén más información aquí.
¿Cómo descargo los libros?
Por el momento, todos nuestros libros ePub adaptables a dispositivos móviles se pueden descargar a través de la aplicación. La mayor parte de nuestros PDF también se puede descargar y ya estamos trabajando para que el resto también sea descargable. Obtén más información aquí.
¿En qué se diferencian los planes de precios?
Ambos planes te permiten acceder por completo a la biblioteca y a todas las funciones de Perlego. Las únicas diferencias son el precio y el período de suscripción: con el plan anual ahorrarás en torno a un 30 % en comparación con 12 meses de un plan mensual.
¿Qué es Perlego?
Somos un servicio de suscripción de libros de texto en línea que te permite acceder a toda una biblioteca en línea por menos de lo que cuesta un libro al mes. Con más de un millón de libros sobre más de 1000 categorías, ¡tenemos todo lo que necesitas! Obtén más información aquí.
¿Perlego ofrece la función de texto a voz?
Busca el símbolo de lectura en voz alta en tu próximo libro para ver si puedes escucharlo. La herramienta de lectura en voz alta lee el texto en voz alta por ti, resaltando el texto a medida que se lee. Puedes pausarla, acelerarla y ralentizarla. Obtén más información aquí.
¿Es Implementing Domain-Specific Languages with Xtext and Xtend - Second Edition un PDF/ePUB en línea?
Sí, puedes acceder a Implementing Domain-Specific Languages with Xtext and Xtend - Second Edition de Lorenzo Bettini en formato PDF o ePUB, así como a otros libros populares de Informatique y Programmation. Tenemos más de un millón de libros disponibles en nuestro catálogo para que explores.



Implementing Domain-Specific Languages with Xtext and Xtend - Second Edition

Table of Contents

Implementing Domain-Specific Languages with Xtext and Xtend - Second Edition
About the Author
About the Reviewer
eBooks, discount offers, and more
Why subscribe?
What this book covers
What you need for this book
Who this book is for
Reader feedback
Customer support
Downloading the example code
Preface to the second edition
1. Implementing a DSL
Domain-Specific Languages
Need for a new language
Implementing a DSL
The Abstract Syntax Tree (AST)
IDE integration
Syntax highlighting
Background validation
Error markers
Content assist
Automatic build
Summarizing DSL implementation
Enter Xtext
Installing Xtext
Let's try Xtext
The aim of this book
2. Creating Your First Xtext Language
A DSL for entities
Creating the project
Xtext projects
Modifying the grammar
Let's try the Editor
The Xtext generator
The Eclipse Modeling Framework (EMF)
Improvements to the DSL
Dealing with types
3. Working with the Xtend Programming Language
An introduction to Xtend
Using Xtend in your projects
Xtend – a better Java with less "noise"
Fields and Variables
Syntactic sugar
Static members and inner types
Extension methods
The implicit variable – it
Lambda expressions
Multi-line template expressions
Additional operators
Polymorphic method invocation
Enhanced switch expressions
Other Xtend expressions
Xtend IDE
Debugging Xtend code
4. Validation
Validation in Xtext
Default validators
Custom validators
Textual modification
Model modification
Quickfixes for default validators
5. Code Generation
Introduction to code generation
Writing a code generator in Xtend
Integration with the Eclipse build mechanism
Standalone command-line compiler
6. Customizing Xtext Components
Dependency injection
Google Guice in Xtext
Customizations of IDE concepts
The Outline view
Customizing other aspects
Custom formatting
Other customizations
7. Testing
Introduction to testing
JUnit 4
The ISetup interface
Implementing tests for your DSL
Testing the parser
Testing the validator
Testing the formatter
Testing code generation
Test suite
Testing the UI
Testing the content assist
Testing workbench integration
Testing the editor
Learning Tests
Testing the outline
Other testing frameworks
Testing and modularity
Clean code
8. An Expression Language
The Expressions DSL
Creating the project
Digression on Xtext grammar rules
The grammar for the Expressions DSL
Left recursive grammars
The complete grammar
Forward references
Custom Content Assist
Typing expressions
Loose type computation, strict type checking
Type computer
Writing an interpreter
Using the interpreter
Optimizations and fine tuning
9. Type Checking
Creating the project
SmallJava grammar
Rules for declarations
Rules for statements and syntactic predicates
Rules for expressions
Rule fragments
The complete grammar
Utility methods
Testing the grammar
First validation rules
Checking cycles in class hierarchies
Checking member selections
Checking return statements
Checking for duplicates
Type checking
Type computer for SmallJava
Type conformance (subtyping)
Expected types
Checking type conformance
Checking method overriding
Improving the UI
10. Scoping
Cross-reference resolution in Xtext
Containments and cross-references
The index
Qualified names
Exported objects
The linker and the scope provider
Component interaction
Custom scoping
Scope for blocks
Scope for inheritance and member visibility
Visibility and accessibility
Filtering unwanted objects from the scope
Global scoping
Packages and imports
The index and the containers
Checking duplicates across files
Providing a library
Default imports
Using the library outside Eclipse
Using the library in the type system and scoping
Classes of the same package
Dealing with super
What to put in the index?
Additional automatic features
Providing a project wizard
11. Continuous Integration
Eclipse features and p2 repositories
Release engineering
Headless builds
Target platforms
Continuous integration
Introduction to Maven/Tycho
Using the Xtext project wizard
Running the Maven build
Customizing the feature
Using and customizing the target platform
Customizing the pom files
Continuous Integration systems
Maintaining the examples of this book
Your DSL editor on the Web
IntelliJ and Gradle
Pitfalls with Maven/Tycho
PDE test problems
Concluding remarks
Installation requirements
Make contributions easy
12. Xbase
Introduction to Xbase
The common Java type model
The Expressions DSL with Xbase
Creating the project
The IJvmModelInferrer interface
Code generation
The Entities DSL with Xbase
Creating the project
Defining attributes
Defining operations
Additional Xbase features
Reusing Java error markers
Using 'extension'
Using type parameters
Further Customizations
13. Advanced Topics
Creating an Xtext project from an Ecore model
Defining the Ecore model
Creating the Xtext project
Fixing the StandaloneSetup
Tweaking the Ecore model
Derived State
Adding new rules to the language
Switching to an imported Ecore model
Generating EMF classes during the build
Customizing the EMF Java classes
Creating the Xcore project
Creating the Xtext project from an existing Xcore model
Modifying the Xcore model
Extending Xbase
Overriding a rule in an Xtext grammar
Customizing the type system
Testing the type computer
Customizing the validator
Customizing the compiler
Using the type system in the compiler
Testing the compiled code
Improving code generation
Smoke tests
14. ...


  1. Implementing Domain-Specific Languages with Xtext and Xtend - Second Edition
Estilos de citas para Implementing Domain-Specific Languages with Xtext and Xtend - Second Edition

APA 6 Citation

Bettini, L. (2016). Implementing Domain-Specific Languages with Xtext and Xtend - Second Edition (2nd ed.). Packt Publishing. Retrieved from (Original work published 2016)

Chicago Citation

Bettini, Lorenzo. (2016) 2016. Implementing Domain-Specific Languages with Xtext and Xtend - Second Edition. 2nd ed. Packt Publishing.

Harvard Citation

Bettini, L. (2016) Implementing Domain-Specific Languages with Xtext and Xtend - Second Edition. 2nd edn. Packt Publishing. Available at: (Accessed: 14 October 2022).

MLA 7 Citation

Bettini, Lorenzo. Implementing Domain-Specific Languages with Xtext and Xtend - Second Edition. 2nd ed. Packt Publishing, 2016. Web. 14 Oct. 2022.