SlideShare a Scribd company logo
1 of 22
Download to read offline
XMF: A Language for Language Oriented
           Programming

                       Tony Clark1

     1 School   of Engineering and Information Sciences
                    University of Middlesex


                      July 25, 2011
Background



• UML 2.0 started around 2000.
• The 2U Submission: UML as family of languages.
• Aim: to merge modelling and programming.
• Tools: MMT, XMT, XMF.
• Programming language based on FP and OCL.
• Important features: meta-; reflection; OO.
• Xactium 2003–2008.
XMF

• Meta-Circular Language (like MOF and ECore).
• XCore Based on ObjvLisp.
• File based or world-state.
• Features for:
     • Packages of models/programs.
     • Higher-order operations.
     • OCL.
     • Meta-Object Prototcol (MOP).
     • Language Engineering (grammars, syntax processing).
     • Daemons (object listeners).
     • Pattern matching.
     • Code generation templates.
     • Threads.
     • XML processing (parsing).
     • Java integration.
Meta-language
Models



 1   context Root
 2     @Class Request
 3       @Attribute id : String end
 4       @Constructor(id) ! end
 5     end
 6
 7   context Root
 8     @Class RBuffer
 9       @Attribute requests : Seq(Request) end
10       @Constructor(requests) ! end
11     end
Behaviour
Programs: XOCL


 1   context RBuffer
 2     @Operation add(id:String)
 3       self.requests := requests + Seq{Request(id)}
 4     end
 5
 6   context RBuffer
 7     @Operation handle(id:String)
 8       @Match(requests) {
 9         R1 + Seq{Request(${id})} + R2 ->
10           self.requests := R1 + R2,
11         else self.error("No request with id " + id)
12       }
13     end
Failure



 1   context SeqOfElement
 2     @Operation removeDups()
 3       @Match(self) {
 4         S1 + Seq{x} + S2 + Seq{y} + S3 ->
 5           if x = y
 6           then (S1+S2+S3)->removeDups
 7           else fail()
 8           end,
 9         else self
10       }
11     end
Syntax Classes
Quasi-Quotes



 1   context Root
 2     @Operation add1_exp(exp:Performable):Performable
 3       [| 1 + <exp> |]
 4     end
 5
 6   context Root
 7     @Operation seq_exp(exps:Seq(Performable)):Performable
 8       exps->iterate(e x = [| Seq{} |] |
 9         [| <x>->including(<e>) |])
10     end
Grammars

 1   parserImport Parser::BNF;
 2   parserImport XOCL;
 3
 4   Root::g :=
 5     @Grammar
 6       Start ::= i=Int o=Op j=Int {
 7          @Case o of
 8            "+" do i + j end
 9            "*" do i * j end
10          end
11       }.
12       Op ::= ’+’ { "+" } | ’*’ { "*" }.
13     end;

     [ 1 ] XMF> g . parseString ( " 1 + 2 " , " S t a r t " , Seq { } ) ;
     3
     [ 1 ] XMF>
Match Language Construct
Match Syntax Class
 1   context Root
 2    @Class Match extends XOCL::Sugar
 3      @Attribute value : Performable end
 4      @Attribute arms : Seq(Arm) end
 5      @Attribute alt : Performable end
 6      @Constructor(value,arms,alt) ! end
 7      @Grammar extends OCL::OCL.grammar
 8        Match ::= e=Exp ’{’ as=Arm* ’else’ a=Exp ’}’ {
 9           Match(e,as,a)
10        }.
11        Arm ::= p=Pat ’->’ e=Exp ’,’ {Arm(p,e)}.
12        Pat ::= l=Atom (’+’ r=Pat {Append(l,r)} | {l}).
13        Pats ::= p=Pat ps=(’,’ Pat)* {Seq{p|ps}}.
14        Atom ::= i=Int {Const(i)}
15        | ’$’ ’{’ n=Name ’}’ {Ref(n)}
16        | v=Name (’(’ ps=Pats ’)’ {Cnstr(v,ps)} | {Var(v)})
17        | ’Seq{’ ps=Pats ’}’ {Patterns(ps)}.
18      end
19    end
Desugar



1   context Match
2     @Operation desugar()
3       [| let value = <value>
4          in <arms->iterate(arm exp=[| @Operation()
5                                         <alt>
6                                       end |]
7                           | arm.desugar(exp))>
8          end |]
9     end
Arms




1   context Arm
2     @Operation desugar(fail:Performable)
3       [| let fail = <fail>
4          in <pattern.match(exp)>
5          end |]
6     end
Constants




1   context Const
2     @Operation match(succ)
3       [| if value = <const.lift()>
4           then <succ>
5           else fail()
6           end |]
7       end
Variables and Refs


 1   context Var
 2     @Operation match(succ)
 3       [| let <name> = value in <succ> end |]
 4     end
 5
 6   context Ref
 7     @Operation match(succ)
 8       [| if value = <OCL::Var(name)>
 9          then <succ>
10          else fail()
11          end |]
12     end
Splits

 1   context SeqOfElement
 2     @Operation split()
 3       (0.to(self->size))->iterate(i pairs=Seq{} |
 4          pairs->including(Seq{self->take(i),
 5                               self->drop(i)}))
 6     end
 7
 8   context SeqOfElement
 9     @Operation select(succ,fail)
10       if self->isEmpty
11       then fail()
12       else succ(self->head,@Operation()
13                              self->tail.select(succ,fail)
14                            end)
15       end
16     end
Append

 1   context Append
 2     @Operation match(succ)
 3       [| if value.isKindOf(Seq(Element))
 4          then
 5            value->split.select(
 6              @Operation(pair,fail)
 7                let value = pair->at(0)
 8                in <left.match([| let value = pair->at(1)
 9                                  in <right.match(succ)>
10                                  end |])>
11                end
12              end,fail)
13          else fail()
14          end |]
15     end
Patterns



 1   context Patterns
 2    @Operation match(succ)
 3      [| if value.isKindOf(Seq(Element)) andthen value->
            size = <patterns->size.lift()>
 4         then <(0.to(patterns->size-1))->iterate(i s=succ |
 5                [| let value = value->at(<i.lift()>)
 6                    in <patterns->at(i).match(succ)>
 7                    end |])>
 8         else fail()
 9         end |]
10    end
Constructors
 1   context Cnstr
 2    @Operation match(succ)
 3      [| if value.of() = Root.getElement(<name.lift()>)
 4          then <let c = Root.getElement(name)
 5                             .constructors
 6                             ->select(c |
 7                               c.names->size =
 8                               args->size)
 9                             ->asSeq->head
10                in (0.to(args->size-1))->iterate(i exp=succ|
11                      [| let value = value.<c.names->at(i)>
12                         in <args->at(i).match(succ)>
13                         end |])
14                end>
15          else fail()
16          end |]
17      end
18     end
Availability, Documentation, Research
http://www.eis.mdx.ac.uk/staffpages/tonyclark/




                     XPL

More Related Content

What's hot

Programmation fonctionnelle en JavaScript
Programmation fonctionnelle en JavaScriptProgrammation fonctionnelle en JavaScript
Programmation fonctionnelle en JavaScriptLoïc Knuchel
 
The Ring programming language version 1.7 book - Part 30 of 196
The Ring programming language version 1.7 book - Part 30 of 196The Ring programming language version 1.7 book - Part 30 of 196
The Ring programming language version 1.7 book - Part 30 of 196Mahmoud Samir Fayed
 
Практическое применения Akka Streams
Практическое применения Akka StreamsПрактическое применения Akka Streams
Практическое применения Akka StreamsAlexey Romanchuk
 
«Практическое применение Akka Streams» — Алексей Романчук, 2ГИС
«Практическое применение Akka Streams» — Алексей Романчук, 2ГИС«Практическое применение Akka Streams» — Алексей Романчук, 2ГИС
«Практическое применение Akka Streams» — Алексей Романчук, 2ГИС2ГИС Технологии
 
The Ring programming language version 1.5.1 book - Part 32 of 180
The Ring programming language version 1.5.1 book - Part 32 of 180The Ring programming language version 1.5.1 book - Part 32 of 180
The Ring programming language version 1.5.1 book - Part 32 of 180Mahmoud Samir Fayed
 
Dts x dicoding #2 memulai pemrograman kotlin
Dts x dicoding #2 memulai pemrograman kotlinDts x dicoding #2 memulai pemrograman kotlin
Dts x dicoding #2 memulai pemrograman kotlinAhmad Arif Faizin
 
Operation Flow @ ChicagoRoboto
Operation Flow @ ChicagoRobotoOperation Flow @ ChicagoRoboto
Operation Flow @ ChicagoRobotoSeyed Jafari
 
The Ring programming language version 1.5.2 book - Part 177 of 181
The Ring programming language version 1.5.2 book - Part 177 of 181The Ring programming language version 1.5.2 book - Part 177 of 181
The Ring programming language version 1.5.2 book - Part 177 of 181Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 91 of 210
The Ring programming language version 1.9 book - Part 91 of 210The Ring programming language version 1.9 book - Part 91 of 210
The Ring programming language version 1.9 book - Part 91 of 210Mahmoud Samir Fayed
 
ClojurianからみたElixir
ClojurianからみたElixirClojurianからみたElixir
ClojurianからみたElixirKent Ohashi
 
The Ring programming language version 1.5.3 book - Part 88 of 184
The Ring programming language version 1.5.3 book - Part 88 of 184The Ring programming language version 1.5.3 book - Part 88 of 184
The Ring programming language version 1.5.3 book - Part 88 of 184Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 42 of 210
The Ring programming language version 1.9 book - Part 42 of 210The Ring programming language version 1.9 book - Part 42 of 210
The Ring programming language version 1.9 book - Part 42 of 210Mahmoud Samir Fayed
 
Evolving with Java - How to remain Relevant and Effective
Evolving with Java - How to remain Relevant and EffectiveEvolving with Java - How to remain Relevant and Effective
Evolving with Java - How to remain Relevant and EffectiveNaresha K
 
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...adrianoalmeida7
 

What's hot (20)

Programmation fonctionnelle en JavaScript
Programmation fonctionnelle en JavaScriptProgrammation fonctionnelle en JavaScript
Programmation fonctionnelle en JavaScript
 
The Ring programming language version 1.7 book - Part 30 of 196
The Ring programming language version 1.7 book - Part 30 of 196The Ring programming language version 1.7 book - Part 30 of 196
The Ring programming language version 1.7 book - Part 30 of 196
 
Практическое применения Akka Streams
Практическое применения Akka StreamsПрактическое применения Akka Streams
Практическое применения Akka Streams
 
«Практическое применение Akka Streams» — Алексей Романчук, 2ГИС
«Практическое применение Akka Streams» — Алексей Романчук, 2ГИС«Практическое применение Akka Streams» — Алексей Романчук, 2ГИС
«Практическое применение Akka Streams» — Алексей Романчук, 2ГИС
 
The Ring programming language version 1.5.1 book - Part 32 of 180
The Ring programming language version 1.5.1 book - Part 32 of 180The Ring programming language version 1.5.1 book - Part 32 of 180
The Ring programming language version 1.5.1 book - Part 32 of 180
 
Dts x dicoding #2 memulai pemrograman kotlin
Dts x dicoding #2 memulai pemrograman kotlinDts x dicoding #2 memulai pemrograman kotlin
Dts x dicoding #2 memulai pemrograman kotlin
 
Anti patterns
Anti patternsAnti patterns
Anti patterns
 
Operation Flow @ ChicagoRoboto
Operation Flow @ ChicagoRobotoOperation Flow @ ChicagoRoboto
Operation Flow @ ChicagoRoboto
 
The Ring programming language version 1.5.2 book - Part 177 of 181
The Ring programming language version 1.5.2 book - Part 177 of 181The Ring programming language version 1.5.2 book - Part 177 of 181
The Ring programming language version 1.5.2 book - Part 177 of 181
 
The Ring programming language version 1.9 book - Part 91 of 210
The Ring programming language version 1.9 book - Part 91 of 210The Ring programming language version 1.9 book - Part 91 of 210
The Ring programming language version 1.9 book - Part 91 of 210
 
ClojurianからみたElixir
ClojurianからみたElixirClojurianからみたElixir
ClojurianからみたElixir
 
Into Clojure
Into ClojureInto Clojure
Into Clojure
 
CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScript
 
Java VS Python
Java VS PythonJava VS Python
Java VS Python
 
The Ring programming language version 1.5.3 book - Part 88 of 184
The Ring programming language version 1.5.3 book - Part 88 of 184The Ring programming language version 1.5.3 book - Part 88 of 184
The Ring programming language version 1.5.3 book - Part 88 of 184
 
The Ring programming language version 1.9 book - Part 42 of 210
The Ring programming language version 1.9 book - Part 42 of 210The Ring programming language version 1.9 book - Part 42 of 210
The Ring programming language version 1.9 book - Part 42 of 210
 
Evolving with Java - How to remain Relevant and Effective
Evolving with Java - How to remain Relevant and EffectiveEvolving with Java - How to remain Relevant and Effective
Evolving with Java - How to remain Relevant and Effective
 
Scala introduction
Scala introductionScala introduction
Scala introduction
 
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
 
The Magic Of Elixir
The Magic Of ElixirThe Magic Of Elixir
The Magic Of Elixir
 

Viewers also liked

Viewers also liked (6)

Dsl tutorial
Dsl tutorialDsl tutorial
Dsl tutorial
 
Kiss at oopsla 09
Kiss at oopsla 09Kiss at oopsla 09
Kiss at oopsla 09
 
Leap isec 2011
Leap isec 2011Leap isec 2011
Leap isec 2011
 
Dsl overview
Dsl overviewDsl overview
Dsl overview
 
Ast 09
Ast 09Ast 09
Ast 09
 
Hcse pres
Hcse presHcse pres
Hcse pres
 

Similar to Patterns 200711

What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)Pavlo Baron
 
CS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term RewritingCS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term RewritingEelco Visser
 
Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語ikdysfm
 
Compiler Construction | Lecture 5 | Transformation by Term Rewriting
Compiler Construction | Lecture 5 | Transformation by Term RewritingCompiler Construction | Lecture 5 | Transformation by Term Rewriting
Compiler Construction | Lecture 5 | Transformation by Term RewritingEelco Visser
 
Clojure for Data Science
Clojure for Data ScienceClojure for Data Science
Clojure for Data ScienceMike Anderson
 
Javascript Basics
Javascript BasicsJavascript Basics
Javascript Basicsmsemenistyi
 
ES6 Simplified
ES6 SimplifiedES6 Simplified
ES6 SimplifiedCarlos Ble
 
Functional techniques in Ruby
Functional techniques in RubyFunctional techniques in Ruby
Functional techniques in Rubyerockendude
 
Functional techniques in Ruby
Functional techniques in RubyFunctional techniques in Ruby
Functional techniques in Rubyerockendude
 
ECMAScript2015
ECMAScript2015ECMAScript2015
ECMAScript2015qmmr
 
Functional Operations - Susan Potter
Functional Operations - Susan PotterFunctional Operations - Susan Potter
Functional Operations - Susan Potterdistributed matters
 
オープンデータを使ったモバイルアプリ開発(応用編)
オープンデータを使ったモバイルアプリ開発(応用編)オープンデータを使ったモバイルアプリ開発(応用編)
オープンデータを使ったモバイルアプリ開発(応用編)Takayuki Goto
 
Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?Jesper Kamstrup Linnet
 
More than syntax
More than syntaxMore than syntax
More than syntaxWooga
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
Ruby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code style
Ruby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code styleRuby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code style
Ruby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code styleAnton Shemerey
 

Similar to Patterns 200711 (20)

What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)
 
CS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term RewritingCS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term Rewriting
 
Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語
 
Compiler Construction | Lecture 5 | Transformation by Term Rewriting
Compiler Construction | Lecture 5 | Transformation by Term RewritingCompiler Construction | Lecture 5 | Transformation by Term Rewriting
Compiler Construction | Lecture 5 | Transformation by Term Rewriting
 
Clojure for Data Science
Clojure for Data ScienceClojure for Data Science
Clojure for Data Science
 
Javascript Basics
Javascript BasicsJavascript Basics
Javascript Basics
 
ES6 Simplified
ES6 SimplifiedES6 Simplified
ES6 Simplified
 
Es6 hackathon
Es6 hackathonEs6 hackathon
Es6 hackathon
 
Functional techniques in Ruby
Functional techniques in RubyFunctional techniques in Ruby
Functional techniques in Ruby
 
Functional techniques in Ruby
Functional techniques in RubyFunctional techniques in Ruby
Functional techniques in Ruby
 
ECMAScript2015
ECMAScript2015ECMAScript2015
ECMAScript2015
 
Functional Operations - Susan Potter
Functional Operations - Susan PotterFunctional Operations - Susan Potter
Functional Operations - Susan Potter
 
Pune Clojure Course Outline
Pune Clojure Course OutlinePune Clojure Course Outline
Pune Clojure Course Outline
 
オープンデータを使ったモバイルアプリ開発(応用編)
オープンデータを使ったモバイルアプリ開発(応用編)オープンデータを使ったモバイルアプリ開発(応用編)
オープンデータを使ったモバイルアプリ開発(応用編)
 
Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?
 
More than syntax
More than syntaxMore than syntax
More than syntax
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Spark workshop
Spark workshopSpark workshop
Spark workshop
 
PythonOOP
PythonOOPPythonOOP
PythonOOP
 
Ruby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code style
Ruby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code styleRuby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code style
Ruby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code style
 

More from ClarkTony

The Uncertain Enterprise
The Uncertain EnterpriseThe Uncertain Enterprise
The Uncertain EnterpriseClarkTony
 
Actors for Behavioural Simulation
Actors for Behavioural SimulationActors for Behavioural Simulation
Actors for Behavioural SimulationClarkTony
 
Context-Aware Content-Centric Collaborative Workflow Management for Mobile De...
Context-Aware Content-Centric Collaborative Workflow Management for Mobile De...Context-Aware Content-Centric Collaborative Workflow Management for Mobile De...
Context-Aware Content-Centric Collaborative Workflow Management for Mobile De...ClarkTony
 
LEAP A Language for Architecture Design, Simulation and Analysis
LEAP A Language for Architecture Design, Simulation and AnalysisLEAP A Language for Architecture Design, Simulation and Analysis
LEAP A Language for Architecture Design, Simulation and AnalysisClarkTony
 
A Common Basis for Modelling Service-Oriented and Event-Driven Architecture
A Common Basis for Modelling Service-Oriented and Event-Driven ArchitectureA Common Basis for Modelling Service-Oriented and Event-Driven Architecture
A Common Basis for Modelling Service-Oriented and Event-Driven ArchitectureClarkTony
 
Context Aware Reactive Applications
Context Aware Reactive ApplicationsContext Aware Reactive Applications
Context Aware Reactive ApplicationsClarkTony
 
Model Slicing
Model SlicingModel Slicing
Model SlicingClarkTony
 
Kings 120711
Kings 120711Kings 120711
Kings 120711ClarkTony
 
Iswim for testing
Iswim for testingIswim for testing
Iswim for testingClarkTony
 
Iswim for testing
Iswim for testingIswim for testing
Iswim for testingClarkTony
 
Mcms and ids sig
Mcms and ids sigMcms and ids sig
Mcms and ids sigClarkTony
 
Reverse engineering and theory building v3
Reverse engineering and theory building v3Reverse engineering and theory building v3
Reverse engineering and theory building v3ClarkTony
 
Onward presentation.en
Onward presentation.enOnward presentation.en
Onward presentation.enClarkTony
 
Formalizing homogeneous language embeddings
Formalizing homogeneous language embeddingsFormalizing homogeneous language embeddings
Formalizing homogeneous language embeddingsClarkTony
 
Filmstrip testing
Filmstrip testingFilmstrip testing
Filmstrip testingClarkTony
 
Dsm as theory building
Dsm as theory buildingDsm as theory building
Dsm as theory buildingClarkTony
 
Code gen 09 kiss results
Code gen 09   kiss resultsCode gen 09   kiss results
Code gen 09 kiss resultsClarkTony
 

More from ClarkTony (20)

The Uncertain Enterprise
The Uncertain EnterpriseThe Uncertain Enterprise
The Uncertain Enterprise
 
Actors for Behavioural Simulation
Actors for Behavioural SimulationActors for Behavioural Simulation
Actors for Behavioural Simulation
 
Context-Aware Content-Centric Collaborative Workflow Management for Mobile De...
Context-Aware Content-Centric Collaborative Workflow Management for Mobile De...Context-Aware Content-Centric Collaborative Workflow Management for Mobile De...
Context-Aware Content-Centric Collaborative Workflow Management for Mobile De...
 
LEAP A Language for Architecture Design, Simulation and Analysis
LEAP A Language for Architecture Design, Simulation and AnalysisLEAP A Language for Architecture Design, Simulation and Analysis
LEAP A Language for Architecture Design, Simulation and Analysis
 
A Common Basis for Modelling Service-Oriented and Event-Driven Architecture
A Common Basis for Modelling Service-Oriented and Event-Driven ArchitectureA Common Basis for Modelling Service-Oriented and Event-Driven Architecture
A Common Basis for Modelling Service-Oriented and Event-Driven Architecture
 
Context Aware Reactive Applications
Context Aware Reactive ApplicationsContext Aware Reactive Applications
Context Aware Reactive Applications
 
Model Slicing
Model SlicingModel Slicing
Model Slicing
 
Kings 120711
Kings 120711Kings 120711
Kings 120711
 
Iswim for testing
Iswim for testingIswim for testing
Iswim for testing
 
Iswim for testing
Iswim for testingIswim for testing
Iswim for testing
 
Mcms and ids sig
Mcms and ids sigMcms and ids sig
Mcms and ids sig
 
Ocl 09
Ocl 09Ocl 09
Ocl 09
 
Scam 08
Scam 08Scam 08
Scam 08
 
Reverse engineering and theory building v3
Reverse engineering and theory building v3Reverse engineering and theory building v3
Reverse engineering and theory building v3
 
Onward presentation.en
Onward presentation.enOnward presentation.en
Onward presentation.en
 
Formalizing homogeneous language embeddings
Formalizing homogeneous language embeddingsFormalizing homogeneous language embeddings
Formalizing homogeneous language embeddings
 
Filmstrip testing
Filmstrip testingFilmstrip testing
Filmstrip testing
 
Dsm as theory building
Dsm as theory buildingDsm as theory building
Dsm as theory building
 
Code gen 09 kiss results
Code gen 09   kiss resultsCode gen 09   kiss results
Code gen 09 kiss results
 
Cg 2011
Cg 2011Cg 2011
Cg 2011
 

Recently uploaded

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 

Recently uploaded (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 

Patterns 200711

  • 1. XMF: A Language for Language Oriented Programming Tony Clark1 1 School of Engineering and Information Sciences University of Middlesex July 25, 2011
  • 2. Background • UML 2.0 started around 2000. • The 2U Submission: UML as family of languages. • Aim: to merge modelling and programming. • Tools: MMT, XMT, XMF. • Programming language based on FP and OCL. • Important features: meta-; reflection; OO. • Xactium 2003–2008.
  • 3. XMF • Meta-Circular Language (like MOF and ECore). • XCore Based on ObjvLisp. • File based or world-state. • Features for: • Packages of models/programs. • Higher-order operations. • OCL. • Meta-Object Prototcol (MOP). • Language Engineering (grammars, syntax processing). • Daemons (object listeners). • Pattern matching. • Code generation templates. • Threads. • XML processing (parsing). • Java integration.
  • 5. Models 1 context Root 2 @Class Request 3 @Attribute id : String end 4 @Constructor(id) ! end 5 end 6 7 context Root 8 @Class RBuffer 9 @Attribute requests : Seq(Request) end 10 @Constructor(requests) ! end 11 end
  • 7. Programs: XOCL 1 context RBuffer 2 @Operation add(id:String) 3 self.requests := requests + Seq{Request(id)} 4 end 5 6 context RBuffer 7 @Operation handle(id:String) 8 @Match(requests) { 9 R1 + Seq{Request(${id})} + R2 -> 10 self.requests := R1 + R2, 11 else self.error("No request with id " + id) 12 } 13 end
  • 8. Failure 1 context SeqOfElement 2 @Operation removeDups() 3 @Match(self) { 4 S1 + Seq{x} + S2 + Seq{y} + S3 -> 5 if x = y 6 then (S1+S2+S3)->removeDups 7 else fail() 8 end, 9 else self 10 } 11 end
  • 10. Quasi-Quotes 1 context Root 2 @Operation add1_exp(exp:Performable):Performable 3 [| 1 + <exp> |] 4 end 5 6 context Root 7 @Operation seq_exp(exps:Seq(Performable)):Performable 8 exps->iterate(e x = [| Seq{} |] | 9 [| <x>->including(<e>) |]) 10 end
  • 11. Grammars 1 parserImport Parser::BNF; 2 parserImport XOCL; 3 4 Root::g := 5 @Grammar 6 Start ::= i=Int o=Op j=Int { 7 @Case o of 8 "+" do i + j end 9 "*" do i * j end 10 end 11 }. 12 Op ::= ’+’ { "+" } | ’*’ { "*" }. 13 end; [ 1 ] XMF> g . parseString ( " 1 + 2 " , " S t a r t " , Seq { } ) ; 3 [ 1 ] XMF>
  • 13. Match Syntax Class 1 context Root 2 @Class Match extends XOCL::Sugar 3 @Attribute value : Performable end 4 @Attribute arms : Seq(Arm) end 5 @Attribute alt : Performable end 6 @Constructor(value,arms,alt) ! end 7 @Grammar extends OCL::OCL.grammar 8 Match ::= e=Exp ’{’ as=Arm* ’else’ a=Exp ’}’ { 9 Match(e,as,a) 10 }. 11 Arm ::= p=Pat ’->’ e=Exp ’,’ {Arm(p,e)}. 12 Pat ::= l=Atom (’+’ r=Pat {Append(l,r)} | {l}). 13 Pats ::= p=Pat ps=(’,’ Pat)* {Seq{p|ps}}. 14 Atom ::= i=Int {Const(i)} 15 | ’$’ ’{’ n=Name ’}’ {Ref(n)} 16 | v=Name (’(’ ps=Pats ’)’ {Cnstr(v,ps)} | {Var(v)}) 17 | ’Seq{’ ps=Pats ’}’ {Patterns(ps)}. 18 end 19 end
  • 14. Desugar 1 context Match 2 @Operation desugar() 3 [| let value = <value> 4 in <arms->iterate(arm exp=[| @Operation() 5 <alt> 6 end |] 7 | arm.desugar(exp))> 8 end |] 9 end
  • 15. Arms 1 context Arm 2 @Operation desugar(fail:Performable) 3 [| let fail = <fail> 4 in <pattern.match(exp)> 5 end |] 6 end
  • 16. Constants 1 context Const 2 @Operation match(succ) 3 [| if value = <const.lift()> 4 then <succ> 5 else fail() 6 end |] 7 end
  • 17. Variables and Refs 1 context Var 2 @Operation match(succ) 3 [| let <name> = value in <succ> end |] 4 end 5 6 context Ref 7 @Operation match(succ) 8 [| if value = <OCL::Var(name)> 9 then <succ> 10 else fail() 11 end |] 12 end
  • 18. Splits 1 context SeqOfElement 2 @Operation split() 3 (0.to(self->size))->iterate(i pairs=Seq{} | 4 pairs->including(Seq{self->take(i), 5 self->drop(i)})) 6 end 7 8 context SeqOfElement 9 @Operation select(succ,fail) 10 if self->isEmpty 11 then fail() 12 else succ(self->head,@Operation() 13 self->tail.select(succ,fail) 14 end) 15 end 16 end
  • 19. Append 1 context Append 2 @Operation match(succ) 3 [| if value.isKindOf(Seq(Element)) 4 then 5 value->split.select( 6 @Operation(pair,fail) 7 let value = pair->at(0) 8 in <left.match([| let value = pair->at(1) 9 in <right.match(succ)> 10 end |])> 11 end 12 end,fail) 13 else fail() 14 end |] 15 end
  • 20. Patterns 1 context Patterns 2 @Operation match(succ) 3 [| if value.isKindOf(Seq(Element)) andthen value-> size = <patterns->size.lift()> 4 then <(0.to(patterns->size-1))->iterate(i s=succ | 5 [| let value = value->at(<i.lift()>) 6 in <patterns->at(i).match(succ)> 7 end |])> 8 else fail() 9 end |] 10 end
  • 21. Constructors 1 context Cnstr 2 @Operation match(succ) 3 [| if value.of() = Root.getElement(<name.lift()>) 4 then <let c = Root.getElement(name) 5 .constructors 6 ->select(c | 7 c.names->size = 8 args->size) 9 ->asSeq->head 10 in (0.to(args->size-1))->iterate(i exp=succ| 11 [| let value = value.<c.names->at(i)> 12 in <args->at(i).match(succ)> 13 end |]) 14 end> 15 else fail() 16 end |] 17 end 18 end