Concrete Syntax Definition for Modeling Languages Frédéric Fondement PhD. thesis Private Defense Swiss Federal Institute of Technology in Lausanne Software Engineering Laboratory September 2007
Contents z Introduction • Model Driven Engineering • Language Definition
Abstract Syntax + Concrete Syntax(es) ModelElement name : String
StateMachine source subvertex *
StateVertex
Event
outgoing *
1
*
1 target
trigger 0..1 Transition
*
incoming top 1 State
PseudoState
«enumeration» PseudoStateKind
kind : PseudoStateKind container 0..1
Composite State
Simple State
Final State
initial choice ...
z Interface between concept instances and system architects • Mean to manipulate virtual concept instances • Different points of view, different approaches to visualization • Emphasize different details
Lexicon z Abstract syntax, metamodel, concepts z Abstract syntax tree (AST), ASG, model z Language sentence = model + representation z Concept instance, model element, instance Abstract Syntax (M etam odel) «conform sTo»
StateMachine Door CompositeState { initial State opened CompositeState closed { initial State unlocked State locked Transition from unlocked to locked on lock Transition from locked to unlocked on unlock Transition from unlocked to opened on open } Transition from opened to closed on close } - 26 -
A Textual Representation
:CompositeState
A Graphical Representation
Example
September 2007
Example TCSS start template for StateMachine ::= "StateMachine" self.name self.top:=stateR; rule stateR ::= {OCL| self.oclIsKindOf(SimpleState)}? ssr | {OCL| self.oclIsKindOf(CompositeState)}? csr template csr for CompositeState ::= init "CompositeState" self.name "{" self.state:=(stateR)* "}" Abstract Syntax (Metamodel)
rule init ::= {OCL| self.incoming.source->exists(s| s.oclIsKindOf(PseudoState) and s.oclAsType(PseudoState).kind = initial) «conformsTo» }? "initial" =>{KerMeta| var _init:PseudoState init PseudoState.new var _t:Transition init Transition.new _init.kind := PseudoStateKind#initial Reversible _t.source := _init _t.target := self} Text … Model Processor
Problems z Not limited to connection-based languages z Reversible mapping z Versatile representation language z Clear representation data structure z Library of reusable interactions
↑ z Avoids Relates two things abstract/concrete of same nature syntax pollution
z Improves reusability z Minimizes maintenance points z Mapping can be complex (large gap !)
- 62 -
September 2007
The Representation Language z Render Vector Graphics • Render “Terminal” Symbols • As open as possible
z Controllable by an API (online rendering) • Implementation for interaction library • Possibility to specify variation points • Mean to access the model
The Representation Language 9 Render Vector Graphics 9Not connection-based only 9As open as possible
z Controllable by an API (online rendering) • Implementation for interaction library • Possibility to specify variation points • Mean to access the model
Alternatives Composite state is depicted either by a text showing the name of the composite state, or by a region showing the contents of the composite state, or both. In the latter case, the two regions are separated by a line. Composite me State 1
dm *
Composite StateDM showName showContent
vo SVGComposite State 1 1 0..1 SVGText name 0..1 separator 0..1
SVGLine SVGContents
context CompositeStateDM inv: self.showName = self.vo.name−>notEmpty() and self.showContent = self.vo.contents−>notEmpty() and (self.showName and self.showContent ) = self.vo.separator−>notEmpty() contents
Representation Link: DopiDOM events z Events depend on DopiDOM component z Reaction to events defined in templates • Java JMI or EMF, KerMETA, Xion, etc.
Conclusions z Language proliferation (MDE+DSM) • Language engineering is a key
z Solutions to fill abstract/concrete syntax gap • Abstract syntax provided as a metamodel • Focus on executable specifications • Missing OCL constraint solver… • Human readable/productible ?
Towards “Agile” Language Engineering z Agile MDE Definition • Knowledge from real specialists ! • “off-the-shelf (MDE) components” • Adaptable to each project