MGSE
Modellgetriebene Softwareentwicklung - HTWG
Modellgetriebene Softwareentwicklung - HTWG
-
- 1 / 138
-
Flashcards
Generator
Manuelle Erstellung einer Referenzimplementierung
Separation des modellabhängigen Codes
Extraktion der Generierungs-Templates aus dem modellabhängigen Code
Erzeugung vom Referenzmodell mit dem DSL-Editor
Ggf. Definition von Modell-zu-Modell-Transformationen
Generierung und Test
Anwendung
Erzeugung weiterer Modelle mit dem DSL-Editor
Generierung, ggf. Test
Welche Transformationen gibt es?
Modell zu Modell (m2m)
Modell zu Text/Code (m2t)
Drei Typen des DSLs
• Textual DSLs
– EBNF-Grammar
– Xtext
• Internal DSLs
– In Ruby, Groovy, Clojure or
– Scala
• Graphical DSLs
– UML Profiles, SysML, BPMN
– GMF
– Poseidon for DSLs
Sprachen von Interne DSL
- Java ist schlecht
- Ruby, Scala
Graphische DSL
• Modeling used to be equivalent to Graphical modeling
• Tooling for textual and internal DSLs has surpassed
graphical DSLs in the past few years
• Graphical Tooling is catching up
– MDSD: Generate from Models
GMF
Poseidon for DSLs
Vier Layer von Meta
- Layer M3: Grammar, BNF
- Layer M2: Programmiersprache, Java-Expression
- Layer M1: Klassen
- Layer M0: Objekte
Die Chomsky Hierarchie
Non Turing-Acceptable
- Turing-Acceptable
-- decidable
--- Context-sensitive
---- Context-free
----- Regular
Regular Expression
- Regular Expressions are very simple textual languages
- For a parser it is sufficient to read left to right to recognise an instance of a grammar
- Examples are Telephone numbers, Zip codes, Email Adresses
Rekursive Definitioin
Primitive regular expression: ∅, λ, α
Given regular expressions r_1 and r_2
Regulare Exppressions
r_1 + r_2
r_1 * r_2
r_1 *
(r_1)
Beispiele zur Regular Expressions
A regular expressions: (a + b⋅ c)*⋅(c +∅)
Not a regular expressions (a+b+)
Languages of Regular Expressions
language of regular expression: L(r) = r
Example L((a + b⋅ c)*) = {λ,a,bc,aa,abc,bca,...}
Xtext - Grundlagen
- Einfache Erstellung textueller DSLs
- Minimierung der Entwicklungszeit und Kosten von DSLs
- Optimale Toolunterstützung für den Anwender
Xtext - Information
- Text-based DSL
- Based on an EBNF grammar: ANTLR3-based parser, EMF.based metamodel, Eclipse editor
Xtext - Rules
- Rules similar to EBNF
Entity : "entity" name "{" (Feature)* "}";
Feature : type name ";";
- Creates a language that allows to say
entity Customer {
String name;
String street;
Integer age;
}
Xtext - Variables
- The grammar only defindes rules: a = A
-- Variable a contains instances of Type A
-- Example: name = ID
- We want to read out instances of the grammar and use it for code generation: (a?='t')?
-- a is true if t is used
-- resetting? = 'resetting'
- For that we need variables in the grammar with Types: (a+=A)*
-- Multivalued variable
-- events+=Events
Abhängigkeiten Grammatik - EMF Model (Ecore)
- Ein EPackage pro Grammatik
- Eine Parser Rule wird in eine EClass übsetzt
- Zuweisungen werden zu EAttributes oder EReferences
- Pro Terminal Rule einen EDataType
- Alternative wird als Vererbung abgebildet
Was ist Xtend?
- Sprache spezialisiert auf Codegenerierung aus Modellen
- Einfache Vermischung Text und dyn. Inhalt
- statisch typisiert