SlideShare a Scribd company logo
©2016 GlobalLogic Inc.
Build your own DSL with Xtext
2
About me - Tomasz Kleszczyński
• Software Engineer @ REC - a
GlobalLogic Company
• Focused in JVM technologies
– Java EE
– Eclipse RCP
• Interested in software architecture
• tomasz.kleszczynski@globallogic.com
3
Agenda
• Introduction of DSL
• Eclipse Modelling Framework
• Xtext
• Demos
• What’s new in Xtext 2.9
4
Introduction of DSL
• What is a Domain-Specific Language?
• Internal or external?
• Is it difficult to build one?
• Examples:
– SQL
– Css (LESS / SASS)
– MATLAB
YourOwn
select * from Named n where n.name =
”foo*” and n.used order by n.name desc
5
Eclipse Modelling Framework
EMF Components
• Core Runtime
– Ecore metamodel
– Notification framework
– Persistence (XML/XMI), validation, change model
• EMF.Edit
– Support for model-based editors and viewers
– Default reflective editor
• Codegen
– Code generator for application models and editors
– Extensible model importer / exporter framework
6
• Eclipse project – EPL license
– Uses ANTLR3, EMF, Google Guice
• Language development framework
– Set of DSLs and API to describe the different aspects
of programming language
– Compiler components independent of Eclipse or
OSGi:
• parser
• type-safe abstract syntax tree (AST)
• serializer
• code formatter
• scoping framework
• linking
– IDE components
• Eclipse
• IntelliJ IDEA
– Translation to Java using XBase
7
Grammar
• Language Declaration
• EPackage Declaration
– EPackage Generation
– EPackage Import
• Rules
– Terminal Rules
– Parser Rules
– Hidden Terminal Symbols
– Data type Rules
– Enum Rules
• Ecore Model Inference
– Epackage
– EClass
– EEnum
– EStructuralFeature
8
Demo
All demos are based on Xtext 2.9.2
• Formatting
• Generation
• Scoping
• Validation
• Content assist
• Labels / outline
• Quick fix
• Web editor
9
Xtext 2.9 - What’s new
• IntelliJ IDEA As An Alternative To Eclipse
– Language Editors for IntelliJ IDEA
• Headless Builds For Xtext Projects
– Gradle / Maven
– Target selection (Eclipse, IntelliJ IDEA, web)
• New Project Wizard
• Web Support
• New Grammar Language Features
– Explicit rule calls and super rule calls
– Parser rule fragments
10
Q & A
11
References
• EMF Fundamentals
• www.eclipse.org/Xtext
• zarnekow.blogspot.de
• blog.efftinge.de
• Scoping and linking
Examples:
• github.com/tkleszczynski/xtext-jug.git
12
Thank you

More Related Content

PDF
Code Generation idioms with Xtend
PDF
Dependency Management in a Complex World (JConf Chicago 2022)
PPTX
Agile Software Development Overview
PDF
Agile methodology
PDF
Introduzione a Docker (Maggio 2017) [ITA]
PDF
Equivalences and diffrences between SysML and Arcadia / Capella
PDF
Google Cloud Platform Solutions for DevOps Engineers
Code Generation idioms with Xtend
Dependency Management in a Complex World (JConf Chicago 2022)
Agile Software Development Overview
Agile methodology
Introduzione a Docker (Maggio 2017) [ITA]
Equivalences and diffrences between SysML and Arcadia / Capella
Google Cloud Platform Solutions for DevOps Engineers

What's hot (20)

PPT
Agile Software Development Overview
PDF
OpenStack DevStack Install - 1부 (All-in-one)
PDF
Cloud-Native CI/CD on Kubernetes with Tekton Pipelines
PPTX
An intro to building an architecture repository meta model and modeling frame...
PPTX
Feature driven development (FDD)
PPT
Effective Software Release Management
PDF
Continuous Integration With Jenkins
PPTX
Agile Methodology (scrum)
PDF
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCD
PDF
Ansible Tower
PPTX
What is DevOps? | DevOps Introduction | DevOps Tools | DevOps Tutorial For Be...
PPT
Architectural design
PPT
Scrum retrospective
PDF
Delivering Quality at Speed with GitOps
PDF
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
PPTX
Introduction to Agile Software Development
PPTX
Azure Pipelines
PDF
What is DevOps | DevOps Introduction | DevOps Training | DevOps Tutorial | Ed...
PDF
Git flow
PPT
Trabajo metodologia scrum
Agile Software Development Overview
OpenStack DevStack Install - 1부 (All-in-one)
Cloud-Native CI/CD on Kubernetes with Tekton Pipelines
An intro to building an architecture repository meta model and modeling frame...
Feature driven development (FDD)
Effective Software Release Management
Continuous Integration With Jenkins
Agile Methodology (scrum)
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCD
Ansible Tower
What is DevOps? | DevOps Introduction | DevOps Tools | DevOps Tutorial For Be...
Architectural design
Scrum retrospective
Delivering Quality at Speed with GitOps
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
Introduction to Agile Software Development
Azure Pipelines
What is DevOps | DevOps Introduction | DevOps Training | DevOps Tutorial | Ed...
Git flow
Trabajo metodologia scrum
Ad

Similar to Building Your Own DSL with Xtext (20)

PPTX
Creating a textual domain specific language
PPTX
Domain specific languages in eclipse with Xtext (Zeus, UGent)
PPTX
Xbase implementing specific domain language for java
PDF
Markus Voelter Textual DSLs
PDF
Compiler Construction | Lecture 17 | Beyond Compiler Construction
PDF
Xtext project and PhDs in Gemany
PDF
Xtext: writing a grammar
PPTX
Introduction To MDD
KEY
Developing a Clojure IDE with Xtext
PPT
ITU - MDD - XText
PDF
Language Engineering With Xtext
PDF
Programming Languages #devcon2013
PPT
ITU - MDD - Textural Languages and Grammars
PPTX
Scam 08
PDF
DSLs in JavaScript
PDF
Zoo of domain-specific languages
PPTX
Enhancing Xtext for General Purpose Languages
PDF
DSL and EMFText
PDF
Metamorphic Domain-Specific Languages
PDF
Building DSLs: Marriage of High Essence and Groovy Metaprogramming
Creating a textual domain specific language
Domain specific languages in eclipse with Xtext (Zeus, UGent)
Xbase implementing specific domain language for java
Markus Voelter Textual DSLs
Compiler Construction | Lecture 17 | Beyond Compiler Construction
Xtext project and PhDs in Gemany
Xtext: writing a grammar
Introduction To MDD
Developing a Clojure IDE with Xtext
ITU - MDD - XText
Language Engineering With Xtext
Programming Languages #devcon2013
ITU - MDD - Textural Languages and Grammars
Scam 08
DSLs in JavaScript
Zoo of domain-specific languages
Enhancing Xtext for General Purpose Languages
DSL and EMFText
Metamorphic Domain-Specific Languages
Building DSLs: Marriage of High Essence and Groovy Metaprogramming
Ad

More from GlobalLogic Ukraine (20)

PDF
GlobalLogic JavaScript Community Webinar #21 “Інтерв’ю без заспокійливих”
PPTX
Deadlocks in SQL - Turning Fear Into Understanding (by Sergii Stets)
PDF
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
PDF
GlobalLogic Embedded Community x ROS Ukraine Webinar "Surgical Robots"
PDF
GlobalLogic Java Community Webinar #17 “SpringJDBC vs JDBC. Is Spring a Hero?”
PDF
GlobalLogic JavaScript Community Webinar #18 “Long Story Short: OSI Model”
PPTX
Штучний інтелект як допомога в навчанні, а не замінник.pptx
PPTX
Задачі AI-розробника як застосовується штучний інтелект.pptx
PPTX
Що треба вивчати, щоб стати розробником штучного інтелекту та нейромереж.pptx
PDF
GlobalLogic Java Community Webinar #16 “Zaloni’s Architecture for Data-Driven...
PDF
JavaScript Community Webinar #14 "Why Is Git Rebase?"
PDF
GlobalLogic .NET Community Webinar #3 "Exploring Serverless with Azure Functi...
PPTX
Страх і сила помилок - IT Inside від GlobalLogic Education
PDF
GlobalLogic .NET Webinar #2 “Azure RBAC and Managed Identity”
PDF
GlobalLogic QA Webinar “What does it take to become a Test Engineer”
PDF
“How to Secure Your Applications With a Keycloak?
PDF
GlobalLogic Machine Learning Webinar “Advanced Statistical Methods for Linear...
PPTX
GlobalLogic Machine Learning Webinar “Statistical learning of linear regressi...
PDF
GlobalLogic C++ Webinar “The Minimum Knowledge to Become a C++ Developer”
PDF
Embedded Webinar #17 "Low-level Network Testing in Embedded Devices Development"
GlobalLogic JavaScript Community Webinar #21 “Інтерв’ю без заспокійливих”
Deadlocks in SQL - Turning Fear Into Understanding (by Sergii Stets)
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Embedded Community x ROS Ukraine Webinar "Surgical Robots"
GlobalLogic Java Community Webinar #17 “SpringJDBC vs JDBC. Is Spring a Hero?”
GlobalLogic JavaScript Community Webinar #18 “Long Story Short: OSI Model”
Штучний інтелект як допомога в навчанні, а не замінник.pptx
Задачі AI-розробника як застосовується штучний інтелект.pptx
Що треба вивчати, щоб стати розробником штучного інтелекту та нейромереж.pptx
GlobalLogic Java Community Webinar #16 “Zaloni’s Architecture for Data-Driven...
JavaScript Community Webinar #14 "Why Is Git Rebase?"
GlobalLogic .NET Community Webinar #3 "Exploring Serverless with Azure Functi...
Страх і сила помилок - IT Inside від GlobalLogic Education
GlobalLogic .NET Webinar #2 “Azure RBAC and Managed Identity”
GlobalLogic QA Webinar “What does it take to become a Test Engineer”
“How to Secure Your Applications With a Keycloak?
GlobalLogic Machine Learning Webinar “Advanced Statistical Methods for Linear...
GlobalLogic Machine Learning Webinar “Statistical learning of linear regressi...
GlobalLogic C++ Webinar “The Minimum Knowledge to Become a C++ Developer”
Embedded Webinar #17 "Low-level Network Testing in Embedded Devices Development"

Recently uploaded (20)

PDF
top salesforce developer skills in 2025.pdf
PPTX
ai tools demonstartion for schools and inter college
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Digital Strategies for Manufacturing Companies
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
history of c programming in notes for students .pptx
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
System and Network Administraation Chapter 3
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
top salesforce developer skills in 2025.pdf
ai tools demonstartion for schools and inter college
Understanding Forklifts - TECH EHS Solution
Wondershare Filmora 15 Crack With Activation Key [2025
How to Migrate SBCGlobal Email to Yahoo Easily
2025 Textile ERP Trends: SAP, Odoo & Oracle
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Navsoft: AI-Powered Business Solutions & Custom Software Development
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Design an Analysis of Algorithms I-SECS-1021-03
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Digital Strategies for Manufacturing Companies
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
history of c programming in notes for students .pptx
CHAPTER 2 - PM Management and IT Context
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Odoo Companies in India – Driving Business Transformation.pdf
System and Network Administraation Chapter 3
Internet Downloader Manager (IDM) Crack 6.42 Build 41

Building Your Own DSL with Xtext

  • 1. ©2016 GlobalLogic Inc. Build your own DSL with Xtext
  • 2. 2 About me - Tomasz Kleszczyński • Software Engineer @ REC - a GlobalLogic Company • Focused in JVM technologies – Java EE – Eclipse RCP • Interested in software architecture • tomasz.kleszczynski@globallogic.com
  • 3. 3 Agenda • Introduction of DSL • Eclipse Modelling Framework • Xtext • Demos • What’s new in Xtext 2.9
  • 4. 4 Introduction of DSL • What is a Domain-Specific Language? • Internal or external? • Is it difficult to build one? • Examples: – SQL – Css (LESS / SASS) – MATLAB YourOwn select * from Named n where n.name = ”foo*” and n.used order by n.name desc
  • 5. 5 Eclipse Modelling Framework EMF Components • Core Runtime – Ecore metamodel – Notification framework – Persistence (XML/XMI), validation, change model • EMF.Edit – Support for model-based editors and viewers – Default reflective editor • Codegen – Code generator for application models and editors – Extensible model importer / exporter framework
  • 6. 6 • Eclipse project – EPL license – Uses ANTLR3, EMF, Google Guice • Language development framework – Set of DSLs and API to describe the different aspects of programming language – Compiler components independent of Eclipse or OSGi: • parser • type-safe abstract syntax tree (AST) • serializer • code formatter • scoping framework • linking – IDE components • Eclipse • IntelliJ IDEA – Translation to Java using XBase
  • 7. 7 Grammar • Language Declaration • EPackage Declaration – EPackage Generation – EPackage Import • Rules – Terminal Rules – Parser Rules – Hidden Terminal Symbols – Data type Rules – Enum Rules • Ecore Model Inference – Epackage – EClass – EEnum – EStructuralFeature
  • 8. 8 Demo All demos are based on Xtext 2.9.2 • Formatting • Generation • Scoping • Validation • Content assist • Labels / outline • Quick fix • Web editor
  • 9. 9 Xtext 2.9 - What’s new • IntelliJ IDEA As An Alternative To Eclipse – Language Editors for IntelliJ IDEA • Headless Builds For Xtext Projects – Gradle / Maven – Target selection (Eclipse, IntelliJ IDEA, web) • New Project Wizard • Web Support • New Grammar Language Features – Explicit rule calls and super rule calls – Parser rule fragments
  • 11. 11 References • EMF Fundamentals • www.eclipse.org/Xtext • zarnekow.blogspot.de • blog.efftinge.de • Scoping and linking Examples: • github.com/tkleszczynski/xtext-jug.git

Editor's Notes

  • #4: Zaczynamy. Na poczatek któtkie wprowadzenie do języków dziedzinowych czyli skupiajcych się na specyficznym problemie. Zanim rozpocznę o Xtext wprowadzę czym jest EMF – framework używany przez Xtext Powiem w kilku słowach czym jest Xtext w kontekście tworzenia języka. Następnie kilka słów o gramatyce oraz Jak Xtext ma się do EMFa Potem przejdziemy do demonstracji podstawowych elementów Xtext-a (takich jak formatowanie, generowanie nowych artefaktów, scoping, walidacja, content assist czy quick-fix,) Na koniec powiem o nowościach w Xtext 2.9
  • #7: This is an Eclipse project conducted mainly by itemis, started about 2008. Current version is 2.9. 2.9 in was released Nov 16, 2015 and it covers some new areas which I will try to show you later on. Behind the xtext is an ANTLR3 (ANother Tool for Language Recognition) as parser generator, EMF as the foundation of the model classes and google guice for dependency injection. Xtext is a language development framework – you can pick only those elements you want. - Provides API for configuring and describing elements of DSL Xtext components are independent of Eclipse and OSGi In 2.9 this distinction is better visible as you can pick project facets (IntelliJ plugins, Web support, Testing support, maven / grable build system, source code layout) – in 2.8 this separation is achievable but needs to be done manually. What does it contain? Parser – translates the string input into EMF model Abstract syntax tree – represents elements of your DSL in form of a tree Serializer – writing your EMF model back to textual form Code formatter – rules for formatting Scoping framework and linking. Eclipse – mature IntelliJ IDEA – new features I’will not cover binding to Java using Xbase. In general it allows using syntax which is close to java in your grammars.
  • #8: Xtext grammar is defined using its DSL. This file is then used by generator to create all language artifacts. Xtext uses Antlr under the hood in order to do the pure parsing. This is basically a two step process: At first, the input sequence of characters is split into tokens (often referred to as terminals) by a component that is called the lexer. The second step is to process the resulting list of tokens. The actual parser is responsible for that stage. It will create the abstract syntax tree from the token stream. Lexing – terminal rules (be careful, overrides the other, can be validated) Parsing – generates AST items Parser rules (production rules) – generated EClass Data type rules – generates Java primitives - The parser will not create those on its own but rather pass the consumed tokens as a string to a value converter. The language developer is responsible for converting the string to a data type. Terminal rules - an return the very same things as data type rules can. That is, they yield Strings, ints or other primitives Doesn’t have look ahead but is more performant Order matters
  • #10: Release candidate http://download.eclipse.org/modeling/tmf/xtext/idea/2.9.2/updatePlugins.xml - It’s it possible to design languages entirely in IDEA - Languages developed in Eclipse can target all available platforms (Eclipse, IDEA, web). It doesn’t worh the outer way round as IDEA is not well suited for Eclipse Plug-in devlelopment. Eclipse support is not going to be dropped Builds with Maven / Gradle You can select the elements (language / editor / build system during project generation). Web editors can be generated New grammar features Explicit rule calls – allows to use rules definitions from parent grammars without the need for redefining Parser rule fragments – allows to reuse common parts of the grammar Parameterized rule calls – lack of documentation, don’t have an idea where it would help