A Brief Stratego XT Tutorial

icon

77

pages

icon

English

icon

Documents

Écrit par

Publié par

Le téléchargement nécessite un accès à la bibliothèque YouScribe Tout savoir sur nos offres

icon

77

pages

icon

English

icon

Documents

Le téléchargement nécessite un accès à la bibliothèque YouScribe Tout savoir sur nos offres

A Brief Stratego/XT TutorialKarl Trygve KallebergEelco VisserDagstuhl Workshop: Beyond Program Slicing, 7.-11. Nov 2005Plan of AttackI Explain the basics of StrategoI Terms, signatures, rewrite rules, strategies, concrete syntax,dynamic rulesI Motivate with a small case-studyI Constant propagationI Give a tiny tool demoI Take questionsOutline1 Motivation2 Terms and Signatures3 Transformation Rules4 Transfo Strategies5 Dynamic RulesPart IMotivationfor i := 1 to n dofor j := 1 to n doc[i,j] := let var d := 0in for k := 1 to n dod := d + a[i,k] * b[k,j];dendlet var din for i := 1 to n dofor j := 1 to n do(d := 0;for k := 1 to n do d := d + a[i,k] * b[k,j];c[i,j] := d)endExample: Desugaringfor i := 1 to n dofor j := 1 to n doc[i,j] := sum k = 1 to n (a[i,k] * b[k,j])let var din for i := 1 to n dofor j := 1 to n do(d := 0;for k := 1 to n do d := d + a[i,k] * b[k,j];c[i,j] := d)endExample: Desugaringfor i := 1 to n dofor j := 1 to n doc[i,j] := sum k = 1 to n (a[i,k] * b[k,j])for i := 1 to n dofor j := 1 to n doc[i,j] := let var d := 0in for k := 1 to n dod := d + a[i,k] * b[k,j];dendExample: Desugaringfor i := 1 to n dofor j := 1 to n doc[i,j] := sum k = 1 to n (a[i,k] * b[k,j])for i := 1 to n dofor j := 1 to n doc[i,j] := let var d := 0in for k := 1 to n dod := d + a[i,k] * b[k,j];dendlet var din for i := 1 to n dofor j := 1 to n do(d := 0;for k := 1 to n do d := d + a[i,k] * b[k,j];c[i,j] := d)endThe ...
Voir icon arrow

Publié par

Langue

English

Dagstuhl
A
Brief Stratego/XT Tutorial
Karl Trygve Kalleberg Eelco Visser
Workshop: Beyond Program Slicing, 7.-11.
Nov
2005
Plano
I
I
I
I
fAttack
Explain the basics of Stratego ITerms,signatures,rewrite rules,strategies,concrete syntax, dynamic rules Motivate with a small case-study IConstant propagation
Give a tiny tool demo
Take questions
uOlti
1
2
3
4
5
ne
Motivation
Terms and Signatures
Transformation
Transformation
Dynamic Rules
Rules
Strategies
Part
I
Motivation
xaElempes:Dragugnifj:orofndto=1i:or+d=:,i[aot1=dodnde];lend*bk],j[ki[j,:]l=1=otdnco0infork:etvard:=+d[ado=:b*k[,i]k;ford:=0tondk:=1:jrofodn(odnot1=nfdiartvto=1i:or
for i := 1 for j := c[i,j]
to n do 1 to n do :=sum k =
d
(a[i,k]
n
to
1
b[k,j])
*
];,ji,c[:=j]end)
0;fo(d:=ondo:=1td=a+od:dt1nokr=:[i;cj]k,b[]*,k[i
(a[i,k] * b[k,j])
n
1 to
for i := 1 for j := c[i,j]
to n do 1 to n do :=sum k =
dne)d=:]j,vaetinrdlodnojrofiroft1=:
end
to n do 1 to n do :=let var in for d d
d := k := := d
for i := 1 for j := c[i,j]
to n do a[i,k] *
0 1 +
b[k,j];
ngrigasuDee:plamxE
Example:Dseguaring
for i := 1 to n do for j := 1 to n do c[i,j] :=sum k = 1 to n (a[i,k] * b[k,j])
for i := 1 to n do for j := 1 to n do c[i,j] :=let var d := 0 in for k := 1 to n do d := d + a[i,k] * b[k,j]; d end
let var d infor i := 1 to n do for j := 1 to n do (d := 0; for k := 1 to n do d := d + a[i,k] * b[k,j]; c[i,j] :=d)
end
TheBigPicture
A Simple Pipeline
1
2
3
4
5
Source code isparsedinto astructuredrepresentation, a concrete syntax tree(CST).
The CST is pruned for non-essential information, to yield abstract syntax tree(AST).
Additional information is added, e.g. type information.
One or multipletransformationsare applied to the AST.
The result is serialized back to file.
an
hTeSmalliPtcuer
Thesyntax definitiondeclares programs we transform and is stages.
thestructureof the used in constructing
language for the most pipeline
Terms
Part
and
I
I
Signatures
Tersm
ITerms are astructured representationof programs. ITheir structure is often derived from the syntax definition of the language. IThe syntax definition gives rules for the structural validation of terms.
Terms are primarily used to encodeabstract syntax trees.
Voir icon more
Alternate Text