MetaEnvironment QBasic Eclipse LaTeX PHP ΞBGF TSR LDF M3 jQuery SVG CSS FST BGF JCL XHTML ++ DCG BNF PDG DMS git SQL XSD JS XCK Inkscape PascalLCF Graphviz Assembly ksh DHTML GraphML Erlang GWBasic C# ATL Delphi CodeSurfer yED JavaXLDF Prolog SoftwarePromela MediaWiki ParsingRuby sh OS/400 CGI EMF Markdown DITA COBOL GIF C FPU HTMLHaskell dot Python SPARQL Flash CRC 80x86 GrammarLab Matlab JSON and ModellingGDK Wikia Blowfish Ecore PCRE Turbo Vision Wikidot phpbb LCI CVS Smalltalk Wordpress Rascal XBGF EBNF VB Ada ASF Jenkins EDD bibTeX WinIceUvA MSc SE: XSLTSoftware SubversionEvolution 2014 Maple SDF HASP DeGlucker SoftIce JAXB XML Django SPIN Dr. Vadim Zaytsev,IDA Grammar Universiteit Huntervan Amsterdam Scheme DTD Unlambda Zope GRK Grammar Hawk Perl make ANTLR What is parsing? What is modelling? Parsing? if (/^\/\/.*$/ := x) {…}

awk '{print $1}' file.txt

sed '/^$/d;G' file.txt Parsing techniques Parsing techniques: LR

• Bottom-up • Deterministic • Operations • shift

• reduce

Left recursion is preferred • &$5CPFJVVRUGPYKMKRGFKCQTIYKMK(KNG5JKHV 4GFWEGA2CTUGA5VGRUAHQTA# $UXI%%$;5# -PWVJ1PVJG6TCPUNCVKQPQH.CPIWCIGUHTQO.GHVVQ4KIJV+% Parsing techniques: LL

• Top-down • Backtracking • Needed • stack

• parsing table

• Left recursion is deadly %KWOCE5GTIKW../CVJGOCVKECN2CTUGT JVVRYYYEQFGRTQLGEVEQO#TVKENGU../CVJGOCVKECN2CTUGT .GYKU5VGCTPU5[PVCZ&KTGEVGF6TCPUFWEVKQP,#%/ Parsing techniques: …

• Recursive descent — ↓ & accept() • Cocke-Younger-Kasami — ↑ & dynamic programming • Earley — ↓ & dynamic programming • Packrat — recursive descent for PEGs • Generalised parsing — return a forest 5EQVV,QJPUVQPG)..2CTUKPI.&6#'06%5

)TWPG,CEQDU2CTUKPI6GEJPKSWGUGF Parsing in Rascal

parse(#S,x);

t = parse(#start[S],x).top;

t = implode(#D,parse(#S,x));

-NKPVXCPFGT5VQTO8KPLW'#5;/GVCRTQITCOOKPIYKVJ4CUECN)665'ņ Parsing in Rascal

catch ParseError:

if (/amb(_) !:= t) {…}

diagnose(t);

-NKPVXCPFGT5VQTO8KPLW'#5;/GVCRTQITCOOKPIYKVJ4CUECN)665'ņ So, parsing or not?

sed '/^$/d' file.txt

…………………… ……………………

…………………… ……………………

…………………… ……………………

…………………… ……………………

…………………… …………………… Parsing or not??

[t | t <- split(s,"\n"), trim(t)!=""]

…………………… ……………………

…………………… ……………………

…………………… ……………………

…………………… ……………………

…………………… …………………… Parsing or not??

[t | t <- split(s," "), t!="a"]

a b r a c a d a b r a 2 0 1 4

b r c d b r 2 0 1 4 Parsing OR not???

[t | t <- split(s," "), /a-z/:=t]

a b r a c a d a b r a 2 0 1 4

a b r a c a d a b r a PARSING OR NOT???

syntax S = W*; lexical W = [a-z]; t = parse(#S,x); a b r a c a d a b r a 2 0 1 4

a b r a c a d a b r a Inside the parser Inside the compiler Compiler

Front MIDDLE BACK End End End Multi-language compiler Front End Front MIDDLE BACK End End End Front End Multi-target compiler Front BACK End End Front MIDDLE BACK End End End Front BACK End End Refactoring plugin Front BACK End End Front MIDDLE BACK End End End Front BACK End End M3 Front BACK End End Front MIDDLE BACK End End End Front BACK End End Formatter Front BACK End End Front MIDDLE BACK End End End Front BACK End End Examples of grammarware? Front BACK End End Front MIDDLE BACK End End End Front BACK End End Kinds of grammarware

• Parser • IDE • API • Compiler • DSL framework • XMLware • Interpreter • Preprocessor • Modelware • Pretty-printer • Postprocessor • Lang.workbench • Scanner • Validator • RE tool • Browser • Model checker • Benchmark • Static checker • Refactoring tool • Recommender • Struct.editor • Code slicer • Renovation tool

-NKPV.¦OOGN8GTJQGH6QYCTFCP'PIKPGGTKPI&KUEKRNKPGHQT)TCOOCTYCTG Grammars are models of structure Models of software analysis/ manipulation Grammarware is a technological space There are others

• UMLware — Mainstream software modeling • MDEware — Model Driven Engineering • Javaware — Mainstream OO programming • XMLware — Interoperability in data exchange • SQLware — Mainstream database management • Haskellware — Strongly typed • Pythonware — Scripting and frameworks • RDFware — Semantic Web and Linked Data • JSONware — Modern interoperability • COBOLware — Legacy programming technology

-WTVGX$G\KXKP#MUKV6GEJPQNQIKECNURCEGU#PKPKVKCNCRRTCKUCN Other models? Definition of a model?

5VCEJQYKCM#NNIGOGKPG/QFGNNVJGQTKG What is not a model? All models are wrong (Other) Models of structure Data model: tree

identifier identifier_start identifier_start identifier_extend map

Data model: list Applies given function to each element and returns a transformed collection.

8

0GCN(QTF(WPEVKQPCN6JKPMKPI)1610KIJV

34 Data model: graph

name: KNOWS name: Andreas Peter

KNOWS KNOWS

KNOWS

name: KNOWS name: Max Sarah

8CP$TWIIGP)TCRJ&CVCDCUGUHQT'PVGTRTKUG#TEJKVGEVU " !

The pattern match for that question looks like the shorthand you might write in an email discussing the problem. We want to find:!

(andreas)-->(friends)-->(friends_of_friends)

"

That ascii-art is exactly what you’d use in the MATCH clause of a Cypher query:!

START andreas=node:People(name=‘Andreas’) MATCH (andreas)-->(friends)-->(friends_of_friends) RETURN friends_of_friends

" !

The START clause specifies where the traversal should begin, here using an “Index” called “People” that is conveniently available. Then the RETURN specifies the result set, as you’d expect. !

Neo Technology 5" ! ! Graph Databases for the Enterprise Architect Data model: properties&claims Concept lattice UML: class diagram UML: sequence diagram

)YCWTJVVRUEQOOQPUYKMKOGFKCQTIYKMK(KNG#EVKXKV[AEQPFWEVKPIUXI%%$;5# Behavioural models Railroad diagrams

/KETQ(QEWU%1$1. Track control of railway systems

JVVRYYYOGVCECUGEQOECUGUTCKNYC[6TCEM%QPVTQNJVON Working with models

Metamodel Language FGHKPGU

KPUVCPEGQH GZRTGUUGFKP

System Model OQFGNQH Working with models

Metameta Metalang FGHKPGU

KPUVCPEGQH GZRTGUUGFKP

Metamodel Language FGHKPGU

KPUVCPEGQH GZRTGUUGFKP

System Model OQFGNQH Example

Rascal.rsc Rascal FGHKPGU

NKPIWKUVKE KPUVCPEGQH GZRTGUUGFKP

Java5.rsc Java FGHKPGU

NKPIWKUVKE KPUVCPEGQH GZRTGUUGFKP

Hello Hello.java OQFGNU Relations between elements

instanceOf

• conformsTo (linguistic instance, about the form) • “is a class”, “is an app”, “is a service” • snapshot (ontological instance, about the content) • “is a car”, “is a dog”, “is a map” Relations between elements

modelOf

• token model (one-to-one) • object diagram, representation model • type model (many-to-one) • class diagram, classification model Relations between elements

instanceOf modelOf

definitionOf elementOf

partOf subsetOf

inputOf hasOutput . . . Technology model

(CXTG.¦OOGN8CTCPQXKEJ/QFGNKPIVJG.KPIWKUVKE#TEJKVGEVWTGQH5QHVYCTG2TQFWEVU The upper frame uses the MegaL/yEd visual notation for megamodeling. TechnologyThe lower frame shows linked artifactsmodellingof the product explained later in the paper. tool

(CXTG.¦OOGN8CTCPQXKEJ/QFGNKPIVJG.KPIWKUVKE#TEJKVGEVWTGQH5QHVYCTG2TQFWEVUFig. 1. The linguistic architecture of a software product when displayed with the Me- gaL/Explorer tool.

demo functionality (see Demo.cs) and applied to a specific company—the Acme Corporation.7 The shown linguistic architecture describes artifacts as they arise during de- velopment time and runtime together with the relationships regarding dataflow, language membership, schema/type conformance, and correspondence. Charac-

7 http://en.wikipedia.org/wiki/Acme_Corporation J.-M. Favre, T. NGuyen / Electronic Notes in Theoretical Computer Science 127 (2005) 59–74 71

example (τµτ). The sequence of greek letters used here above are ambiguous, in particular because there is no formal rule for the ordering of letters. This is because the concepts described above corresponds to graph patterns, not simply sequences. We have identifiedMegapatterns a lot of interesting patterns that corresponds to known concepts. Some examples are provided in the next figure. τ τ µ τ µ τ µ χ τ τ

Forward Reverse Model Metamodel engineering engineering / System / Model transformation transformation co-evolution co-evolution τ τ µ τ µ τ µ τ µ τ µ τ τ τ

System-driven Model-driven Round-trip evolution evolution evolution µ χ µ ε µ χ τ ε τ µ τ χ µ χ χ Metamodel Metamodel Metamodel Metamodel/ Reflexive reverse inference engineering conformantModel metamodel engineering

(CXTG0)W[GP6QYCTFUC/GICOQFGNVQ/QFGN5QHVYCTG'XQNWVKQPVJTQWIJ6TCPUHQTOCVKQPUFig. 8. MegaModel: Examples of interesting mega-patterns (τ)

5Conclusion

In this paper we introduced a megamodel to describe MDE concepts and their relationships. This megamodel is summarized in Figure 9.Theviewpresented here corresponds has been simplified forthepurposeofthispaper.Amore complete view making explicit the relationships between the megamodel, the set theory and the language theory can be found in [8]. In fact, by using the megamodel we discovered that it was much more pow- erful than expected. It really helped us to connect concepts and technologies that were apparently disconnected. Surprisingly we discovered that a lot of known issues could be model as graph patterns. And we are still discovering Given the program… Guess the model (1) Guess the model (2) Guess the model (3) Guess the model (4) Guess the model (5) Guess the model (6) Parsing Unparsing

• recognising structure • representing structure

• text → tree • model → picture

• parse tree → AST • ASG → text

• forest disambiguation • (re)formatting

• tokens → graph • serialisation Model parsing as a technology

grouped abstract visual tokens model diagram

typed concrete graph tokens model model

slices/ parse vector tokens graph drawing

raw parse raster string forest picture

• Model is a reduced pragmatic view on a system • Parsing identifies structure • We need grammars and other models for software analysis • Use models to understand, visualise, cooperate, conform • All models are wrong

HQNNQY"ITCOOCTYCTG Read @ home: “Yet another annotated SLEBOK bibliography” http://softlang.uni-koblenz.de/yabib.pdf Credits

• Given on the bottom of each slide • unless self-made or public domain • Font • Intuitive by Bruno de Souza Leão, OFL http://openfontlibrary.org/en/font/intuitive

• Feedback • http://grammarware.net, http://grammarware.github.io, …