• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Formalizing homogeneous language embeddings
 

Formalizing homogeneous language embeddings

on

  • 428 views

 

Statistics

Views

Total Views
428
Views on SlideShare
306
Embed Views
122

Actions

Likes
0
Downloads
0
Comments
0

1 Embed 122

http://www.eis.mdx.ac.uk 122

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Formalizing homogeneous language embeddings Formalizing homogeneous language embeddings Presentation Transcript

    • Formalizing Homogeneous Language Embeddings
      Tony Clark
      Centre for Model Driven Software Engineering, School of Computing, Thames Valley University
      tony.clark@tvu.ac.uk
      http://itcentre.tvu.ac.uk/~clark/
      Laurence Tratt
      School of Design Engineering and Computing, Bournemouth University
      laurie@tratt.net
      http://tratt.net/laurie/
      1
    • Overview
      Language Factories and DSLs
      An example and some properties
      A language model for DSLs
      The mu-calculus for DSLs
      Some examples
      Further work.
      2
    • Language Factories
      The ability to construct new languages by combining precisely defined, reusable, language components and templates.
      3
    • Language Component
      program A
      block B
      do C
      do D
      end
      do E
      end
      A
      E
      parse
      B
      D
      C
      Abstract Syntax Tree
      σ
      σ
      σ
      σ
      σ
      Execution Trace
      4
    • Problem Addressed
      Reusable
      Language
      Component
      Parametric
      Language
      Component
      Questions:
      • how can syntax be merged?
      • how can semantics be merged?
      • how can we specify the combination?
      5
    • An Application of DSLs
      let results =
      langsql:SQL[
      select name,agefrom Customer where age > 18]
      inlanghtml:HTML[
      <TABLE>
      forname,agein results do
      <TR>
      <TD> name </TD>
      <TD> age </TD>
      </TR>
      </TABLE>
      ]
      6
    • A
      A Model for DSL Embedding
      host language(G)
      E
      B
      evalG
      σ
      σ
      σ
      σ
      σ
      σ
      C
      V
      load
      unload
      Z
      W
      w
      w
      w
      w
      w
      evalH
      Y
      X
      embedded language(H)
      7
    • The mu-Calculus
      E ::= V variables | fun(V) E functions | E E applications | (E,E,E) language def | lang E:T[C] language embed | ...
      8
    • Abstract Syntax
      type Exp(T) =Var(String) | Lambda(String,Exp(T)) | Apply(Exp(T),Exp(T)) | (Exp(T),Exp(T),Exp(T)) | Lang(T) | ...
      9
    • Semantics
      evalExp(eval)(s) =
      case s of
      ... standard SECD except for...
      (R:():s,e,App:c,d) ->
      eval((s,e,c,d):s,e,c,d)
      (I:v:s,e,App:c,d) ->
      eval(v)
      end
      10
    • Loading and Unloading
      lang(eval,load,unload):t[c]
      is equivalent to:
      I(newState)
      where newState = unload(termState,initialState)
      where termState = eval(startState)
      where startState = load(initialState,parse(t)(c))
      where initialState = R()
      translate terminal embedded to
      host state
      produce embedded
      terminal state
      install the host
      state
      translate host
      state to embedded initial state
      reify the host state
      11
    • mu-calculus Embedded in Itself
      Mu = Y(Exp)
      evalMu = Y(evalExp)
      loadMu((s,e,c,d),x) = (s,e,x:s,d)
      unloadMu(s,_) = s
      muL = (evalMu,loadMu,unloadMu)
      fun(x)
      langmuL:Mu[
      fun(y)
      langmuL:Mu[x + y]]
      12
    • Let Binding: Semantics
      type LetExp(T) = Let(String,Let(T),Let(T)) | Exp(T)
      type Let = Y(LetExp)
      evalLetExp(eval)(s) =
      case s of
      (s,e,Let(n,x,b):c,d) ->
      eval(s,e,x:Let(n,b):c,d)
      (v:s,e,Let(n,b):c,d) ->
      eval([],e[n->v],[b],(s,e,c,d))
      else evalExp(eval)(s)
      end
      13
    • Let-Binding: Language Definition
      type Let = Y(LetExp)
      evalLet = Y(evalLetExp)
      loadLet((s,e,c,d),x) = (s,e,x:c,d)
      unoadLet(s,_) = s
      letL = (evalLet,loadLet,unloadLet)
      fun(x)
      lang letL:Let[
      let y = x + 1 in y ]
      14
    • Other Examples
      langletL:Let[let mkArray = fun(limit) langarrayL:Array [ 0 .. limit ]in mkArray(100)]
      langletL:Let[
      let x = ...
      in langabortL:Abort[
      stop if(x > 100) ]]
      15
    • Review and Further Work
      mu-Calculus for semantic analysis of language embedding.
      Further work:
      Parsing
      Static Analysis
      Logic for combining language components
      Practical considerations
      16