Overview - Eindhoven University of Technologymvdbrand/courses/GLT/1112/slides/DSLDesi… · Generic...

9
Generic Language Technology 2IS15 Domain Specific Language Engineering Prof.dr. Mark van den Brand Overview GLT so far: Why Generic Language Technology Language design Language design Syntax: signatures, abstract and concrete syntax Static semantics: scoping, identification and type checking Dynamic semantics: operational semantics Dynamic semantics: operational semantics Basic technology S i Scanning Parsing: LL, LR and GLR / Faculteit Wiskunde en Informatica PAGE 1 15-11-2011 Organization of DSLE part Topics: Model driven software engineering Meta-modeling Model transformations Model transformations Domain specific language design and engineering Textual Tooling Eclipse plus EMF Xtext, EMFtext, ATL, Xtend, Xpand, and QVTo / Faculteit Wiskunde en Informatica PAGE 2 15-11-2011 Overview of DSLE Model driven software engineering in general Grammars and meta-models DSL Design Model transformations Code generation / Faculteit Wiskunde en Informatica PAGE 3 15-11-2011

Transcript of Overview - Eindhoven University of Technologymvdbrand/courses/GLT/1112/slides/DSLDesi… · Generic...

  • Generic Language Technology 2IS15g g gy

    Domain Specific Language Engineering

    Prof.dr. Mark van den Brand

    Overview

    • GLT so far:• Why Generic Language Technology

    • Language design• Language design− Syntax: signatures, abstract and concrete syntax− Static semantics: scoping, identification and type checking− Dynamic semantics: operational semantics− Dynamic semantics: operational semantics

    • Basic technologyS i− Scanning

    − Parsing: LL, LR and GLR

    / Faculteit Wiskunde en Informatica PAGE 115-11-2011

    Organization of DSLE part

    • Topics:• Model driven software engineering

    − Meta-modeling− Model transformationsModel transformations

    • Domain specific language design and engineering− Textual

    • Tooling• Eclipse plus EMF• Xtext, EMFtext, ATL, Xtend, Xpand, and QVTo

    / Faculteit Wiskunde en Informatica PAGE 215-11-2011

    Overview of DSLE

    • Model driven software engineering in generalg g g• Grammars and meta-models• DSL Design• Model transformations• Code generation

    / Faculteit Wiskunde en Informatica PAGE 315-11-2011

  • Model driven software engineering

    • Models are used everywhere y

    / Faculteit Wiskunde en Informatica PAGE 415-11-2011

    Model driven software engineering

    • Models are abstractions of real life objectsj

    / Faculteit Wiskunde en Informatica PAGE 515-11-2011

    Model driven software engineering

    • Models increase the level of abstraction• used for both hardware and software design• often manually translated into design documents and code• no guarantee for consistency between model, design and

    resulting code

    / Faculteit Wiskunde en Informatica PAGE 615-11-2011

    Model driven software engineering

    • Whole range of modeling languages are developed over the years:• data oriented, e.g., E/R models, class diagrams• behaviour oriented, e.g., use cases, state machines,

    sequence diagrams, activity diagrams• architecture oriented, e.g., package diagrams, component

    diagrams

    • Standardization initiative of OMG:• Unified Modeling Language

    / Faculteit Wiskunde en Informatica PAGE 715-11-2011

  • Model driven software engineering

    • UML is unified:• Class diagrams• Object diagrams• Use cases• Use cases• State machine diagrams• Sequence diagrams• Activity diagrams• Component diagrams• etc.

    • UML is too “universal”

    / Faculteit Wiskunde en Informatica PAGE 815-11-2011

    Model driven software engineering

    • Criticism on UML:• It contains many diagrams and constructs that are redundant

    or infrequently used• Problems in learning and adoptingProblems in learning and adopting• Linguistic incoherence• Dysfunctional interchange format

    / Faculteit Wiskunde en Informatica PAGE 915-11-2011

    Model driven software engineering

    • UML is too “universal”: a general purpose modeling g glanguage

    • Domain specific extension via:P fil di t t th t d l l l t h• Profile diagram operates at the meta model level to show − stereotypes as classes with the stereotype, and − profiles as packages with the stereotype

    • Meta modeling

    / Faculteit Wiskunde en Informatica PAGE 1015-11-2011

    Model driven software engineering

    • Meta-Object Facility (MOF) is a four-layered architecture:• M3 Meta-Meta-Model Layer

    − defines structure of the meta-metadata− it provides a meta-meta model at the top layerM2 M t M d l L• M2 Meta-Model Layer− defines the structure of the metadata − the M3-model is used to build meta models− the most prominent example is the UML meta model the model thatthe most prominent example is the UML meta model, the model that

    describes the UML itself • M1 Model Layer

    − describes the data in the information layer − the M2-models describe elements of the M1-layer − For example, models written in UML

    • M0 Model Layer− describes objects or data in the information layer

    / Faculteit Wiskunde en Informatica PAGE 1115-11-2011

  • Model driven software engineering

    / Faculteit Wiskunde en Informatica PAGE 1215-11-2011

    Model driven software engineering

    • Meta-Object Facility (MOF) is the OMG standardj y ( )

    • EMF is the Eclipse implementation of MOF

    / Faculteit Wiskunde en Informatica PAGE 1315-11-2011

    Model driven software engineering

    EMF Model Definition

    • What is an EMF “model”?• Specification of an application’s dataSpecification of an application s data

    − Objects− Object attributes− Relationships (associations) between objectsRelationships (associations) between objects− Operations available on each object− Simple constraints (e.g., multiplicity) on objects and relationships

    • Essentially the Class Diagram subset of UML

    / Faculteit Wiskunde en Informatica PAGE 1415-11-2011

    Model driven software engineering

    • What does EMF provide?• Meta-model

    − A general model of models from which any model can be defined− Models classes, attributes, relationships, data types, etc.

    − Referred to as Ecore− Ecore is just another EMF model

    EMF i d t i l t EMF!• EMF is used to implement EMF!• Tool support within Eclipse framework• Runtime environment

    R fl ti d d i d l i ti− Reflective and dynamic model invocation− XML/XMI default model serialization

    / Faculteit Wiskunde en Informatica PAGE 1515-11-2011

  • Model driven software engineering

    • EMF is middle ground in the modeling vs. programming world• Focus is on class diagram subset of UML modeling (object model)• Transforms models into (efficient, correct, and customizable) Java

    code• Provides the infrastructure to use models effectively in your code

    / Faculteit Wiskunde en Informatica PAGE 1615-11-2011

    Model driven software engineering

    • EMF Components• EMF Core

    − Ecore meta model− Model change notification− Persistence and serialization − Reflection API− Runtime support for generated models− Change model and recorder− Validation frameworkValidation framework

    • EMF Edit− Helps integrate models with a rich user interface− Used to build editors and viewers for your model

    Includes default reflective model editor− Includes default reflective model editor• EMF Codegen

    − Code generator for core and edit based components− Model importers from Rose, XML, or Java interfaces

    / Faculteit Wiskunde en Informatica PAGE 1715-11-2011

    Model driven software engineering

    • EClass models classes• Simplified Ecore meta-model EClass models classes themselves• identified by name• number of attributes

    Simplified Ecore meta model

    number of attributes• number of reference

    • EAttribute models attributes• identified by name• identified by name• has a type

    • EDataType represents i l tsimple types

    / Faculteit Wiskunde en Informatica PAGE 1815-11-2011

    Model driven software engineering

    • Simplified Ecore meta-model • EReference modelsSimplified Ecore meta model EReference models associations between classes• identified by name• has a type which must be anhas a type which must be an

    EClass• containment attribute

    indicating whether the EReference is used as “whole-part” relationship

    / Faculteit Wiskunde en Informatica PAGE 1915-11-2011

  • Model driven software engineering

    • Classes, abstract classes and interfaces

    • Attributes and Operations

    / Faculteit Wiskunde en Informatica PAGE 2015-11-2011

    Model driven software engineering

    • Creation of abstract class

    / Faculteit Wiskunde en Informatica PAGE 2115-11-2011

    Model driven software engineering

    • Associations in the meta-model:• One way reference

    • Two way reference

    / Faculteit Wiskunde en Informatica PAGE 2215-11-2011

    Model driven software engineering

    • Associations in the meta-model:• Containment reference

    • Inherit association

    / Faculteit Wiskunde en Informatica PAGE 2315-11-2011

  • Model driven software engineering

    • Associations in the meta-model:• Multiple inheritance via “extend”

    / Faculteit Wiskunde en Informatica PAGE 2415-11-2011

    Model driven software engineering

    • Further reading on EMF:g• http://help.eclipse.org/indigo/index.jsp• EMF Developer Guide

    − Programmer's Guide:Programmer s Guide: “The Eclipse Modeling Framework (EMF) Overview”

    / Faculteit Wiskunde en Informatica PAGE 2515-11-2011

    Model driven software engineering

    • EMF is suited for modeling domain specific glanguages

    / Faculteit Wiskunde en Informatica PAGE 2615-11-2011

    Model driven software engineering

    • What is a Domain Specific Language (DSL)?g g ( )

    • A DSL is a formal, procesable language targeting at a specific aspect of a systemaspect of a system

    • Its semantics, flexibility and notation is designed in order to support working with that aspect as good as possible

    / Faculteit Wiskunde en Informatica PAGE 2715-11-2011

  • Model driven software engineering

    • How do we design a Domain Specific Language?g g g• Establish needed language concepts

    − domain specific− abstractionabstraction− corresponding semantics

    • Graphical vs textual representation• Develop tooling• Develop tooling

    / Faculteit Wiskunde en Informatica PAGE 2815-11-2011

    Model driven software engineering

    • Example of a Domain Specific Languageg g• Specifying and Implementing the Controllers of Conveyor

    Belts− We defined a domain specific language (DSL) for modeling p g g ( ) g

    communicating systems− Stepwise refinement to adapt the characteristics of the

    communication channels to the Lego Mindstorms platform

    / Faculteit Wiskunde en Informatica PAGE 2915-11-2011

    Model driven software engineering

    • State machine based• combination of:

    − graphical models and− textual modelstextual models

    • conditional message exchange− plus activitiesplus activities

    • No data yet• No timing yet

    Model driven software engineering

  • Model driven software engineering

    • Requirements for a DSL:• Unambiguous syntax• Unambiguous semantics

    U bi t f bilit• Unambiguous transformability• Strongly-typed and deterministic IO• Encapsulationcapsu at o• Expressiveness• Readability