dsl and emftext

21
EMT | 07/07/2014 | © Robert Bosch Engineering and Business Solutions Limited 2014. All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution, as well as in the event of applications for industrial property rights. DSL and EMFTEXT DSL AND EMFTEXT Eclipse Day Bangalore Sep20, 2014 1 RAJKUMAR K (RBEI) KULANDAI VELU (RBEI)

Upload: eclipse-day-india

Post on 25-May-2015

160 views

Category:

Technology


2 download

DESCRIPTION

DSL and EMFText

TRANSCRIPT

Page 1: DSL and EMFText

EMT | 07/07/2014 | © Robert Bosch Engineering and Business Solutions Limited 2014. All rights reserved, a lso regarding any disposal,

exploita tion, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

DSL and EMFTEXT

DSL AND EMFTEXT

Eclipse Day Bangalore Sep20, 2014

1

RAJKUMAR K (RBEI) KULANDAI VELU (RBEI)

Page 2: DSL and EMFText

RBEI/EMT | 07/07/2014 | © Robert Bosch Engineering and Business Solutions Limited 2014. All rights reserved, also regarding any disposal,

exploita tion, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

2

AGENDA What is DSL? Eclipse in DSL What is EMFText? Why to use EMFText? Features of EMFText EMFText language development process Customizations Techniques and Concrete Customizations Integration with Other Frameworks Demo

DSL and EMFTEXT

Page 3: DSL and EMFText

RBEI/EMT | 07/07/2014 | © Robert Bosch Engineering and Business Solutions Limited 2014. All rights reserved, also regarding any disposal,

exploita tion, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

What is DSL? DSLs are small, expressive programming languages designed for particular domain

or task DSL has limited in scope and capabilities DSLs are focused on a certain type of a problem or domain, and on expressing a

narrow set of solutions within the context of that limited scope Domain experts can understand, validate and modify DSL programs DSLs are easy to learn and don't need to spend time for learning difficult and

complicated languages (C, C++,C#, .NET, Java and etc) Examples

HTML, CSS, ANTLR, MAKEFILE, UNIX SHELL SCRIPT, SQL

3

DSL and EMFTEXT

Page 4: DSL and EMFText

RBEI/EMT | 07/07/2014 | © Robert Bosch Engineering and Business Solutions Limited 2014. All rights reserved, also regarding any disposal,

exploita tion, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Eclipse in DSL

Eclipse offers frameworks for domain-specific modeling and defining textual domain specific language

Domain-specific modeling

EMF - Modeling frame work and code generation facility for structured model GMF - Supports developing the graphical editors for structured model

Defining textual domain specific language (EMFText)

Enables developers to define textual DSL quickly Don’t require to learn new technologies and concepts Collection of 100 concrete text syntaxes to define new languages of our own Derives the textual syntax for DSL from ECORE meta model

4

DSL and EMFTEXT

Page 5: DSL and EMFText

RBEI/EMT | 07/07/2014 | © Robert Bosch Engineering and Business Solutions Limited 2014. All rights reserved, also regarding any disposal,

exploita tion, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

What is EMFText ?

5

Meta Model

Concrete Syntax Semantics EMFTEXT

Domain concepts, relations, attributes

Syntax, Shapes

Behavior, meaning

DSL and EMFTEXT

Page 6: DSL and EMFText

RBEI/EMT | 07/07/2014 | © Robert Bosch Engineering and Business Solutions Limited 2014. All rights reserved, also regarding any disposal,

exploita tion, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Why to use EMFText ?

Readability

Version control

Backward compatibility

OS independent

Quick model instantiation

Tool reuse

Easy to understand

Clear structure

Tracing artifacts

Custom syntax is much easier to read than XML

Comparing and diffing the XML produce useless results

Existing models can be fixed on new version of Meta model

Text can edited on every OS with single text editor

Default HUTN Syntax instantly allows to create model instances

Transform documents (ATL) or analyze them (OCL)

Working on modelling tools allows easy to query

Easier to maintain document formats

Trace requirements from initial documents down to the running code

6

DSL and EMFTEXT

Page 7: DSL and EMFText

RBEI/EMT | 07/07/2014 | © Robert Bosch Engineering and Business Solutions Limited 2014. All rights reserved, also regarding any disposal,

exploita tion, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Generation Features

Generation of Independent code Generated code doesn’t contain dependencies to EMFText All code is fully customizable Deployable in non EMFtext environment UI code is generated to a separate plug-in enabling the

usage of DSLs in headless environments

Generation of default Syntaxes Syntax that conforms to HUTN standard Java –like syntax Custom syntax configuration

Highly customizable code generation Provide many options to tailoring its code generation process to specific needs Supports 293 customizable code generation options ex: additionalDependencies, additionalExports, disableBuilder

7

DSL and EMFTEXT

Page 8: DSL and EMFText

RBEI/EMT | 07/07/2014 | © Robert Bosch Engineering and Business Solutions Limited 2014. All rights reserved, also regarding any disposal,

exploita tion, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Specification Features

Modular specification Modularization and extension of CS specifications Support for abstract syntaxes and syntax imports Simple and precise syntax specification

Default reference resolving mechanisms Default name resolution mechanism External references resolved automatically Complex resolution mechanisms can be realized

Comprehensive syntax analysis

Informs developer about potential error in syntax ex: missing syntax for certain meta class Supports 20 plus warning messages

8

DSL and EMFTEXT

Page 9: DSL and EMFText

RBEI/EMT | 07/07/2014 | © Robert Bosch Engineering and Business Solutions Limited 2014. All rights reserved, also regarding any disposal,

exploita tion, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Other Features

9

Editor Features Advanced features like Java Editor Outline View Customizable Syntax Highlighting Occurrence Highlighting Code Completion Bracket handling Hyperlinks Text hovers Quick Fix

Build Features Generation of builder and interpreter stubs Customizable builder and interpreter ANT support to generate text syntax plug-ins in build scripts

DSL and EMFTEXT

Page 10: DSL and EMFText

RBEI/EMT | 07/07/2014 | © Robert Bosch Engineering and Business Solutions Limited 2014. All rights reserved, also regarding any disposal,

exploita tion, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

EMFText language development process

10

Iterative EMFText Language development process

DSL and EMFTEXT

Page 11: DSL and EMFText

RBEI/EMT | 07/07/2014 | © Robert Bosch Engineering and Business Solutions Limited 2014. All rights reserved, also regarding any disposal,

exploita tion, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Specifying a Language Meta-Model

11

Meta model elements: Classes Data Types Enumerations Attributes References(Containment, Non-

containment) Cardinalities Inheritance

Creating a new meta model:

Define concepts, relations and properties in an Ecore model

Existing meta models can be imported (e.g., UML, Ecore,…)

DSL and EMFTEXT

Page 12: DSL and EMFText

RBEI/EMT | 07/07/2014 | © Robert Bosch Engineering and Business Solutions Limited 2014. All rights reserved, also regarding any disposal,

exploita tion, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

12

Specifying the Language's Concrete Syntax

Textual representation of all Meta-model concepts

Automatically create the syntax

generator conforming to HUTN Possible to specify manually the concrete

syntax Syntax specification rules are derived

from EBNF syntax specification language Provide advance support like errors and

warning if consistent during syntax specification

DSL and EMFTEXT

Page 13: DSL and EMFText

RBEI/EMT | 07/07/2014 | © Robert Bosch Engineering and Business Solutions Limited 2014. All rights reserved, also regarding any disposal,

exploita tion, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Specifying the language CS’ syntax

13

Header SYNTAXDEF <yourFileExtension> FOR <namespaceURI> START <Root Model> Body (optional )TOKENS { Identifiers, numbers etc} (optional )TOKENSTYLES {color and font style} Bottom Rules{ own rules}

DSL and EMFTEXT

Page 14: DSL and EMFText

RBEI/EMT | 07/07/2014 | © Robert Bosch Engineering and Business Solutions Limited 2014. All rights reserved, also regarding any disposal,

exploita tion, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Specifying the language CS’ syntax

14

DSL and EMFTEXT

Page 15: DSL and EMFText

RBEI/EMT | 07/07/2014 | © Robert Bosch Engineering and Business Solutions Limited 2014. All rights reserved, also regarding any disposal,

exploita tion, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Customizations Techniques

Overriding Generated Artifacts

Provides Override option for all generated artifacts Possible to specify not to override the specific class or file Possible to customize the hover text using overrideHoverTextProvider

Overriding Meta Information Classes

SetOverride option to false for meta information class Using subclass instead of overriding the class directly Make customizations by overriding individual methods

Using Generated Extension Points

Customize the resource loader by using default_load_options Customize the registration of parser by using additional_extension_parser

15

DSL and EMFTEXT

Page 16: DSL and EMFText

RBEI/EMT | 07/07/2014 | © Robert Bosch Engineering and Business Solutions Limited 2014. All rights reserved, also regarding any disposal,

exploita tion, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Customizing Token Resolving Customizing Reference Resolving Implementing Post Processors Implementing Quick Fixes Implementing Builders Implementing Launch Support Enabling Debug Support Customizing Text Hovers

16

Concrete Customizations

DSL and EMFTEXT

Page 17: DSL and EMFText

RBEI/EMT | 07/07/2014 | © Robert Bosch Engineering and Business Solutions Limited 2014. All rights reserved, also regarding any disposal,

exploita tion, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Integration with Other Frameworks

Integration with the EMF Edit Framework

EMFText is tightly integrated with EMF Edit Framework Provider class will be used to obtain icons and labels for the outline view Icons shown in code completion proposals Consistent presentation of DSLs across different kind of editors

Integration with the EMF Validation Framework

EMFText integrate your DSL tooling with EMF validation Framework On editing DSL documents, only live constraints are evaluated Batch constraints are re-evaluated when documents are saved Consistent presentation of DSLs across different kind of editors Ensure constraintProvider extension must set to mixed mode

17

DSL and EMFTEXT

Page 18: DSL and EMFText

RBEI/EMT | 07/07/2014 | © Robert Bosch Engineering and Business Solutions Limited 2014. All rights reserved, also regarding any disposal,

exploita tion, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

18

DSL and EMFTEXT

Page 19: DSL and EMFText

RBEI/EMT | 07/07/2014 | © Robert Bosch Engineering and Business Solutions Limited 2014. All rights reserved, also regarding any disposal,

exploita tion, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Conclusion

19

EMFText is a tool for defining textual syntax for Ecore-based metamodels Enable developers to define their own textual languages – be it DSL Provides a Domain specific language for syntax specification Generates a full-fledged Eclipse Editor Includes a parser for loading textual models Includes a printer for storing model instances Provides editor will all its customizable components

DSL and EMFTEXT

Page 20: DSL and EMFText

RBEI/EMT | 07/07/2014 | © Robert Bosch Engineering and Business Solutions Limited 2014. All rights reserved, also regarding any disposal,

exploita tion, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

20

DSL and EMFTEXT

Page 21: DSL and EMFText

RBEI/EMT | 07/07/2014 | © Robert Bosch Engineering and Business Solutions Limited 2014. All rights reserved, also regarding any disposal,

exploita tion, reproduction, editing, distribution, as well as in the event of applications for industrial property rights.

Thank you

21

http://www.emftext.org

DSL and EMFTEXT