Top Banner
©2016 GlobalLogic Inc. Build your own DSL with Xtext
12

Building Your Own DSL with Xtext

Apr 12, 2017

Download

Software

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Building Your Own DSL with Xtext

©2016 GlobalLogic Inc.

Build your own DSL with Xtext

Page 2: Building 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

[email protected]

Page 3: Building Your Own DSL with Xtext

3

Agenda

• Introduction of DSL• Eclipse Modelling Framework• Xtext• Demos• What’s new in Xtext 2.9

Page 4: Building Your Own DSL with Xtext

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

Page 5: Building Your Own DSL with Xtext

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

Page 6: Building Your Own DSL with Xtext

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

Page 7: Building Your Own DSL with Xtext

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

Page 8: Building Your Own DSL with Xtext

8

DemoAll demos are based on Xtext 2.9.2• Formatting• Generation• Scoping• Validation• Content assist• Labels / outline• Quick fix• Web editor

Page 9: Building Your Own DSL with Xtext

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

Page 10: Building Your Own DSL with Xtext

10

Q & A

Page 12: Building Your Own DSL with Xtext

12

Thank you