Download presentation
Presentation is loading. Please wait.
Published byScott Poole Modified over 8 years ago
1
Adding semantics to metamodels Mars 2006 Franck FLEUREY Triskell Research Group IRISA – Rennes (France)
2
2 Outline Introduction and motivations Kermeta Design Using Kermeta Tools and Demo Conclusion Outline
3
3 MDE Artifacts Meta-model Language Model Program M3 M2 M1 MOFUMLState... Meta-meta-models Meta-language Conforms to... Introduction and motivations
4
4 Example ● The metamodel ● A model Introduction and motivations S1S3S2 a/b x/y b/a y/x
5
5 MOF describe structures ● MOF => Only data structures – classes, properties, associations,... – operations : only signatures ● Not sufficient to use models – Constraints – Actions – Transformations –... Introduction and motivations
6
6 Existing technologies ● Constraints, OCL ● Transformations, QVT ● Operation behavior / algorithms – Natural language? OCL? JAVA? – Executable ? – Used in constraints / transformations ? Introduction and motivations
7
7 A Metamodeling Kernel Kermeta ● Extension to MOF ● Operation behavior specification ● Imperative language ● Core execution platform Introduction and motivations currentState := initialState
8
8 Outline Introduction and motivations Kermeta Design Using Kermeta Tools and Demo Conclusion Outline
9
9 Kermeta Design Kermeta design Metamodelling Constraints Transformations semantics OCL MOF, ECORE QVT, JAVA Kermeta
10
10 Options Kermeta design ● Use Java + Metadata Framework – Lazy solution or optimal solution? ● Define a brand new language ● Use or extend an existing language – Ecore++, EMOF++…
11
11 Building Kermeta Kermeta design
12
12 The action metamodel ● CRUD operation ● Control structures ● Operation call ● Variables and assignment ● Exceptions handling ● Functions (OCL-like iterators) Close to the OCL Kermeta design
13
13 Composition problems ● Type system – Generics – Function types ● Behavior redefinition – Abstract operations – Behavior inheritance – Behavior redefinition MOF is not designed to support behavior Kermeta design
14
14 Kermeta metamodel Kermeta design
15
15 Outline Introduction and motivations Kermeta Design Using Kermeta Tools and Demo Conclusion Outline
16
16 Using Kermeta ● EMOF compliant ● Object-Oriented – Multiple inheritance / behavior selection – Operation overiding / late binding – Full reflection (read-only) ● Statically Typed – Generics – Function types Using Kermeta
17
17 Example operation fire() : String source.owningFSM.currentState := target result := output Kermeta design
18
18 Example Using kermeta // Get the valid transitions var validTransitions : Collection validTransitions :=outgoingTransition.select { t | t.input.equals(c) } // Check if there is one and only one valid transition if validTransitions.empty then raise NoTransition.new end if validTransitions.size > 1 then raise NonDeterminism.new end // fire the transition result := validTransitions.one.fire operation step(c : String) : String
19
19 Example Using kermeta from var str : String until str == "exit" loop stdio.writeln("current state is " + currentState.name) str := stdio.read("Enter an input string or 'exit' to exit simulation : ") stdio.writeln(str) if str != "exit" then do stdio.writeln("Output string : " + currentState.step(str)) rescue (ex : FSMException) stdio.writeln("ERROR : " + ex.toString) end stdio.writeln("* END OF SIMULATION *") operation run() : Void
20
20 Creating a model /** * Create a sample FSM */ operation createFSM() : FSM is do // The FSM result := FSM.new // Create the states of the FSM var s1 : State init State.news1.name := "s1"result.ownedState.add(s1) var s2 : State init State.news2.name := "s2"result.ownedState.add(s2) var s3 : State init State.news3.name := "s3"result.ownedState.add(s3) // Create the transitions var t12 : Transition init Transition.new t12.input := "a"t12.source := s1t12.output := "b"t12.target := s2 var t23x : Transition init Transition.new t23x.input := "x"t23x.source := s2t23x.output := "y"t23x.target := s3 var t23y : Transition init Transition.new t23y.input := "y"t23y.source := s2t23y.output := "x"t23y.target := s3 var t31 : Transition init Transition.new t31.input := "b"t31.source := s3t31.output := "a"t31.target := s1 // Set the initial state result.initialState := s1 end S1S3S2 a/b x/y b/a y/x Using kermeta
21
21 Printing the State Machine /** * Print the FSM */ operation printFSM(fsm : FSM) is do fsm.ownedState.each { s | stdio.writeln("State : " + s.name) s.outgoingTransition.each { t | stdio.writeln(" Transition : " + t.source.name + "-(" + t.input + "/" + t.output + ")->" + t.target.name) } end State : s1 Transition : s1-(a/b)->s2 Transition : s1-(b/a)->s1 State : s2 Transition : s2-(x/y)->s3 Transition : s2-(y/x)->s3 State : s3 Transition : s3-(b/a)->s1 Using kermeta
22
22 Outline Introduction and motivations Kermeta Design Using Kermeta Tools and Demo Conclusion Outline
23
23 Tools and Demo
24
24 Outline Introduction and motivations Kermeta Design Using Kermeta Tools and Demo Conclusion Outline
25
25 Status ● Started January 2005 ● Current version (0.1.2) – Parser, type checker, interpreter – Eclipse plug-in: Editor, Browser, Launcher – EMF (meta-)model Import / Export ● Under development / test – Graphical Editor – Import of JAVA classes in Kermeta Conclusion
26
26 Future work ● Kermeta features – Import / Export MDR (meta-)models – Round-trip Graphical / Textual editor – Kermeta compiler ● MDE features – Concrete syntax and parser generator – OCL in Kermeta – QVT in Kermeta – Executable UML in Kermeta Conclusion
27
27 Links ● Home page – http://www.kermeta.org ● Development page – http://kermeta.gforge.inria.fr/ ● Part of the eclipse GMT project – http://www.eclipse.org/gmt/ Conclusion
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.