6. 6 / 25
Grammar-to-metamodel
lexical syntax
[a-zA-Z][a-zA-Z0-9]* -> ID
context-free syntax
"module" ID Type* -> Start {"Module"}
"entity" ID "{" Property* "}" -> Type {"Entity"}
"datatype" ID -> Type {"DataType"}
"attr" ID ":" ID -> Property {"Attribute"}
"ref" ID ":" ID -> Property {"Reference"}
namespaces
Module
Entity
DataType
Property
binding rules
Module(n, _):
defines Module n
scopes Entity, DataType
Attribute(n, t):
defines Property n
refers to DataType t
...
10. 10 / 25
Graphical Layout Preservation (1)
Conventional approach:
●
Replace entire model with new one
●
Re-link layout based on names/indices
●
Fails when names/indices change
entity Book2 {
attr title : String
ref author : Author
}
entity Author {}
entity Book {
attr title : String
ref author : Author
}
entity Author {}sync.
change
sync.
11. 11 / 25
diff calc. + merge
Graphical Layout Preservation (2)
New approach:
Change rather than replace model
Update graph. represent. accordingly
3
4
synchronize
12. 12 / 25
diff calc. + merge
Textual Layout Preservation (1)
Compare ASTs and merge changes into text:
●
Preserve unchanged elements
●
Pretty-print new elements
●
Pretty-print changed elements, but reassign layout
13. 13 / 25
Textual Layout Preservation (2)
Pretty-printers are generated from SDF3 definition:
14. 14 / 25
Textual Layout Preservation (3)
Use origin information to:
●
Merge text (use origin position)
●
Improve diff calc. (try match origin term, otherwise use heuristics)
origin position
origin term
origin term
diff calc. + merge
15. 15 / 25
Error Recovery
Apply recovery rules:
●
Recovery rules generated from the grammar
●
Malformed text → well-formed AST
Parse errors (1)
16. 16 / 25
Error Recovery
Treat unrecoverable text regions as layout:
●
Layout preserved during graphical editing
●
Graphical layout (currently) lost
Parse errors (2)
17. 17 / 25
Error Recovery
Leave unresolved references out of model:
●
Violations of lower bound constraints allowed
●
Elements still visualized when possible
Unresolved references
18. 18 / 25
Error Recovery
Introduce defaults to avoid syntax errors:
●
Defaults can be user-defined
●
Defaults may result in temp. unresolved references
Graphical syntax errors
19. 19 / 25
Editor Services
Undo-Redo:
●
Maintain single (shared)
operation history
Selection sharing:
Persistence:
●
Persist text and graph
●
Persist text
(auto-layout diagram)
●
Persist AST/model
(auto-layout diagram + pretty-print text)