SlideShare uma empresa Scribd logo
1 de 142
Baixar para ler offline
Challenge the future
Delft
University of
Technology
Course IN4303 2013/14
Compiler Construction
Guido Wachsmuth
Declarative Semantics Definition
Term Rewriting
today’s lecture
Term Rewriting
Overview
manual implementation
• static analysis & error checking
• code generation
• semantic editor services
domain-specific language
• Stratego
• transform ASTs
• working on ATerms
• declarative style
2
Term Rewriting
overview
I
3
architecture
Term Rewriting
Modern Compilers in IDEs
4
Source
Code
architecture
Term Rewriting
Modern Compilers in IDEs
4
Source
Code
parse
architecture
Term Rewriting
Modern Compilers in IDEs
4
Source
Code
parse
check
architecture
Term Rewriting
Modern Compilers in IDEs
4
Source
Code
parse
check
architecture
Term Rewriting
Modern Compilers in IDEs
4
Source
Code
parse generate
Machine
Code
check
manual implementation
Term Rewriting
Traditional Compiler Compilers
5
Language
Implementation
compile
Compiler
compilation + compilation
Term Rewriting
Traditional Compiler Compilers
6
Language
Implementation
compile
Compiler
Language
Definition
compile
compilation + interpretation
Term Rewriting
Traditional Compiler Compilers
7
interpret
Interpreter
Language
Definition
compile
Language
Implementation
compilation + interpretation
Term Rewriting
Spoofax Language Workbench
8
interpret
Generic
Parser
Syntax
Definition
compile
Parse Table
manual implementation
Term Rewriting
Spoofax Language Workbench
Stratego
• declarative DSL
• domain: program transformation
• means to manipulate ASTs
• working on ATerms
• compiles to C or Java
Stratego in Spoofax
• static analysis & error checking
• code generation
• semantic editor services
9
concepts
Term Rewriting
Stratego
signatures
rewrite rules
• transform term to term
• left-hand side
• pattern matching & variable binding
• right-hand side
• pattern instantiation & variable substitution
rewrite strategies
• algorithm for applying rewrite rules
10
example
Term Rewriting
Stratego
module desugar
imports
include/Tiger
operators
strategies
	
desugar-all = innermost(desugar)
	
rules
desugar: IfThen(e1, e2) -> IfThenElse(e1, e2, NoVal())
11
Term Rewriting
signatures
II
12
context-free syntax
"-" Exp -> Exp {cons("Uminus")}
Exp "+" Exp -> Exp {cons("Plus")}
Exp "-" Exp -> Exp {cons("Minus")}
Exp "*" Exp -> Exp {cons("Times")}
Exp "/" Exp -> Exp {cons("Divide")}
	 	
Exp "=" Exp -> Exp {cons("Eq")}
Exp "<>" Exp -> Exp {cons("Neq")}
Exp ">" Exp -> Exp {cons("Gt")}
Exp "<" Exp -> Exp {cons("Lt")}
Exp ">=" Exp -> Exp {cons("Geq")}
Exp "<=" Exp -> Exp {cons("Leq")}
	 	
Exp "&" Exp -> Exp {cons("And")}
Exp "|" Exp -> Exp {cons("Or")}
Term Rewriting
Signatures
signature
constructors
Uminus : Exp -> Exp
Plus : Exp * Exp -> Exp
Minus : Exp * Exp -> Exp
Times : Exp * Exp -> Exp
Divide : Exp * Exp -> Exp
Eq : Exp * Exp -> Exp
Neq : Exp * Exp -> Exp
Gt : Exp * Exp -> Exp
Lt : Exp * Exp -> Exp
Geq : Exp * Exp -> Exp
Leq : Exp * Exp -> Exp
And : Exp * Exp -> Exp
Or : Exp * Exp -> Exp
13
signature
Term Rewriting
signature
constructors
Constructor : Cons -> Term
Application : Cons * List(Term) -> Term
List : List(Term) -> Term
Tuple : List(Term) -> Term
signature
constructors
Nil : -> List(a)
Cons : a * List(a) -> List(a)
Conc : List(a) * List(a) -> List(a)
14
ATerms in Stratego
Term Rewriting
rewrite rules
III
15
Term Rewriting
Desugaring
if x then
printint(x)
16
if x then
printint(x)
else
()
Term Rewriting
Desugaring
if x then
printint(x)
16
if x then
printint(x)
else
()
IfThen(
Var("x")
, Call(
"printint"
, [Var("x")]
)
)
IfThenElse(
Var("x")
, Call(
"printint"
, [Var("x")]
)
, NoVal()
)
desugar: IfThen(e1, e2) -> IfThenElse(e1, e2, NoVal())
Term Rewriting
Desugaring
if x then
printint(x)
16
if x then
printint(x)
else
()
IfThen(
Var("x")
, Call(
"printint"
, [Var("x")]
)
)
IfThenElse(
Var("x")
, Call(
"printint"
, [Var("x")]
)
, NoVal()
)
desugar: IfThen(e1, e2) -> IfThenElse(e1, e2, NoVal())
Term Rewriting
Desugaring
if x then
printint(x)
16
if x then
printint(x)
else
()
IfThen(
Var("x")
, Call(
"printint"
, [Var("x")]
)
)
IfThenElse(
Var("x")
, Call(
"printint"
, [Var("x")]
)
, NoVal()
)
pattern matching
desugar: IfThen(e1, e2) -> IfThenElse(e1, e2, NoVal())
Term Rewriting
Desugaring
if x then
printint(x)
16
if x then
printint(x)
else
()
IfThen(
Var("x")
, Call(
"printint"
, [Var("x")]
)
)
IfThenElse(
Var("x")
, Call(
"printint"
, [Var("x")]
)
, NoVal()
)
pattern matching
e1
e2
desugar: IfThen(e1, e2) -> IfThenElse(e1, e2, NoVal())
Term Rewriting
Desugaring
if x then
printint(x)
16
if x then
printint(x)
else
()
IfThen(
Var("x")
, Call(
"printint"
, [Var("x")]
)
)
IfThenElse(
Var("x")
, Call(
"printint"
, [Var("x")]
)
, NoVal()
)
pattern matching pattern instantiation
e1
e2
desugar: IfThen(e1, e2) -> IfThenElse(e1, e2, NoVal())
Term Rewriting
Desugaring
if x then
printint(x)
16
if x then
printint(x)
else
()
IfThen(
Var("x")
, Call(
"printint"
, [Var("x")]
)
)
IfThenElse(
Var("x")
, Call(
"printint"
, [Var("x")]
)
, NoVal()
)
pattern matching pattern instantiation
e1
e2
desugar: Uminus(e) 		 -> Bop(MINUS(), Int("0"), e)
	
desugar: Plus(e1, e2) -> Bop(PLUS(), e1, e2)
desugar: Minus(e1, e2) -> Bop(MINUS(), e1, e2)
desugar: Times(e1, e2) -> Bop(MUL(), e1, e2)
desugar: Divide(e1, e2) -> Bop(DIV(), e1, e2)
	
desugar: Eq(e1, e2) -> Rop(EQ(), e1, e2)
desugar: Neq(e1, e2) -> Rop(NE(), e1, e2)
desugar: Leq(e1, e2) -> Rop(LE(), e1, e2)
desugar: Lt(e1, e2) -> Rop(LT(), e1, e2)
desugar: Geq(e1, e2) -> Rop(LE(), e2, e1)
desugar: Gt(e1, e2) -> Rop(LT(), e2, e1)
desugar: And(e1, e2) -> IfThenElse(e1, e2, Int("0"))
desugar: Or(e1, e2) -> IfThenElse(e1, Int("1"), e2)
Term Rewriting
More Desugaring
signature constructors
PLUS: 	 BinOp
MINUS: 	BinOp
MUL: 	 BinOp
DIV: 	 BinOp
	
EQ: 	RelOp
NE: 	RelOp
LE: 	RelOp
LT: 	RelOp
	
Bop: BinOp * Expr * Expr -> Expr
Rop: RelOp * Expr * Expr -> Expr
17
Term Rewriting
Constant Folding
x := 21 + 21 + x
18
x := 42 + x
Term Rewriting
Constant Folding
x := 21 + 21 + x
18
x := 42 + x
Assign(
Var("x")
, Plus(
Plus(
Int("21")
, Int("21")
)
, Var("x")
)
)
Assign(
Var("x")
, Plus(
Int("42")
, Var("x")
)
)
eval: Bop(PLUS(), Int(i1), Int(i2)) -> Int(i3)
where <addS> (i1, i2) => i3
Term Rewriting
Constant Folding
x := 21 + 21 + x
18
x := 42 + x
Assign(
Var("x")
, Plus(
Plus(
Int("21")
, Int("21")
)
, Var("x")
)
)
Assign(
Var("x")
, Plus(
Int("42")
, Var("x")
)
)
eval: Bop(PLUS(), Int(i1), Int(i2)) -> Int(<addS> (i1, i2))
eval: Bop(MINUS(), Int(i1), Int(i2)) -> Int(<subtS> (i1, i2))
eval: Bop(MUL(), Int(i1), Int(i2)) -> Int(<mulS> (i1, i2))
eval: Bop(DIV(), Int(i1), Int(i2)) -> Int(<divS> (i1, i2))
	
eval: Rop(EQ(), Int(i), Int(i)) -> Int("1")
eval: Rop(EQ(), Int(i1), Int(i2)) -> Int("0") where not( <eq> (i1, i2) )
eval: Rop(NE(), Int(i), Int(i)) -> Int("0")
eval: Rop(NE(), Int(i1), Int(i2)) -> Int("1") where not( <eq> (i1, i2) )
	
eval: Rop(LT(), Int(i1), Int(i2)) -> Int("1") where <ltS> (i1, i2)
eval: Rop(LT(), Int(i1), Int(i2)) -> Int("0") where not( <ltS> (i1, i2) )
	
eval: Rop(LE(), Int(i1), Int(i2)) -> Int("1") where <leqS> (i1, i2)
eval: Rop(LE(), Int(i1), Int(i2)) -> Int("0") where not( <leqS> (i1, i2))
Term Rewriting
More Constant Folding
19
parameters
Term Rewriting
Rewrite Rules
f(x,y|a,b): lhs -> rhs
• strategy or rule parameters x,y
• term parameters a,b
• no matching
f(|a,b): lhs -> rhs
• optional strategy parameters
f(x,y): lhs -> rhs
• optional term parameters
f: lhs -> rhs
20
example: map
Term Rewriting
Rules with Parameters
21
[ 1
, 2
, 3
]
[ 2
, 3
, 4
]
map(inc)
example: map
Term Rewriting
Rules with Parameters
21
[ 1
, 2
, 3
]
[ 2
, 3
, 4
]
map(inc)
inc
1
2
3
2
3
4inc
inc
example: map
Term Rewriting
Rules with Parameters
map(s): [] -> []	
map(s): [x|xs] -> [<s> x | <map(s)> xs]
21
[ 1
, 2
, 3
]
[ 2
, 3
, 4
]
map(inc)
inc
1
2
3
2
3
4inc
inc
example: zip
Term Rewriting
Rules with Parameters
22
[ 1
, 2
, 3
]
[ (1,4)
, (2,5)
, (3,6)
]
[ 4
, 5
, 6
]zip
example: zip
Term Rewriting
Rules with Parameters
22
[ 1
, 2
, 3
]
[ (1,4)
, (2,5)
, (3,6)
]
[ 4
, 5
, 6
]zip
[ 1
, 2
, 3
]
[ 5
, 7
, 9
]
[ 4
, 5
, 6
]zip(add)
example: zip
Term Rewriting
Rules with Parameters
22
[ 1
, 2
, 3
]
[ (1,4)
, (2,5)
, (3,6)
]
[ 4
, 5
, 6
]zip
[ 1
, 2
, 3
]
[ 5
, 7
, 9
]
[ 4
, 5
, 6
]zip(add)
map(add)
example: zip
Term Rewriting
Rules with Parameters
zip(s): ([],[]) -> []	
zip(s): ([x|xs],[y|ys]) -> [<s> (x,y) | <zip(s)> (xs,ys)]
zip = zip(id)
22
[ 1
, 2
, 3
]
[ (1,4)
, (2,5)
, (3,6)
]
[ 4
, 5
, 6
]zip
[ 1
, 2
, 3
]
[ 5
, 7
, 9
]
[ 4
, 5
, 6
]zip(add)
map(add)
example: fold
Term Rewriting
Rules with Parameters
23
[1,2,3] foldr(!0,add) 6
example: fold
Term Rewriting
Rules with Parameters
23
[1,2,3] foldr(!0,add) 6
[]
0
[3]
3
[2,3]
56
[1,2,3]
example: fold
Term Rewriting
Rules with Parameters
foldr(s1,s2): [] -> <s1>	
foldr(s1,s2): [x|xs] -> <s2> (x,<foldr(s1,s2)> xs)
23
[1,2,3] foldr(!0,add) 6
[]
0
[3]
3
[2,3]
56
[1,2,3]
example: inverse
Term Rewriting
Rules with Parameters
24
[1,2,3] inverse(|[]) [3,2,1]
example: inverse
Term Rewriting
Rules with Parameters
24
[1,2,3] inverse(|[]) [3,2,1]
[2,3]
[1][]
[1,2,3] [3]
[2,1] [3,2,1]
[]
example: inverse
Term Rewriting
Rules with Parameters
inverse(|is): [] -> is	
inverse(|is): [x|xs] -> <inverse(|[x|is])> xs
24
[1,2,3] inverse(|[]) [3,2,1]
[2,3]
[1][]
[1,2,3] [3]
[2,1] [3,2,1]
[]
Term Rewriting 25
coffee break
Term Rewriting
rewrite strategies
IV
26
rules and strategies
Term Rewriting
Transformation Definitions
rewrite rules
• term to term
• left-hand side matching
• right-hand side instantiation
• conditional
• partial transformation
rewrite strategies
• rule selection
• algorithm
• composition of transformations
27
example
Term Rewriting
Stratego
module desugar
imports
include/Tiger
operators
strategies
	
desugar-all = innermost(desugar)
	
rules
desugar: IfThen(e1, e2) -> IfThenElse(e1, e2, NoVal())
28
example
Term Rewriting
Stratego
module eval
imports
include/Tiger
operators
desugar
strategies
eval-all = innermost(desugar + eval)
	
rules
eval: Bop(PLUS(),Int(i1),Int(i2)) -> Int(i3)
where <addS> (i1, i2) => i3
29
Term Rewriting
Strategy Combinators
identity
id
30
Term Rewriting
Strategy Combinators
identity
id
failure
fail
30
Term Rewriting
Strategy Combinators
identity
id
failure
fail
sequential composition
s1 ; s2
30
Term Rewriting
Strategy Combinators
identity
id
failure
fail
sequential composition
s1 ; s2
deterministic choice
s1 <+ s2
30
Term Rewriting
Strategy Combinators
identity
id
failure
fail
sequential composition
s1 ; s2
deterministic choice
s1 <+ s2
non-deterministic choice
s1 + s2
30
Term Rewriting
Strategy Combinators
identity
id
failure
fail
sequential composition
s1 ; s2
deterministic choice
s1 <+ s2
non-deterministic choice
s1 + s2
guarded choice
s1 < s2 + s3
30
variables
Term Rewriting
Strategy Combinators
pattern matching
?t
31
variables
Term Rewriting
Strategy Combinators
pattern matching
?t
pattern instantiation
!t
31
variables
Term Rewriting
Strategy Combinators
pattern matching
?t
pattern instantiation
!t
strategy application
<s> t ≣ !t ; s
31
variables
Term Rewriting
Strategy Combinators
pattern matching
?t
pattern instantiation
!t
strategy application
<s> t ≣ !t ; s
result matching
s => t ≣ s ; ?t
<s> t1 => t2
t2 := <s> t1
31
variables
Term Rewriting
Strategy Combinators
pattern matching
?t
pattern instantiation
!t
strategy application
<s> t ≣ !t ; s
result matching
s => t ≣ s ; ?t
<s> t1 => t2
t2 := <s> t1
variable scope
{x,y: s}
31
rules and strategies
Term Rewriting
Strategy Combinators
named rewrite rule
l: t1 -> t2 where s ≣ l = ?t1 ; s ; !t2
32
rules and strategies
Term Rewriting
Strategy Combinators
named rewrite rule
l: t1 -> t2 where s ≣ l = ?t1 ; s ; !t2
unscoped rewrite rule
(t1 -> t2 where s) ≣ ?t1 ; s ; !t2
32
rules and strategies
Term Rewriting
Strategy Combinators
named rewrite rule
l: t1 -> t2 where s ≣ l = ?t1 ; s ; !t2
unscoped rewrite rule
(t1 -> t2 where s) ≣ ?t1 ; s ; !t2
strategy definition
f(x,y|a,b) = s
32
examples
Term Rewriting
Strategy Combinators
try(s) = s <+ id
repeat(s) = try(s ; repeat(s))
33
examples
Term Rewriting
Strategy Combinators
try(s) = s <+ id
repeat(s) = try(s ; repeat(s))
topdown(s) = s ; all(topdown(s))
33
examples
Term Rewriting
Strategy Combinators
try(s) = s <+ id
repeat(s) = try(s ; repeat(s))
topdown(s) = s ; all(topdown(s))
alltd(s) = s <+ all(alltd(s))
33
examples
Term Rewriting
Strategy Combinators
try(s) = s <+ id
repeat(s) = try(s ; repeat(s))
topdown(s) = s ; all(topdown(s))
alltd(s) = s <+ all(alltd(s))
bottomup(s) = all(bottomup(s)) ; s
innermost(s) = bottomup(try(s ; innermost(s)))
oncetd(s) = s <+ one(oncetd(s))
contains(|t) = oncetd(?t)
33
examples
Term Rewriting
Strategy Combinators
try(s) = s <+ id
repeat(s) = try(s ; repeat(s))
topdown(s) = s ; all(topdown(s))
alltd(s) = s <+ all(alltd(s))
bottomup(s) = all(bottomup(s)) ; s
innermost(s) = bottomup(try(s ; innermost(s)))
oncetd(s) = s <+ one(oncetd(s))
contains(|t) = oncetd(?t)
33
examples
Term Rewriting
Strategy Combinators
try(s) = s <+ id
repeat(s) = try(s ; repeat(s))
topdown(s) = s ; all(topdown(s))
alltd(s) = s <+ all(alltd(s))
bottomup(s) = all(bottomup(s)) ; s
innermost(s) = bottomup(try(s ; innermost(s)))
oncetd(s) = s <+ one(oncetd(s))
contains(|t) = oncetd(?t)
33
examples
Term Rewriting
Strategy Combinators
try(s) = s <+ id
repeat(s) = try(s ; repeat(s))
topdown(s) = s ; all(topdown(s))
alltd(s) = s <+ all(alltd(s))
bottomup(s) = all(bottomup(s)) ; s
innermost(s) = bottomup(try(s ; innermost(s)))
oncetd(s) = s <+ one(oncetd(s))
contains(|t) = oncetd(?t)
33
examples
Term Rewriting
Strategy Combinators
try(s) = s <+ id
repeat(s) = try(s ; repeat(s))
topdown(s) = s ; all(topdown(s))
alltd(s) = s <+ all(alltd(s))
bottomup(s) = all(bottomup(s)) ; s
innermost(s) = bottomup(try(s ; innermost(s)))
oncetd(s) = s <+ one(oncetd(s))
contains(|t) = oncetd(?t)
33
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
topdown(s) = s ; all(topdown(s))
topdown(switch)
34
Const
Mul
Const
3 4 5
Const
Add
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
topdown(s) = s ; all(topdown(s))
topdown(switch)
34
Const
Mul
Const
3 4 5
Const
Add1
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
topdown(s) = s ; all(topdown(s))
topdown(switch)
35
Mul
Const
3
Const
4 5
Const
Add1
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
topdown(s) = s ; all(topdown(s))
topdown(switch)
35
Mul
Const
3
Const
4 5
Const
Add1
2
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
topdown(s) = s ; all(topdown(s))
topdown(switch)
36
Mul
Const
3
Const
5 4
Const
Add1
2
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
topdown(s) = s ; all(topdown(s))
topdown(switch)
36
Mul
Const
3
Const
5 4
Const
Add1
2
3
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
topdown(s) = s ; all(topdown(s))
topdown(try(switch))
37
Const
Mul
Const
3 4 5
Const
Add
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
topdown(s) = s ; all(topdown(s))
topdown(try(switch))
37
Const
Mul
Const
3 4 5
Const
Add1
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
topdown(s) = s ; all(topdown(s))
topdown(try(switch))
38
Mul
Const
3
Const
4 5
Const
Add1
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
topdown(s) = s ; all(topdown(s))
topdown(try(switch))
38
Mul
Const
3
Const
4 5
Const
Add1
2
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
topdown(s) = s ; all(topdown(s))
topdown(try(switch))
39
Mul
Const
3
Const
5 4
Const
Add1
2
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
topdown(s) = s ; all(topdown(s))
topdown(try(switch))
39
Mul
Const
3
Const
5 4
Const
Add1
2
3
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
topdown(s) = s ; all(topdown(s))
topdown(try(switch))
39
Mul
Const
3
Const
5 4
Const
Add1
2
3
4
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
topdown(s) = s ; all(topdown(s))
topdown(try(switch))
39
Mul
Const
3
Const
5 4
Const
Add1
2
3
4
5
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
topdown(s) = s ; all(topdown(s))
topdown(try(switch))
39
Mul
Const
3
Const
5 4
Const
Add1
2
3
4
5
6
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
topdown(s) = s ; all(topdown(s))
topdown(try(switch))
39
Mul
Const
3
Const
5 4
Const
Add1
2
3
4
5
6
7
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
topdown(s) = s ; all(topdown(s))
topdown(try(switch))
39
Mul
Const
3
Const
5 4
Const
Add1
2
3
4
5
6
7
8
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
alltd(s) = s <+ all(alltd(s))
alltd(switch)
40
Const
Mul
Const
3 4 5
Const
Add
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
alltd(s) = s <+ all(alltd(s))
alltd(switch)
40
Const
Mul
Const
3 4 5
Const
Add1
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
alltd(s) = s <+ all(alltd(s))
alltd(switch)
41
Mul
Const
3
Const
4 5
Const
Add1
example
Term Rewriting
Stratego
switch: Mul(e1, e2) -> Mul(e2, e1)
alltd(s) = s <+ all(alltd(s))
alltd(switch)
42
Const
Mul
Const
3 4 5
Const
Add
example
Term Rewriting
Stratego
switch: Mul(e1, e2) -> Mul(e2, e1)
alltd(s) = s <+ all(alltd(s))
alltd(switch)
42
Const
Mul
Const
3 4 5
Const
Add1
example
Term Rewriting
Stratego
switch: Mul(e1, e2) -> Mul(e2, e1)
alltd(s) = s <+ all(alltd(s))
alltd(switch)
42
Const
Mul
Const
3 4 5
Const
Add1
2
example
Term Rewriting
Stratego
switch: Mul(e1, e2) -> Mul(e2, e1)
alltd(s) = s <+ all(alltd(s))
alltd(switch)
42
Const
Mul
Const
3 4 5
Const
Add1
2
3
example
Term Rewriting
Stratego
switch: Mul(e1, e2) -> Mul(e2, e1)
alltd(s) = s <+ all(alltd(s))
alltd(switch)
42
Const
Mul
Const
3 4 5
Const
Add1
2
3
4
example
Term Rewriting
Stratego
switch: Mul(e1, e2) -> Mul(e2, e1)
alltd(s) = s <+ all(alltd(s))
alltd(switch)
43
Const
Mul
Const
3 5 4
Const
Add1
2
3
4
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
bottomup(s) = all(bottomup(s)) ; s
bottomup(switch)
44
Const
Mul
Const
3 4 5
Const
Add
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
bottomup(s) = all(bottomup(s)) ; s
bottomup(switch)
44
Const
Mul
Const
3 4 5
Const
Add1
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
bottomup(s) = all(bottomup(s)) ; s
bottomup(switch)
44
Const
Mul
Const
3 4 5
Const
Add1
2
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
bottomup(s) = all(bottomup(s)) ; s
bottomup(switch)
44
Const
Mul
Const
3 4 5
Const
Add1
2
3
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
bottomup(s) = all(bottomup(s)) ; s
bottomup(try(switch))
45
Const
Mul
Const
3 4 5
Const
Add
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
bottomup(s) = all(bottomup(s)) ; s
bottomup(try(switch))
45
Const
Mul
Const
3 4 5
Const
Add1
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
bottomup(s) = all(bottomup(s)) ; s
bottomup(try(switch))
45
Const
Mul
Const
3 4 5
Const
Add1
2
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
bottomup(s) = all(bottomup(s)) ; s
bottomup(try(switch))
45
Const
Mul
Const
3 4 5
Const
Add1
2
3
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
bottomup(s) = all(bottomup(s)) ; s
bottomup(try(switch))
45
Const
Mul
Const
3 4 5
Const
Add1
2
3
4
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
bottomup(s) = all(bottomup(s)) ; s
bottomup(try(switch))
45
Const
Mul
Const
3 4 5
Const
Add1
2
3
4
5
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
bottomup(s) = all(bottomup(s)) ; s
bottomup(try(switch))
45
Const
Mul
Const
3 4 5
Const
Add1
2
3
4
5
6
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
bottomup(s) = all(bottomup(s)) ; s
bottomup(try(switch))
45
Const
Mul
Const
3 4 5
Const
Add1
2
3
4
5
6
7
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
bottomup(s) = all(bottomup(s)) ; s
bottomup(try(switch))
45
Const
Mul
Const
3 4 5
Const
Add1
2
3
4
5
6
7
8
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
bottomup(s) = all(bottomup(s)) ; s
bottomup(try(switch))
46
Const
Mul
Const
3 4 5
Const
Add1
2
3
4
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
bottomup(s) = all(bottomup(s)) ; s
bottomup(try(switch))
47
Const
Mul
Const
3 5 4
Const
Add1
2
3
4
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
bottomup(s) = all(bottomup(s)) ; s
bottomup(try(switch))
48
Const
Mul
Const
3 5 4
Const
Add1
Mul
Const
3
Const
5 4
Const
Add
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
bottomup(s) = all(bottomup(s)) ; s
bottomup(try(switch))
49
1
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
innermost(s) = bottomup(try(s ; innermost(s)))
innermost(switch)
50
Const
Mul
Const
3 4 5
Const
Add
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
innermost(s) = bottomup(try(s ; innermost(s)))
innermost(switch)
50
Const
Mul
Const
3 4 5
Const
Add1
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
innermost(s) = bottomup(try(s ; innermost(s)))
innermost(switch)
50
Const
Mul
Const
3 4 5
Const
Add1
2
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
innermost(s) = bottomup(try(s ; innermost(s)))
innermost(switch)
50
Const
Mul
Const
3 4 5
Const
Add1
2
3
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
innermost(s) = bottomup(try(s ; innermost(s)))
innermost(switch)
50
Const
Mul
Const
3 4 5
Const
Add1
2
3
4
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
innermost(s) = bottomup(try(s ; innermost(s)))
innermost(switch)
50
Const
Mul
Const
3 4 5
Const
Add1
2
3
4
5
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
innermost(s) = bottomup(try(s ; innermost(s)))
innermost(switch)
50
Const
Mul
Const
3 4 5
Const
Add1
2
3
4
5
6
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
innermost(s) = bottomup(try(s ; innermost(s)))
innermost(switch)
50
Const
Mul
Const
3 4 5
Const
Add1
2
3
4
5
6
7
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
innermost(s) = bottomup(try(s ; innermost(s)))
innermost(switch)
50
Const
Mul
Const
3 4 5
Const
Add1
2
3
4
5
6
7
8
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
innermost(s) = bottomup(try(s ; innermost(s)))
innermost(switch)
51
Const
Mul
Const
3 4 5
Const
Add1
2
3
4
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
innermost(s) = bottomup(try(s ; innermost(s)))
innermost(switch)
52
Const
Mul
Const
3 5 4
Const
Add1
2
3
4
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
innermost(s) = bottomup(try(s ; innermost(s)))
innermost(switch)
52
Const
Mul
Const
3 5 4
Const
Add1
2
3
4
9
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
innermost(s) = bottomup(try(s ; innermost(s)))
innermost(switch)
52
Const
Mul
Const
3 5 4
Const
Add1
2
3
4
9
10
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
innermost(s) = bottomup(try(s ; innermost(s)))
innermost(switch)
52
Const
Mul
Const
3 5 4
Const
Add1
2
3
4
9
10
11
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
innermost(s) = bottomup(try(s ; innermost(s)))
innermost(switch)
52
Const
Mul
Const
3 5 4
Const
Add1
2
3
4
9
10
11
12
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
innermost(s) = bottomup(try(s ; innermost(s)))
innermost(switch)
53
Const
Mul
Const
3 5 4
Const
Add1
2
3
4
example
Term Rewriting
Stratego
switch: Add(e1, e2) -> Add(e2, e1)
switch: Mul(e1, e2) -> Mul(e2, e1)
innermost(s) = bottomup(try(s ; innermost(s)))
innermost(switch)
54
Const
Mul
Const
3 4 5
Const
Add1
2
3
4
Term Rewriting
summary
V
55
lessons learned
Term Rewriting
Summary
56
lessons learned
Term Rewriting
Summary
How do you define AST transformations in Stratego?
• signatures
• rewrite rules
• rewrite strategies
• strategy combinators
56
lessons learned
Term Rewriting
Summary
How do you define AST transformations in Stratego?
• signatures
• rewrite rules
• rewrite strategies
• strategy combinators
What kind of strategies can you find in the Stratego library?
• arithmetics
• map, zip, foldr
• generic traversals
56
learn more
Term Rewriting
Literature
57
learn more
Term Rewriting
Literature
Spoofax
Lennart C. L. Kats, Eelco Visser: The Spoofax Language Workbench.
Rules for Declarative Specification of Languages and IDEs. OOPSLA
2010
http://www.spoofax.org
57
learn more
Term Rewriting
Literature
Spoofax
Lennart C. L. Kats, Eelco Visser: The Spoofax Language Workbench.
Rules for Declarative Specification of Languages and IDEs. OOPSLA
2010
http://www.spoofax.org
Stratego
Martin Bravenboer, Karl Trygve Kalleberg, Rob Vermaas, Eelco Visser:
Stratego/XT 0.17. A language and toolset for program transformation.
Science of Computer Programming, 72(1-2), 2008.
http://www.strategoxt.org
57
coming next
Term Rewriting
Outlook
declarative semantics definition
• Lecture 5: Static Analysis and Error Checking
• Lecture 6: Code Generation
Assignment Oct 2: MiniJava grammar in SDF
• submit on Blackboard
Lab Oct 03
• syntactic editor services
• pretty-printer for MiniJava
58
Term Rewriting 59
attribution & copyrights
Term Rewriting
Pictures
Slides 1, 9, 10, 20, 27: Stratego by Kendrick Arnett, some rights reserved
Slides 23-26, 28, 31, 37-39, 41-43: PICOL icons by Melih Bilgil, some rights reserved
Slide 14: Thesaurus by Enoch Lau, some rights reserved
Slide 21: Google Maps Street View Camera by Ian Britton, some rights reserved
Slide 22: Zipper by Rabensteiner, some rights reserved
Slide 23: Fold by Kim Piper Werker, some rights reserved
Slide 24: Inverse by lanchongzi, some rights reserved
Slide 25: Maxwell's by Dominica Williamson, some rights reserved
Slide 58: Reichstag by Wolfgang Staudt, some rights reserved
60

Mais conteúdo relacionado

Mais procurados

Declare Your Language: Syntactic (Editor) Services
Declare Your Language: Syntactic (Editor) ServicesDeclare Your Language: Syntactic (Editor) Services
Declare Your Language: Syntactic (Editor) ServicesEelco Visser
 
Compiler Components and their Generators - Traditional Parsing Algorithms
Compiler Components and their Generators - Traditional Parsing AlgorithmsCompiler Components and their Generators - Traditional Parsing Algorithms
Compiler Components and their Generators - Traditional Parsing AlgorithmsGuido Wachsmuth
 
Declare Your Language: Syntax Definition
Declare Your Language: Syntax DefinitionDeclare Your Language: Syntax Definition
Declare Your Language: Syntax DefinitionEelco Visser
 
Compiler Components and their Generators - Lexical Analysis
Compiler Components and their Generators - Lexical AnalysisCompiler Components and their Generators - Lexical Analysis
Compiler Components and their Generators - Lexical AnalysisGuido Wachsmuth
 
Declare Your Language: Type Checking
Declare Your Language: Type CheckingDeclare Your Language: Type Checking
Declare Your Language: Type CheckingEelco Visser
 
Declare Your Language: Transformation by Strategic Term Rewriting
Declare Your Language: Transformation by Strategic Term RewritingDeclare Your Language: Transformation by Strategic Term Rewriting
Declare Your Language: Transformation by Strategic Term RewritingEelco Visser
 
Declare Your Language: Name Resolution
Declare Your Language: Name ResolutionDeclare Your Language: Name Resolution
Declare Your Language: Name 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 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
 
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
 
Programming languages
Programming languagesProgramming languages
Programming languagesEelco 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
 
Dynamic Semantics Specification and Interpreter Generation
Dynamic Semantics Specification and Interpreter GenerationDynamic Semantics Specification and Interpreter Generation
Dynamic Semantics Specification and Interpreter GenerationEelco 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
 

Mais procurados (20)

Syntax Definition
Syntax DefinitionSyntax Definition
Syntax Definition
 
Dynamic Semantics
Dynamic SemanticsDynamic Semantics
Dynamic Semantics
 
Syntax Definition
Syntax DefinitionSyntax Definition
Syntax Definition
 
Formal Grammars
Formal GrammarsFormal Grammars
Formal Grammars
 
Declare Your Language: Syntactic (Editor) Services
Declare Your Language: Syntactic (Editor) ServicesDeclare Your Language: Syntactic (Editor) Services
Declare Your Language: Syntactic (Editor) Services
 
LL Parsing
LL ParsingLL Parsing
LL Parsing
 
Compiler Components and their Generators - Traditional Parsing Algorithms
Compiler Components and their Generators - Traditional Parsing AlgorithmsCompiler Components and their Generators - Traditional Parsing Algorithms
Compiler Components and their Generators - Traditional Parsing Algorithms
 
Declare Your Language: Syntax Definition
Declare Your Language: Syntax DefinitionDeclare Your Language: Syntax Definition
Declare Your Language: Syntax Definition
 
Compiler Components and their Generators - Lexical Analysis
Compiler Components and their Generators - Lexical AnalysisCompiler Components and their Generators - Lexical Analysis
Compiler Components and their Generators - Lexical Analysis
 
Declare Your Language: Type Checking
Declare Your Language: Type CheckingDeclare Your Language: Type Checking
Declare Your Language: Type Checking
 
Declare Your Language: Transformation by Strategic Term Rewriting
Declare Your Language: Transformation by Strategic Term RewritingDeclare Your Language: Transformation by Strategic Term Rewriting
Declare Your Language: Transformation by Strategic Term Rewriting
 
Declare Your Language: Name Resolution
Declare Your Language: Name ResolutionDeclare Your Language: Name Resolution
Declare Your Language: Name 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 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
 
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
 
Programming languages
Programming languagesProgramming languages
Programming languages
 
Compiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint ResolutionCompiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint Resolution
 
Dynamic Semantics Specification and Interpreter Generation
Dynamic Semantics Specification and Interpreter GenerationDynamic Semantics Specification and Interpreter Generation
Dynamic Semantics Specification and Interpreter Generation
 
Ch04
Ch04Ch04
Ch04
 
Declarative Type System Specification with Statix
Declarative Type System Specification with StatixDeclarative Type System Specification with Statix
Declarative Type System Specification with Statix
 

Destaque

Declarative Semantics Definition - Code Generation
Declarative Semantics Definition - Code Generation Declarative Semantics Definition - Code Generation
Declarative Semantics Definition - Code Generation Guido Wachsmuth
 
Declarative Syntax Definition - Pretty Printing
Declarative Syntax Definition - Pretty PrintingDeclarative Syntax Definition - Pretty Printing
Declarative Syntax Definition - Pretty PrintingGuido Wachsmuth
 
Compiling Imperative and Object-Oriented Languages - Activation Records
Compiling Imperative and Object-Oriented Languages - Activation RecordsCompiling Imperative and Object-Oriented Languages - Activation Records
Compiling Imperative and Object-Oriented Languages - Activation RecordsGuido Wachsmuth
 
Compiling Imperative and Object-Oriented Languages - Dataflow Analysis
Compiling Imperative and Object-Oriented Languages - Dataflow AnalysisCompiling Imperative and Object-Oriented Languages - Dataflow Analysis
Compiling Imperative and Object-Oriented Languages - Dataflow AnalysisGuido Wachsmuth
 
Domain-Specific Type Systems
Domain-Specific Type SystemsDomain-Specific Type Systems
Domain-Specific Type SystemsGuido Wachsmuth
 
Compiling Imperative and Object-Oriented Languages - Register Allocation
Compiling Imperative and Object-Oriented Languages - Register AllocationCompiling Imperative and Object-Oriented Languages - Register Allocation
Compiling Imperative and Object-Oriented Languages - Register AllocationGuido Wachsmuth
 
Compiler Components and their Generators - LR Parsing
Compiler Components and their Generators - LR ParsingCompiler Components and their Generators - LR Parsing
Compiler Components and their Generators - LR ParsingGuido Wachsmuth
 
Compiling Imperative and Object-Oriented Languages - Garbage Collection
Compiling Imperative and Object-Oriented Languages - Garbage CollectionCompiling Imperative and Object-Oriented Languages - Garbage Collection
Compiling Imperative and Object-Oriented Languages - Garbage CollectionGuido Wachsmuth
 
K to 12 automotive teachers guide
K to 12 automotive teachers guideK to 12 automotive teachers guide
K to 12 automotive teachers guideNoel Tan
 
Beginners' Guide to Powerpoint
Beginners' Guide to PowerpointBeginners' Guide to Powerpoint
Beginners' Guide to PowerpointLaura Hampton
 
Research or Proposal Writing - DEFINITION OF TERMS
Research or Proposal Writing - DEFINITION OF TERMSResearch or Proposal Writing - DEFINITION OF TERMS
Research or Proposal Writing - DEFINITION OF TERMSJaime Alfredo Cabrera
 

Destaque (16)

Declarative Semantics Definition - Code Generation
Declarative Semantics Definition - Code Generation Declarative Semantics Definition - Code Generation
Declarative Semantics Definition - Code Generation
 
Declarative Syntax Definition - Pretty Printing
Declarative Syntax Definition - Pretty PrintingDeclarative Syntax Definition - Pretty Printing
Declarative Syntax Definition - Pretty Printing
 
Compiling Imperative and Object-Oriented Languages - Activation Records
Compiling Imperative and Object-Oriented Languages - Activation RecordsCompiling Imperative and Object-Oriented Languages - Activation Records
Compiling Imperative and Object-Oriented Languages - Activation Records
 
Compiling Imperative and Object-Oriented Languages - Dataflow Analysis
Compiling Imperative and Object-Oriented Languages - Dataflow AnalysisCompiling Imperative and Object-Oriented Languages - Dataflow Analysis
Compiling Imperative and Object-Oriented Languages - Dataflow Analysis
 
Domain-Specific Type Systems
Domain-Specific Type SystemsDomain-Specific Type Systems
Domain-Specific Type Systems
 
Compiling Imperative and Object-Oriented Languages - Register Allocation
Compiling Imperative and Object-Oriented Languages - Register AllocationCompiling Imperative and Object-Oriented Languages - Register Allocation
Compiling Imperative and Object-Oriented Languages - Register Allocation
 
K to 12 TLE Curriculum Guide for Automotive
K to 12 TLE Curriculum Guide for AutomotiveK to 12 TLE Curriculum Guide for Automotive
K to 12 TLE Curriculum Guide for Automotive
 
Compiler Components and their Generators - LR Parsing
Compiler Components and their Generators - LR ParsingCompiler Components and their Generators - LR Parsing
Compiler Components and their Generators - LR Parsing
 
Compiling Imperative and Object-Oriented Languages - Garbage Collection
Compiling Imperative and Object-Oriented Languages - Garbage CollectionCompiling Imperative and Object-Oriented Languages - Garbage Collection
Compiling Imperative and Object-Oriented Languages - Garbage Collection
 
Language
LanguageLanguage
Language
 
Definition Of Terms
Definition Of TermsDefinition Of Terms
Definition Of Terms
 
K to 12 automotive teachers guide
K to 12 automotive teachers guideK to 12 automotive teachers guide
K to 12 automotive teachers guide
 
K to 12 Automotive Learning Module
K to 12 Automotive Learning ModuleK to 12 Automotive Learning Module
K to 12 Automotive Learning Module
 
Beginners' Guide to Powerpoint
Beginners' Guide to PowerpointBeginners' Guide to Powerpoint
Beginners' Guide to Powerpoint
 
Research or Proposal Writing - DEFINITION OF TERMS
Research or Proposal Writing - DEFINITION OF TERMSResearch or Proposal Writing - DEFINITION OF TERMS
Research or Proposal Writing - DEFINITION OF TERMS
 
K to 12 TLE Curriculum Guide
K to 12 TLE Curriculum GuideK to 12 TLE Curriculum Guide
K to 12 TLE Curriculum Guide
 

Semelhante a Declarative Semantics Definition - Term Rewriting

Lex (lexical analyzer)
Lex (lexical analyzer)Lex (lexical analyzer)
Lex (lexical analyzer)Sami Said
 
CS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesCS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesEelco Visser
 
Chapter Eight(3)
Chapter Eight(3)Chapter Eight(3)
Chapter Eight(3)bolovv
 
Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Romain Francois
 
Design Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesDesign Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesGanesh Samarthyam
 
Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Romain Francois
 
ANSI C REFERENCE CARD
ANSI C REFERENCE CARDANSI C REFERENCE CARD
ANSI C REFERENCE CARDTia Ricci
 
Compiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | InterpretersCompiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | InterpretersEelco Visser
 
Scala as a Declarative Language
Scala as a Declarative LanguageScala as a Declarative Language
Scala as a Declarative Languagevsssuresh
 
Profiling and optimization
Profiling and optimizationProfiling and optimization
Profiling and optimizationg3_nittala
 
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate CompilersFunctional Thursday
 
A Replay Approach to Software Validation
A Replay Approach to Software ValidationA Replay Approach to Software Validation
A Replay Approach to Software ValidationJames Pascoe
 
Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1Ali Aminian
 
Data-Oriented Programming with Clojure and Jackdaw (Charles Reese, Funding Ci...
Data-Oriented Programming with Clojure and Jackdaw (Charles Reese, Funding Ci...Data-Oriented Programming with Clojure and Jackdaw (Charles Reese, Funding Ci...
Data-Oriented Programming with Clojure and Jackdaw (Charles Reese, Funding Ci...confluent
 
仕事で使うF#
仕事で使うF#仕事で使うF#
仕事で使うF#bleis tift
 
Go generics. what is this fuzz about?
Go generics. what is this fuzz about?Go generics. what is this fuzz about?
Go generics. what is this fuzz about?Gabriel Habryn
 

Semelhante a Declarative Semantics Definition - Term Rewriting (20)

Lex (lexical analyzer)
Lex (lexical analyzer)Lex (lexical analyzer)
Lex (lexical analyzer)
 
R Language Introduction
R Language IntroductionR Language Introduction
R Language Introduction
 
CS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesCS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic Services
 
Chapter Eight(3)
Chapter Eight(3)Chapter Eight(3)
Chapter Eight(3)
 
Interm codegen
Interm codegenInterm codegen
Interm codegen
 
Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Rcpp: Seemless R and C++
Rcpp: Seemless R and C++
 
Design Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesDesign Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on Examples
 
An Intoduction to R
An Intoduction to RAn Intoduction to R
An Intoduction to R
 
Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Rcpp: Seemless R and C++
Rcpp: Seemless R and C++
 
ANSI C REFERENCE CARD
ANSI C REFERENCE CARDANSI C REFERENCE CARD
ANSI C REFERENCE CARD
 
Compiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | InterpretersCompiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | Interpreters
 
Scala as a Declarative Language
Scala as a Declarative LanguageScala as a Declarative Language
Scala as a Declarative Language
 
Profiling and optimization
Profiling and optimizationProfiling and optimization
Profiling and optimization
 
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
 
A Replay Approach to Software Validation
A Replay Approach to Software ValidationA Replay Approach to Software Validation
A Replay Approach to Software Validation
 
Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1
 
Data-Oriented Programming with Clojure and Jackdaw (Charles Reese, Funding Ci...
Data-Oriented Programming with Clojure and Jackdaw (Charles Reese, Funding Ci...Data-Oriented Programming with Clojure and Jackdaw (Charles Reese, Funding Ci...
Data-Oriented Programming with Clojure and Jackdaw (Charles Reese, Funding Ci...
 
Faster Python, FOSDEM
Faster Python, FOSDEMFaster Python, FOSDEM
Faster Python, FOSDEM
 
仕事で使うF#
仕事で使うF#仕事で使うF#
仕事で使うF#
 
Go generics. what is this fuzz about?
Go generics. what is this fuzz about?Go generics. what is this fuzz about?
Go generics. what is this fuzz about?
 

Último

Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 

Último (20)

Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 

Declarative Semantics Definition - Term Rewriting

Notas do Editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. feedback loop\n
  14. feedback loop\n
  15. feedback loop\n
  16. feedback loop\n
  17. feedback loop\n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. \n
  100. \n
  101. \n
  102. \n
  103. \n
  104. \n
  105. \n
  106. \n
  107. \n
  108. \n
  109. \n
  110. \n
  111. \n
  112. \n
  113. \n
  114. \n
  115. \n
  116. \n
  117. \n
  118. \n
  119. \n
  120. \n
  121. \n
  122. \n
  123. \n
  124. \n
  125. \n
  126. \n
  127. \n
  128. \n
  129. \n
  130. \n
  131. \n
  132. \n
  133. \n
  134. round-up on every lecture\n\nwhat to take with you\n\ncheck yourself, pre- and post-paration\n
  135. \n
  136. \n