SlideShare uma empresa Scribd logo
1 de 46
Baixar para ler offline
Pretty-Printing
                    Editor Services
                    Term Rewriting
                         Lecture 7



                                               Course IN4308
     Eelco Visser
                                    Master Computer Science
http://eelcovisser.org          Delft University of Technology
Outline



Pretty-printing
   ★ from abstract syntax to concrete syntax

Editor services
   ★ defining the behavior of editors

Term rewriting
   ★ transforming abstract syntax
Pretty-Printing
Pretty-Printing: Abstract to Concrete Syntax

While(
  BinOp(Var("x"), "<", IntLit("3"))
, Block(
    [Assign(
       Var("x")
     , BinOp(Var("x"), "+", IntLit("1"))
     )]
  )
)



                                       while ( (x < 3) )
                                       {
                                         x := (x + 1) ;
                                       }
Syntax
                                        Definition




                                                            Pretty-Print
                  Parse Table           Signature
                                                               Table




                    Parse              Transform            Pretty-Print


                                                                            @Entity
entity User {
                                                                           class User {
 name :: String
                                                                             String _user;
 pw :: Secret
                                                                             public User
}
                                                                               getUser() {
def output(u :

                     syntax definition is basis of language definition
                                                                               return _user;
User) {
                                                                              }
Syntax of Statements
module statements
exports
  sorts Statement
  context-free syntax
    Exp ":=" Exp ";"       ->   Statement   {cons("Assign")}
    Exp ";"                ->   Statement   {cons("ExpStat")}
    "return" PageRef ";"   ->   Statement   {cons("ReturnPage")}
    "{" Statement* "}"     ->   Block       {cons("Block")}
    Block                  ->   Statement

  sorts VarDecl
  context-free syntax
    "var" ID ":" Type          -> VarDecl {cons("VarDecl")}
    "var" ID ":" Type ":=" Exp -> VarDecl {cons("VarDeclInit")}
    VarDecl ";"                -> Statement {cons("Stat")}
    "var"                      -> ID {reject}

  context-free syntax
    "for" "(" ID ":" Type "in" Exp ")" Block -> Statement {cons("For")}
    "while" "(" Exp ")" Block                -> Statement {cons("While")}
    "if" "(" Exp ")" Block "else" Block      -> Statement {cons("If")}
Pretty-Print Table
    context-free syntax
      Exp ":=" Exp ";"            ->   Statement {cons("Assign")}
      "{" Statement* "}"          ->   Block     {cons("Block")}
      Block                       ->   Statement
      "while" "(" Exp ")" Block   ->   Statement {cons("While")}




[
 ...
 Assign            -- H[ _1 KW[":="] _2 KW[";"] ],

 Block             -- V[ V is=2[ KW["{"] _1] KW["}"]],

 Block.1:iter-star -- _1,

 While             -- V[ H[KW["while"] KW["("] _1 KW[")"]] _2],
 ...
]


                  mapping constructors to text
Formatting with Box Expressions
    context-free syntax
      Exp ":=" Exp ";"            ->   Statement {cons("Assign")}
      "{" Statement* "}"          ->   Block     {cons("Block")}
      Block                       ->   Statement
      "while" "(" Exp ")" Block   ->   Statement {cons("While")}




[
 ...
 Assign            -- H[ _1 KW[":="] _2 KW[";"] ],

 Block             -- V[ V is=2[ KW["{"] _1] KW["}"]],

 Block.1:iter-star -- _1,

 While             -- V[ H[KW["while"] KW["("] _1 KW[")"]] _2],
 ...
]
Pretty-Printing: Term to Box to Text
While(
  BinOp(Var("x"), "<", IntLit("3"))
, Block(
    [Assign(
       Var("x")
     , BinOp(Var("x"), "+", IntLit("1"))
     )]
  )
)



      V[H[KW["while"] KW["("] ... KW[")"]]
        V[V is=2[KW["{"]
          ... ]
          KW["}"]]                           while ( (x < 3) )
      ]                                      {
                                               x := (x + 1) ;
                                             }
Generated Pretty-Print Table



[ ...
  Assign              --   _1 KW[":="] _2 KW[";"],
  ExpStat             --   _1 KW[";"],
  ReturnPage          --   KW["return"] _1 KW[";"],
  Block               --   KW["{"] _1] KW["}"],
  Block.1:iter-star   --   _1,
  VarDecl             --   KW["var"] _1 KW[":"] _2,
  VarDeclInit         --   KW["var"] _1 KW[":"] _2 KW[":="] _3,
  Stat                --   _1 KW[";"],
  For                 --   KW["for"] KW["("] _1 KW[":"] _2 KW["in"] _3 KW[")"] _4,
  While               --   KW["while"] KW["("] _1 KW[")"] _2],
  If                  --   KW["if"] KW["("] _1 KW[")"] _2 KW["else"] _3,
  ...
]
Pretty-Print Table with Box Markup



[ ...
 Assign              --   H[_1 KW[":="] _2 KW[";"]],
 ExpStat             --   H hs=0[_1 KW[";"]],
 ReturnPage          --   H hs=0 [KW["return"] _1 KW[";"]],
 Block               --   V [V is=2 [KW["{"] _1] KW["}"]],
 Block.1:iter-star   --   _1,
 VarDecl             --   H [KW["var"] _1 KW[":"] _2],
 VarDeclInit         --   H [KW["var"] _1 KW[":"] _2 KW[":="] _3],
 Stat                --   H hs=0 [_1 KW[";"]],
 For                 --   V[H[KW["for"] KW["("] _1 KW[":"] _2 KW["in"] _3 KW[")"]] _4],
 While               --   V[H[KW["while"] KW["("] _1 KW[")"]] _2],
 If                  --   V [ V is=2[
                            H[KW["if"] KW["("] _1 KW[")"]] _2]
                            V is=2[ KW["else"] _3]],
 ...
]
Presentational
Editor Services
Editor Services

Syntax highlighting
   ★ token coloring

Code folding
   ★ folding & unfolding code fragments

Outline view
   ★ table of contents

Syntax properties
   ★ bracket matching, indentation

Syntax completion
   ★ match on syntactic triggers & replace with template
Editor Services Composition

module nwl.main

imports nwl-Builders nwl-Colorer nwl-Folding nwl-Outliner
        nwl-References nwl-Syntax nwl-Completions

language General properties

  name            : nwl
  id              : nwl
  extends         : Root

  description     : "Spoofax/IMP-generated editor for the nwl language"
  url             : http://strategoxt.org

  extensions    : nwl
  table         : include/nwl.tbl
  start symbols : Start
Syntax
                         Definition




Default Syntax         Default               Default
 Highlighting        Code Folding          Outline View



     Custom Syntax            Custom             Custom
+     Highlighting   +      Code Folding   +    Outline View




                          Editor
Code Folding


          module nwl-Folding.generated
          folding Default folding
            Start.Module
            Definition.Entity
            Property.Property
            Definition.TemplateDef
            Element.CallArgs
            PageRef.PageRef
            Element.Action


          module nwl-Folding
          imports nwl-Folding.generated
          folding
            Element.CallElems
            Element.Call
            Element.ForElem
            Element.ForAllElem
Outline View


          module nwl-Outliner.generated
          outliner Default outliner
            Start.Module
            Definition.Entity
            Property.Property
            Definition.TemplateDef
            Element.CallArgs
            Exp.MethodCall
            Element.CallElems
            Element.Call
            Element.ForElem
            Element.ForAllElem
            PageRef.PageRef
            Element.Action
            Statement.For
            Statement.While
            Statement.If
            Element.Submit
            Element.XmlElem
module nwl-Colorer.generated
                              colorer Default, token-based highlighting
Default Syntax Highlighting     keyword    : 127 0 85 bold
                                identifier : default
                                string     : blue
                                number     : darkgreen
                                var        : 255 0 100 italic
                                operator   : 0 0 128
                                layout     : 100 100 0 italic
                              colorer System colors
                                darkred   = 128 0 0
                                red       = 255 0 0
                                darkgreen = 0 128 0
                                green     = 0 255 0
                                darkblue = 0 0 128
                                blue      = 0 0 255
                                cyan      = 0 255 255
                                magenta   = 255 0 255
                                yellow    = 255 255 0
                                white     = 255 255 255
                                black     = 0 0 0
                                gray      = 128 128 128
                                grey      = gray
                                orange    = 255 165 0
                                pink      = 255 105 180
                                brown     = 139 69 19
                                default   = _
Custom Syntax Highlighting




                module nwl-Colorer
                imports nwl-Colorer.generated
                colorer
                  Element : darkgreen
Syntax Properties

module nwl-Syntax.generated
language Syntax properties (static defaults)

 // Comment constructs:
 line comment                            : "//"
 block comment                           : "/*" * "*/"

 // Fences (used for matching,
 // inserting, indenting brackets):
 fences                                  : [ ]
                                           ( )
                                           { }
 // Automatic indent hints
 // (indent after these tokens):
 indent after                            : "="
                                           ":"
 // Regular expression for identifiers:
 identifier lexical                     : "[A-Za-z0-9_]+"
Builders
Semantic Editor Services
Builders: Analysis & Transformation Services

module nwl-Builders
builders
  provider: include/nwl.ctree

  observer: editor-analyze

  builder : "Generate Java code" =
    generate-java (openeditor) (realtime)

  builder : "Show ATerm (selection)" =
    generate-aterm (openeditor) (realtime) (meta)

  builder : "Normalize (selection)" =
    show-normalized (openeditor) (realtime) (meta)

  builder : "Normalize Pretty (selection)" =
    show-normalized-pp (openeditor) (realtime) (meta)
Term Rewriting
Term Rewriting



Term rewrite rules
   ★ transform term to term
   ★ pattern matching
   ★ variable binding
   ★ substitution

Rewriting strategy
   ★ algorithm for applying rewrite rules
Grammar to Signature

context-free syntax
  "entity" ID "{" Property* "}"         -> Definition {cons("Entity")}
  ID ":" Type                           -> Property   {cons("Property")}
  ID ":" Type "(" {Annotation ","}* ")" -> Property   {cons("Property")}




      module nwl
      signature
        constructors
          Entity   : ID * List(Property) -> Definition
          Property : ID * Type * List(Annotation) -> Property
          Property : ID * Type -> Property
Desugaring: Syntactic Normalization

Entity("Blog"
, [ Property("url", SimpleType("String"), [Id()])
  , Property("name", SimpleType("String"), [Name()])
  , Property("posts", SetType(SimpleType("Post")))
  , Property("author", SimpleType("User"))
  ]
)




                       Entity("Blog"
                       , [ Property("url", SimpleType("String"), [Id()])
                         , Property("name", SimpleType("String"), [Name()])
                         , Property("posts", SetType(SimpleType("Post")), [])
                         , Property("author", SimpleType("User"), [])
                         ]
                       )
Term Rewriting in Stratego

                         import signature

module desugar

imports include/nwl                             rewrite rule

rules

  desugar :
    Property(x, t) -> Property(x, t, [])

strategies

  desugar-all =
    innermost(desugar)


                                            strategy
Term Rewrite Rule


                         left-hand side pattern
label/name



      desugar :
        Property(x, t) -> Property(x, t, [])



             variable
                                                  right-hand side pattern
Rewrite Rule Application

                Property("author", SimpleType("User"))
pattern                                                      variable
matching                                                     binding

       desugar :
         Property(x, t) -> Property(x, t, [])

   pattern
                                                         substitution
instantiation


           Property("author", SimpleType("User"), [])
Rewrite Strategy


                                  generic strategy
strategy definition



     desugar-all = innermost(desugar)



                                              strategy instantiation



              apply transformation s exhaustively to all sub-
 innermost(s)
                terms of subject term in bottom-up order
More Syntactic Normalizations


rules

  desugar :
    CallArgs(x, e*) -> Call(x, e*, [])

  desugar :
    CallElems(x, elem*) -> Call(x, [], elem*)

  desugar :
    Call(x) -> Call(x, [], [])

  desugar :
    Property(x, t) -> Property(x, t, [])
Generic Representation for Binary Operators

  signature
    constructors
      BinOp : Exp * Op * Exp -> Exp

  rules

    desugar :
      Lt(e1, e2) -> BinOp(e1, "<", e2)

    desugar :
      Plus(e1, e2) -> BinOp(e1, "+", e2)

    desugar :
      Times(e1, e2) -> BinOp(e1, "*", e2)

    desugar :
      UnaryMinus(e) -> BinOp(IntLit("0"), "-", e)
x := a + b * 3 / c;

         Assign(
           Var("x")
         , Plus(
             Var("a")
           , Div(Times(Var("b"), IntLit("3")), Var("c"))
parse
           )
         )

                          Assign(
                            Var("x")
                          , BinOp(
                              Var("a")
                            , "+"
                            , BinOp(
                                BinOp(Var("b"), "+", IntLit("3"))
           desugar            , "/"
                              , Var("c")
                              )
                            )
                          )
Applying Transformation in Editor
Binding Transformation to Editor Service

                                   editor interface
                                                                         behavior
                module nwl-Builders
                builders
                  builder : "Desugar (selection)" =
                    show-desugared (openeditor) (realtime) (meta)


 Stratego interface
                                                  standard calling
                                               convention for builders
rules

  show-desugared :
    (selected, position, ast, path, project-path) -> (filename, result-string)
    with
      filename      := <guarantee-extension(|"aterm")> path;
      result-string := <desugar-all; pp-aterm-box; box2text-string(|120)> selected



         transformation
Constant Folding
y := a + (3 * 5 - 17);


        Assign(
          Var("y")
        , Plus(
            Var("a")
          , Minus(Times(IntLit("3"), IntLit("5")), IntLit("17"))
parse     )
        )


                   Assign(
                     Var("y")
                   , BinOp(Var("a"), "+", IntLit("25"))
 desugar + eval    )


                                                  y := (a + 25);
                                   pretty-print
Constant Folding Rules

strategies

 eval-all = innermost(desugar + eval)

rules

 eval :
   BinOp(IntLit(x), "+", IntLit(y)) -> IntLit(<addS>(x, y))

 eval :
   BinOp(IntLit(x), "-", IntLit(y)) -> IntLit(<subtS>(x, y))

 eval :
   BinOp(IntLit(x), "*", IntLit(y)) -> IntLit(<mulS>(x, y))

 eval :
   BinOp(IntLit(x), "/", IntLit(y)) -> IntLit(<divS>(x, y))
Conditional Rewrite Rules

                                    bound in condition

            eval :
              BinOp(IntLit(x), "+", IntLit(y)) -> IntLit(z)
condition     where z := <addS>(x, y)




               match          apply transformation


     eval :
       BinOp(IntLit(x), "+", IntLit(y)) -> IntLit(<addS>(x, y))
For to While


action foo() {
  for(p : Post in b.posts) {
    p.title := "foo";
  }                                   action foo ( ) {
}                                       var i : Int := 0;
                                        var c : Set<Post> := b.posts;
                                        var l : Int := c.length();
                                        while (i < l) {
                                          var p : Post := c[i];
                                          p.title := "foo" ;
                                          i := i + 1;
                                        }
                                      }


                     specification (by example)
For to While: Transformation Schema




for(x : t in e) b
                                    var i : Int := 0;
                                    var c : Set<t> := e;
                                    var l : Int := c.length();
                                    while (i < l) {
                                      var x : t := c[i];
                                      b
                                      i := i + 1;
                                    }




                    abstraction of example
For to While: Rewrite Rule

normalize :
  For(x, t, e, b) ->
  Block([
    Stat(VarDeclInit(i, SimpleType("Int"), IntLit("0"))),
    Stat(VarDeclInit(c, SimpleType(t), e)),
    Stat(VarDeclInit(l, SimpleType("Int"),
                      MethodCall(Var(c), "length", []))),
    While(BinOp(Var(i), "<", Var(l)), Block([
       Stat(VarDeclInit(x, t, IndexAccess(Var(c), Var(i)))),
       b,
       Assign(Var(i), BinOp(Var(i), "+", IntLit("1")))
     ]))
  ])
  where i := <newname> "i";
         c := <newname> "c";
         l := <newname> "l"
For to While: Result

action foo() {                       specification by example
  for(p : Post in b.posts) {
    p.title := "foo";
                                           action foo ( ) {
  }
                                             var i : Int := 0;
}
                                             var c : Set<Post> := b.posts;
                                             var l : Int := c.length();
action foo ( ) {                             while (i < l) {
  {                                            var p : Post := c[i];
    var i0 : Int := 0;                         p.title := "foo" ;
    var c0 : Set<Post> := b.posts;             i := i + 1;
    var l0 : Int := c0.length();             }
    while ( (i0 < l0) )                    }
    {
      var p : Post := c0[i0];
      p.title := "foo" ;
      i0 := (i0 + 1) ;
    }
  }
}                                        result
Normalization Strategy

strategies

  normalize-all =
    innermost(desugar + normalize)

rules

 normalize :
   For(x, t, e, b) ->
   Block([
      Stat(VarDecl(...
   ])

 normalize :
   [Block(stat1*) | stat2*] -> <conc> (stat1*, stat2*)



             (is that a correct transformation?)
For to While: Final Result

action foo() {                     specification by example
  for(p : Post in b.posts) {
    p.title := "foo";
                                         action foo ( ) {
  }
                                           var i : Int := 0;
}
                                           var c : Set<Post> := b.posts;
                                           var l : Int := c.length();
                                           while (i < l) {
action foo ( ) {                             var p : Post := c[i];
  var i0 : Int := 0;                         p.title := "foo" ;
  var c0 : Set<Post> := b.posts;             i := i + 1;
  var l0 : Int := c0.length();             }
  while ( (i0 < l0) )                    }
  {
    var p : Post := c0[i0];
    p.title := "foo" ;
    i0 := (i0 + 1) ;
  }
}
                                       result
Normalization Strategy

strategies

  normalize-all =
    innermost(desugar + normalize)

rules

 normalize :
   For(x, t, e, b) ->
   Block([
      Stat(VarDecl(...
   ])

 normalize :
   Block([Block(stat*)]) -> Block(stat*)
Schedule


Lab this week
  ★ Design 1: deadline is April 1
  ★ Design 2: what DSL will you design?

Cases
  ★ Case 2: web abstractions
  ★ Deadline Case 2: April 8
  ★ Case 3:

Next
  ★ Lecture 8: code generation

Mais conteúdo relacionado

Mais procurados

Scoobi - Scala for Startups
Scoobi - Scala for StartupsScoobi - Scala for Startups
Scoobi - Scala for Startupsbmlever
 
Advanced Php - Macq Electronique 2010
Advanced Php - Macq Electronique 2010Advanced Php - Macq Electronique 2010
Advanced Php - Macq Electronique 2010Michelangelo van Dam
 
concurrency gpars
concurrency gparsconcurrency gpars
concurrency gparsPaul King
 
11. session 11 functions and objects
11. session 11   functions and objects11. session 11   functions and objects
11. session 11 functions and objectsPhúc Đỗ
 
concurrency with GPars
concurrency with GParsconcurrency with GPars
concurrency with GParsPaul King
 
Kotlin @ Coupang Backend 2017
Kotlin @ Coupang Backend 2017Kotlin @ Coupang Backend 2017
Kotlin @ Coupang Backend 2017Sunghyouk Bae
 
GPars (Groovy Parallel Systems)
GPars (Groovy Parallel Systems)GPars (Groovy Parallel Systems)
GPars (Groovy Parallel Systems)Gagan Agrawal
 
Kotlin @ Coupang Backed - JetBrains Day seoul 2018
Kotlin @ Coupang Backed - JetBrains Day seoul 2018Kotlin @ Coupang Backed - JetBrains Day seoul 2018
Kotlin @ Coupang Backed - JetBrains Day seoul 2018Sunghyouk Bae
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Jonas Bonér
 
awesome groovy
awesome groovyawesome groovy
awesome groovyPaul King
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
CS101- Introduction to Computing- Lecture 26
CS101- Introduction to Computing- Lecture 26CS101- Introduction to Computing- Lecture 26
CS101- Introduction to Computing- Lecture 26Bilal Ahmed
 

Mais procurados (20)

Scoobi - Scala for Startups
Scoobi - Scala for StartupsScoobi - Scala for Startups
Scoobi - Scala for Startups
 
Advanced Php - Macq Electronique 2010
Advanced Php - Macq Electronique 2010Advanced Php - Macq Electronique 2010
Advanced Php - Macq Electronique 2010
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
concurrency gpars
concurrency gparsconcurrency gpars
concurrency gpars
 
11. session 11 functions and objects
11. session 11   functions and objects11. session 11   functions and objects
11. session 11 functions and objects
 
Requery overview
Requery overviewRequery overview
Requery overview
 
Scalding for Hadoop
Scalding for HadoopScalding for Hadoop
Scalding for Hadoop
 
Dartprogramming
DartprogrammingDartprogramming
Dartprogramming
 
concurrency with GPars
concurrency with GParsconcurrency with GPars
concurrency with GPars
 
Kotlin @ Coupang Backend 2017
Kotlin @ Coupang Backend 2017Kotlin @ Coupang Backend 2017
Kotlin @ Coupang Backend 2017
 
Spring data
Spring dataSpring data
Spring data
 
GPars (Groovy Parallel Systems)
GPars (Groovy Parallel Systems)GPars (Groovy Parallel Systems)
GPars (Groovy Parallel Systems)
 
Kotlin @ Coupang Backed - JetBrains Day seoul 2018
Kotlin @ Coupang Backed - JetBrains Day seoul 2018Kotlin @ Coupang Backed - JetBrains Day seoul 2018
Kotlin @ Coupang Backed - JetBrains Day seoul 2018
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)
 
awesome groovy
awesome groovyawesome groovy
awesome groovy
 
The Xtext Grammar Language
The Xtext Grammar LanguageThe Xtext Grammar Language
The Xtext Grammar Language
 
Xtext Eclipse Con
Xtext Eclipse ConXtext Eclipse Con
Xtext Eclipse Con
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
CS101- Introduction to Computing- Lecture 26
CS101- Introduction to Computing- Lecture 26CS101- Introduction to Computing- Lecture 26
CS101- Introduction to Computing- Lecture 26
 
Dart
DartDart
Dart
 

Semelhante a Model-Driven Software Development - Pretty-Printing, Editor Services, Term Rewriting

Type safe embedded domain-specific languages
Type safe embedded domain-specific languagesType safe embedded domain-specific languages
Type safe embedded domain-specific languagesArthur Xavier
 
Леонид Шевцов «Clojure в деле»
Леонид Шевцов «Clojure в деле»Леонид Шевцов «Clojure в деле»
Леонид Шевцов «Clojure в деле»DataArt
 
Erlang for data ops
Erlang for data opsErlang for data ops
Erlang for data opsmnacos
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to PythonUC San Diego
 
(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?Tomasz Wrobel
 
A Few of My Favorite (Python) Things
A Few of My Favorite (Python) ThingsA Few of My Favorite (Python) Things
A Few of My Favorite (Python) ThingsMichael Pirnat
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghStuart Roebuck
 
Kotlin coroutines and spring framework
Kotlin coroutines and spring frameworkKotlin coroutines and spring framework
Kotlin coroutines and spring frameworkSunghyouk Bae
 
Clojure Intro
Clojure IntroClojure Intro
Clojure Introthnetos
 
CS101- Introduction to Computing- Lecture 29
CS101- Introduction to Computing- Lecture 29CS101- Introduction to Computing- Lecture 29
CS101- Introduction to Computing- Lecture 29Bilal Ahmed
 
Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기JangHyuk You
 
Ekeko Technology Showdown at SoTeSoLa 2012
Ekeko Technology Showdown at SoTeSoLa 2012Ekeko Technology Showdown at SoTeSoLa 2012
Ekeko Technology Showdown at SoTeSoLa 2012Coen De Roover
 
Model-Driven Software Development - Static Analysis & Error Checking
Model-Driven Software Development - Static Analysis & Error CheckingModel-Driven Software Development - Static Analysis & Error Checking
Model-Driven Software Development - Static Analysis & Error CheckingEelco Visser
 
(first '(Clojure.))
(first '(Clojure.))(first '(Clojure.))
(first '(Clojure.))niklal
 

Semelhante a Model-Driven Software Development - Pretty-Printing, Editor Services, Term Rewriting (20)

Grammarware Memes
Grammarware MemesGrammarware Memes
Grammarware Memes
 
Term Rewriting
Term RewritingTerm Rewriting
Term Rewriting
 
Type safe embedded domain-specific languages
Type safe embedded domain-specific languagesType safe embedded domain-specific languages
Type safe embedded domain-specific languages
 
Interpreter Case Study - Design Patterns
Interpreter Case Study - Design PatternsInterpreter Case Study - Design Patterns
Interpreter Case Study - Design Patterns
 
Леонид Шевцов «Clojure в деле»
Леонид Шевцов «Clojure в деле»Леонид Шевцов «Clojure в деле»
Леонид Шевцов «Clojure в деле»
 
Erlang for data ops
Erlang for data opsErlang for data ops
Erlang for data ops
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?
 
A Few of My Favorite (Python) Things
A Few of My Favorite (Python) ThingsA Few of My Favorite (Python) Things
A Few of My Favorite (Python) Things
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup Edinburgh
 
Hw09 Hadoop + Clojure
Hw09   Hadoop + ClojureHw09   Hadoop + Clojure
Hw09 Hadoop + Clojure
 
Coding in Style
Coding in StyleCoding in Style
Coding in Style
 
Kotlin coroutines and spring framework
Kotlin coroutines and spring frameworkKotlin coroutines and spring framework
Kotlin coroutines and spring framework
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
 
Clojure Intro
Clojure IntroClojure Intro
Clojure Intro
 
CS101- Introduction to Computing- Lecture 29
CS101- Introduction to Computing- Lecture 29CS101- Introduction to Computing- Lecture 29
CS101- Introduction to Computing- Lecture 29
 
Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기
 
Ekeko Technology Showdown at SoTeSoLa 2012
Ekeko Technology Showdown at SoTeSoLa 2012Ekeko Technology Showdown at SoTeSoLa 2012
Ekeko Technology Showdown at SoTeSoLa 2012
 
Model-Driven Software Development - Static Analysis & Error Checking
Model-Driven Software Development - Static Analysis & Error CheckingModel-Driven Software Development - Static Analysis & Error Checking
Model-Driven Software Development - Static Analysis & Error Checking
 
(first '(Clojure.))
(first '(Clojure.))(first '(Clojure.))
(first '(Clojure.))
 

Mais de Eelco Visser

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
 
CS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesCS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesEelco Visser
 
CS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | ParsingCS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | ParsingEelco Visser
 
CS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionCS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionEelco Visser
 
CS4200 2019 Lecture 1: Introduction
CS4200 2019 Lecture 1: IntroductionCS4200 2019 Lecture 1: Introduction
CS4200 2019 Lecture 1: IntroductionEelco Visser
 
A Direct Semantics of Declarative Disambiguation Rules
A Direct Semantics of Declarative Disambiguation RulesA Direct Semantics of Declarative Disambiguation Rules
A Direct Semantics of Declarative Disambiguation RulesEelco Visser
 
Declarative Type System Specification with Statix
Declarative Type System Specification with StatixDeclarative Type System Specification with Statix
Declarative Type System Specification with StatixEelco Visser
 
Compiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler ConstructionCompiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler ConstructionEelco Visser
 
Domain Specific Languages for Parallel Graph AnalytiX (PGX)
Domain Specific Languages for Parallel Graph AnalytiX (PGX)Domain Specific Languages for Parallel Graph AnalytiX (PGX)
Domain Specific Languages for Parallel Graph AnalytiX (PGX)Eelco Visser
 
Compiler Construction | Lecture 15 | Memory Management
Compiler Construction | Lecture 15 | Memory ManagementCompiler Construction | Lecture 15 | Memory Management
Compiler Construction | Lecture 15 | Memory ManagementEelco Visser
 
Compiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | InterpretersCompiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | InterpretersEelco Visser
 
Compiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code GenerationCompiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code GenerationEelco Visser
 
Compiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesCompiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesEelco Visser
 
Compiler Construction | Lecture 11 | Monotone Frameworks
Compiler Construction | Lecture 11 | Monotone FrameworksCompiler Construction | Lecture 11 | Monotone Frameworks
Compiler Construction | Lecture 11 | Monotone FrameworksEelco Visser
 
Compiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow AnalysisCompiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow AnalysisEelco Visser
 
Compiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint ResolutionCompiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint ResolutionEelco Visser
 
Compiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type ConstraintsCompiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type ConstraintsEelco Visser
 
Compiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingCompiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingEelco Visser
 
Compiler Construction | Lecture 6 | Introduction to Static Analysis
Compiler Construction | Lecture 6 | Introduction to Static AnalysisCompiler Construction | Lecture 6 | Introduction to Static Analysis
Compiler Construction | Lecture 6 | Introduction to Static AnalysisEelco Visser
 
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
 

Mais de Eelco Visser (20)

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
 
CS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesCS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic Services
 
CS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | ParsingCS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | Parsing
 
CS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionCS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definition
 
CS4200 2019 Lecture 1: Introduction
CS4200 2019 Lecture 1: IntroductionCS4200 2019 Lecture 1: Introduction
CS4200 2019 Lecture 1: Introduction
 
A Direct Semantics of Declarative Disambiguation Rules
A Direct Semantics of Declarative Disambiguation RulesA Direct Semantics of Declarative Disambiguation Rules
A Direct Semantics of Declarative Disambiguation Rules
 
Declarative Type System Specification with Statix
Declarative Type System Specification with StatixDeclarative Type System Specification with Statix
Declarative Type System Specification with Statix
 
Compiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler ConstructionCompiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler Construction
 
Domain Specific Languages for Parallel Graph AnalytiX (PGX)
Domain Specific Languages for Parallel Graph AnalytiX (PGX)Domain Specific Languages for Parallel Graph AnalytiX (PGX)
Domain Specific Languages for Parallel Graph AnalytiX (PGX)
 
Compiler Construction | Lecture 15 | Memory Management
Compiler Construction | Lecture 15 | Memory ManagementCompiler Construction | Lecture 15 | Memory Management
Compiler Construction | Lecture 15 | Memory Management
 
Compiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | InterpretersCompiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | Interpreters
 
Compiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code GenerationCompiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code Generation
 
Compiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesCompiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual Machines
 
Compiler Construction | Lecture 11 | Monotone Frameworks
Compiler Construction | Lecture 11 | Monotone FrameworksCompiler Construction | Lecture 11 | Monotone Frameworks
Compiler Construction | Lecture 11 | Monotone Frameworks
 
Compiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow AnalysisCompiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow Analysis
 
Compiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint ResolutionCompiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint Resolution
 
Compiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type ConstraintsCompiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type Constraints
 
Compiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingCompiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type Checking
 
Compiler Construction | Lecture 6 | Introduction to Static Analysis
Compiler Construction | Lecture 6 | Introduction to Static AnalysisCompiler Construction | Lecture 6 | Introduction to Static Analysis
Compiler Construction | Lecture 6 | Introduction to Static Analysis
 
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
 

Último

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)Samir Dash
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
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
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 

Último (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
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
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 

Model-Driven Software Development - Pretty-Printing, Editor Services, Term Rewriting

  • 1. Pretty-Printing Editor Services Term Rewriting Lecture 7 Course IN4308 Eelco Visser Master Computer Science http://eelcovisser.org Delft University of Technology
  • 2. Outline Pretty-printing ★ from abstract syntax to concrete syntax Editor services ★ defining the behavior of editors Term rewriting ★ transforming abstract syntax
  • 4. Pretty-Printing: Abstract to Concrete Syntax While( BinOp(Var("x"), "<", IntLit("3")) , Block( [Assign( Var("x") , BinOp(Var("x"), "+", IntLit("1")) )] ) ) while ( (x < 3) ) { x := (x + 1) ; }
  • 5. Syntax Definition Pretty-Print Parse Table Signature Table Parse Transform Pretty-Print @Entity entity User { class User { name :: String String _user; pw :: Secret public User } getUser() { def output(u : syntax definition is basis of language definition return _user; User) { }
  • 6. Syntax of Statements module statements exports sorts Statement context-free syntax Exp ":=" Exp ";" -> Statement {cons("Assign")} Exp ";" -> Statement {cons("ExpStat")} "return" PageRef ";" -> Statement {cons("ReturnPage")} "{" Statement* "}" -> Block {cons("Block")} Block -> Statement sorts VarDecl context-free syntax "var" ID ":" Type -> VarDecl {cons("VarDecl")} "var" ID ":" Type ":=" Exp -> VarDecl {cons("VarDeclInit")} VarDecl ";" -> Statement {cons("Stat")} "var" -> ID {reject} context-free syntax "for" "(" ID ":" Type "in" Exp ")" Block -> Statement {cons("For")} "while" "(" Exp ")" Block -> Statement {cons("While")} "if" "(" Exp ")" Block "else" Block -> Statement {cons("If")}
  • 7. Pretty-Print Table context-free syntax Exp ":=" Exp ";" -> Statement {cons("Assign")} "{" Statement* "}" -> Block {cons("Block")} Block -> Statement "while" "(" Exp ")" Block -> Statement {cons("While")} [ ... Assign -- H[ _1 KW[":="] _2 KW[";"] ], Block -- V[ V is=2[ KW["{"] _1] KW["}"]], Block.1:iter-star -- _1, While -- V[ H[KW["while"] KW["("] _1 KW[")"]] _2], ... ] mapping constructors to text
  • 8. Formatting with Box Expressions context-free syntax Exp ":=" Exp ";" -> Statement {cons("Assign")} "{" Statement* "}" -> Block {cons("Block")} Block -> Statement "while" "(" Exp ")" Block -> Statement {cons("While")} [ ... Assign -- H[ _1 KW[":="] _2 KW[";"] ], Block -- V[ V is=2[ KW["{"] _1] KW["}"]], Block.1:iter-star -- _1, While -- V[ H[KW["while"] KW["("] _1 KW[")"]] _2], ... ]
  • 9. Pretty-Printing: Term to Box to Text While( BinOp(Var("x"), "<", IntLit("3")) , Block( [Assign( Var("x") , BinOp(Var("x"), "+", IntLit("1")) )] ) ) V[H[KW["while"] KW["("] ... KW[")"]] V[V is=2[KW["{"] ... ] KW["}"]] while ( (x < 3) ) ] { x := (x + 1) ; }
  • 10. Generated Pretty-Print Table [ ... Assign -- _1 KW[":="] _2 KW[";"], ExpStat -- _1 KW[";"], ReturnPage -- KW["return"] _1 KW[";"], Block -- KW["{"] _1] KW["}"], Block.1:iter-star -- _1, VarDecl -- KW["var"] _1 KW[":"] _2, VarDeclInit -- KW["var"] _1 KW[":"] _2 KW[":="] _3, Stat -- _1 KW[";"], For -- KW["for"] KW["("] _1 KW[":"] _2 KW["in"] _3 KW[")"] _4, While -- KW["while"] KW["("] _1 KW[")"] _2], If -- KW["if"] KW["("] _1 KW[")"] _2 KW["else"] _3, ... ]
  • 11. Pretty-Print Table with Box Markup [ ... Assign -- H[_1 KW[":="] _2 KW[";"]], ExpStat -- H hs=0[_1 KW[";"]], ReturnPage -- H hs=0 [KW["return"] _1 KW[";"]], Block -- V [V is=2 [KW["{"] _1] KW["}"]], Block.1:iter-star -- _1, VarDecl -- H [KW["var"] _1 KW[":"] _2], VarDeclInit -- H [KW["var"] _1 KW[":"] _2 KW[":="] _3], Stat -- H hs=0 [_1 KW[";"]], For -- V[H[KW["for"] KW["("] _1 KW[":"] _2 KW["in"] _3 KW[")"]] _4], While -- V[H[KW["while"] KW["("] _1 KW[")"]] _2], If -- V [ V is=2[ H[KW["if"] KW["("] _1 KW[")"]] _2] V is=2[ KW["else"] _3]], ... ]
  • 13. Editor Services Syntax highlighting ★ token coloring Code folding ★ folding & unfolding code fragments Outline view ★ table of contents Syntax properties ★ bracket matching, indentation Syntax completion ★ match on syntactic triggers & replace with template
  • 14. Editor Services Composition module nwl.main imports nwl-Builders nwl-Colorer nwl-Folding nwl-Outliner nwl-References nwl-Syntax nwl-Completions language General properties name : nwl id : nwl extends : Root description : "Spoofax/IMP-generated editor for the nwl language" url : http://strategoxt.org extensions : nwl table : include/nwl.tbl start symbols : Start
  • 15. Syntax Definition Default Syntax Default Default Highlighting Code Folding Outline View Custom Syntax Custom Custom + Highlighting + Code Folding + Outline View Editor
  • 16. Code Folding module nwl-Folding.generated folding Default folding Start.Module Definition.Entity Property.Property Definition.TemplateDef Element.CallArgs PageRef.PageRef Element.Action module nwl-Folding imports nwl-Folding.generated folding Element.CallElems Element.Call Element.ForElem Element.ForAllElem
  • 17. Outline View module nwl-Outliner.generated outliner Default outliner Start.Module Definition.Entity Property.Property Definition.TemplateDef Element.CallArgs Exp.MethodCall Element.CallElems Element.Call Element.ForElem Element.ForAllElem PageRef.PageRef Element.Action Statement.For Statement.While Statement.If Element.Submit Element.XmlElem
  • 18. module nwl-Colorer.generated colorer Default, token-based highlighting Default Syntax Highlighting keyword : 127 0 85 bold identifier : default string : blue number : darkgreen var : 255 0 100 italic operator : 0 0 128 layout : 100 100 0 italic colorer System colors darkred = 128 0 0 red = 255 0 0 darkgreen = 0 128 0 green = 0 255 0 darkblue = 0 0 128 blue = 0 0 255 cyan = 0 255 255 magenta = 255 0 255 yellow = 255 255 0 white = 255 255 255 black = 0 0 0 gray = 128 128 128 grey = gray orange = 255 165 0 pink = 255 105 180 brown = 139 69 19 default = _
  • 19. Custom Syntax Highlighting module nwl-Colorer imports nwl-Colorer.generated colorer Element : darkgreen
  • 20. Syntax Properties module nwl-Syntax.generated language Syntax properties (static defaults) // Comment constructs: line comment : "//" block comment : "/*" * "*/" // Fences (used for matching, // inserting, indenting brackets): fences : [ ] ( ) { } // Automatic indent hints // (indent after these tokens): indent after : "=" ":" // Regular expression for identifiers: identifier lexical : "[A-Za-z0-9_]+"
  • 22. Builders: Analysis & Transformation Services module nwl-Builders builders provider: include/nwl.ctree observer: editor-analyze builder : "Generate Java code" = generate-java (openeditor) (realtime) builder : "Show ATerm (selection)" = generate-aterm (openeditor) (realtime) (meta) builder : "Normalize (selection)" = show-normalized (openeditor) (realtime) (meta) builder : "Normalize Pretty (selection)" = show-normalized-pp (openeditor) (realtime) (meta)
  • 24. Term Rewriting Term rewrite rules ★ transform term to term ★ pattern matching ★ variable binding ★ substitution Rewriting strategy ★ algorithm for applying rewrite rules
  • 25. Grammar to Signature context-free syntax "entity" ID "{" Property* "}" -> Definition {cons("Entity")} ID ":" Type -> Property {cons("Property")} ID ":" Type "(" {Annotation ","}* ")" -> Property {cons("Property")} module nwl signature constructors Entity : ID * List(Property) -> Definition Property : ID * Type * List(Annotation) -> Property Property : ID * Type -> Property
  • 26. Desugaring: Syntactic Normalization Entity("Blog" , [ Property("url", SimpleType("String"), [Id()]) , Property("name", SimpleType("String"), [Name()]) , Property("posts", SetType(SimpleType("Post"))) , Property("author", SimpleType("User")) ] ) Entity("Blog" , [ Property("url", SimpleType("String"), [Id()]) , Property("name", SimpleType("String"), [Name()]) , Property("posts", SetType(SimpleType("Post")), []) , Property("author", SimpleType("User"), []) ] )
  • 27. Term Rewriting in Stratego import signature module desugar imports include/nwl rewrite rule rules desugar : Property(x, t) -> Property(x, t, []) strategies desugar-all = innermost(desugar) strategy
  • 28. Term Rewrite Rule left-hand side pattern label/name desugar : Property(x, t) -> Property(x, t, []) variable right-hand side pattern
  • 29. Rewrite Rule Application Property("author", SimpleType("User")) pattern variable matching binding desugar : Property(x, t) -> Property(x, t, []) pattern substitution instantiation Property("author", SimpleType("User"), [])
  • 30. Rewrite Strategy generic strategy strategy definition desugar-all = innermost(desugar) strategy instantiation apply transformation s exhaustively to all sub- innermost(s) terms of subject term in bottom-up order
  • 31. More Syntactic Normalizations rules desugar : CallArgs(x, e*) -> Call(x, e*, []) desugar : CallElems(x, elem*) -> Call(x, [], elem*) desugar : Call(x) -> Call(x, [], []) desugar : Property(x, t) -> Property(x, t, [])
  • 32. Generic Representation for Binary Operators signature constructors BinOp : Exp * Op * Exp -> Exp rules desugar : Lt(e1, e2) -> BinOp(e1, "<", e2) desugar : Plus(e1, e2) -> BinOp(e1, "+", e2) desugar : Times(e1, e2) -> BinOp(e1, "*", e2) desugar : UnaryMinus(e) -> BinOp(IntLit("0"), "-", e)
  • 33. x := a + b * 3 / c; Assign( Var("x") , Plus( Var("a") , Div(Times(Var("b"), IntLit("3")), Var("c")) parse ) ) Assign( Var("x") , BinOp( Var("a") , "+" , BinOp( BinOp(Var("b"), "+", IntLit("3")) desugar , "/" , Var("c") ) ) )
  • 35. Binding Transformation to Editor Service editor interface behavior module nwl-Builders builders builder : "Desugar (selection)" = show-desugared (openeditor) (realtime) (meta) Stratego interface standard calling convention for builders rules show-desugared : (selected, position, ast, path, project-path) -> (filename, result-string) with filename := <guarantee-extension(|"aterm")> path; result-string := <desugar-all; pp-aterm-box; box2text-string(|120)> selected transformation
  • 36. Constant Folding y := a + (3 * 5 - 17); Assign( Var("y") , Plus( Var("a") , Minus(Times(IntLit("3"), IntLit("5")), IntLit("17")) parse ) ) Assign( Var("y") , BinOp(Var("a"), "+", IntLit("25")) desugar + eval ) y := (a + 25); pretty-print
  • 37. Constant Folding Rules strategies eval-all = innermost(desugar + eval) rules eval : BinOp(IntLit(x), "+", IntLit(y)) -> IntLit(<addS>(x, y)) eval : BinOp(IntLit(x), "-", IntLit(y)) -> IntLit(<subtS>(x, y)) eval : BinOp(IntLit(x), "*", IntLit(y)) -> IntLit(<mulS>(x, y)) eval : BinOp(IntLit(x), "/", IntLit(y)) -> IntLit(<divS>(x, y))
  • 38. Conditional Rewrite Rules bound in condition eval : BinOp(IntLit(x), "+", IntLit(y)) -> IntLit(z) condition where z := <addS>(x, y) match apply transformation eval : BinOp(IntLit(x), "+", IntLit(y)) -> IntLit(<addS>(x, y))
  • 39. For to While action foo() { for(p : Post in b.posts) { p.title := "foo"; } action foo ( ) { } var i : Int := 0; var c : Set<Post> := b.posts; var l : Int := c.length(); while (i < l) { var p : Post := c[i]; p.title := "foo" ; i := i + 1; } } specification (by example)
  • 40. For to While: Transformation Schema for(x : t in e) b var i : Int := 0; var c : Set<t> := e; var l : Int := c.length(); while (i < l) { var x : t := c[i]; b i := i + 1; } abstraction of example
  • 41. For to While: Rewrite Rule normalize : For(x, t, e, b) -> Block([ Stat(VarDeclInit(i, SimpleType("Int"), IntLit("0"))), Stat(VarDeclInit(c, SimpleType(t), e)), Stat(VarDeclInit(l, SimpleType("Int"), MethodCall(Var(c), "length", []))), While(BinOp(Var(i), "<", Var(l)), Block([ Stat(VarDeclInit(x, t, IndexAccess(Var(c), Var(i)))), b, Assign(Var(i), BinOp(Var(i), "+", IntLit("1"))) ])) ]) where i := <newname> "i"; c := <newname> "c"; l := <newname> "l"
  • 42. For to While: Result action foo() { specification by example for(p : Post in b.posts) { p.title := "foo"; action foo ( ) { } var i : Int := 0; } var c : Set<Post> := b.posts; var l : Int := c.length(); action foo ( ) { while (i < l) { { var p : Post := c[i]; var i0 : Int := 0; p.title := "foo" ; var c0 : Set<Post> := b.posts; i := i + 1; var l0 : Int := c0.length(); } while ( (i0 < l0) ) } { var p : Post := c0[i0]; p.title := "foo" ; i0 := (i0 + 1) ; } } } result
  • 43. Normalization Strategy strategies normalize-all = innermost(desugar + normalize) rules normalize : For(x, t, e, b) -> Block([ Stat(VarDecl(... ]) normalize : [Block(stat1*) | stat2*] -> <conc> (stat1*, stat2*) (is that a correct transformation?)
  • 44. For to While: Final Result action foo() { specification by example for(p : Post in b.posts) { p.title := "foo"; action foo ( ) { } var i : Int := 0; } var c : Set<Post> := b.posts; var l : Int := c.length(); while (i < l) { action foo ( ) { var p : Post := c[i]; var i0 : Int := 0; p.title := "foo" ; var c0 : Set<Post> := b.posts; i := i + 1; var l0 : Int := c0.length(); } while ( (i0 < l0) ) } { var p : Post := c0[i0]; p.title := "foo" ; i0 := (i0 + 1) ; } } result
  • 45. Normalization Strategy strategies normalize-all = innermost(desugar + normalize) rules normalize : For(x, t, e, b) -> Block([ Stat(VarDecl(... ]) normalize : Block([Block(stat*)]) -> Block(stat*)
  • 46. Schedule Lab this week ★ Design 1: deadline is April 1 ★ Design 2: what DSL will you design? Cases ★ Case 2: web abstractions ★ Deadline Case 2: April 8 ★ Case 3: Next ★ Lecture 8: code generation