Building Your Own DSL with Xtext
-
Upload
globallogic-ukraine -
Category
Software
-
view
813 -
download
2
Transcript of Building Your Own DSL with Xtext
©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
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 FrameworkEMF 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
DemoAll 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