Stratego/XT Examples

Eelco Visser

Delft University of Technology

Karl Trygve Kalleberg

Universitetet i Bergen

Table of Contents

1. Introduction
1.1. Software Transformations
1.2. Introducing Stratego/XT
1.3. Software
1.4. Overview
1.4.1. TIL: A Tiny Imperative Language
1.4.2. BibTeX Transformations
1.4.3. Tiger
1.4.4. Other Applications
I. A Tiny Imperative Language
2. Syntax Definition and Pretty-Printing
2.1. TIL: a Tiny Imperative Language
2.2. Syntax Definition
2.3. Term Format
2.4. Pretty-Printing
2.5. A Complete Pipeline
3. Simplification and Desugaring
3.1. Constant Folding Rules
3.2. Desugaring Rules
3.3. Simplying by Term Rewriting
3.4. Compiling the Simplifier
3.5. Applying the Simplifier
4. Bound Variable Renaming (*)
4.1. Renaming Bound Variables
4.2. Example
5. Typechecking (*)
5.1. Typechecking
5.2. Example
6. Interpretation
6.1. Evaluating Expressions
6.2. Evaluating Variable Accesses
6.3. Evaluating Statements
6.4. The Complete Interpreter
6.5. Running TIL Programs
7. Data-flow Transformation (*)
7.1. Preliminaries
7.2. Constant Propagation
7.3. Copy Propagation
7.4. Reverse Copy Propagation
7.5. Common-subexpression Elimination
7.6. Forward Substitution
7.7. Dead Code Elimination
7.8. Compiling the Transformations
8. Typestate Checking
9. Expression Blocks (*)
9.1. Syntax of Expression Blocks
9.2. Desugaring Expression Blocks
9.3. Example
II. Example Packages (*)
10. Tiger Base (*)
10.1.
10.2.
10.3.
11. BibTeX Tools (*)
11.1.
11.2.
11.3.

List of Figures

2.1. file: til/xmpl/test1.til
2.2. file: til/syn/TIL-layout.sdf
2.3. file: til/syn/TIL-literals.sdf
2.4. file: til/syn/TIL-expressions.sdf
2.5. file: til/syn/TIL-statements.sdf
2.6. file: til/syn/TIL-calls.sdf
2.7. file: til/syn/TIL.sdf
2.8. file: til/syn/maak
2.9. file: til/syn/TIL.def
2.10. file: til/xmpl/parse-test
2.11. file: til/xmpl/test1.atil
2.12. file: til/sig/maak
2.13. file: til/sig/TIL.rtg
2.14. file: til/sig/TIL.str
2.15. file: til/xmpl/fc-test1
2.16. file: til/xmpl/test1.atil.fc
2.17. file: til/xmpl/test1-wrong.atil
2.18. file: til/xmpl/fc-test2
2.19. file: til/xmpl/test1-wrong.atil.fc
2.20. file: til/pp/maak
2.21. file: til/pp/TIL.pp
2.22. file: til/xmpl/pp-test1
2.23. file: til/xmpl/test1.txt1
2.24. file: til/pp/TIL-pretty.pp
2.25. file: til/xmpl/test1.txt2
2.26. file: til/xmpl/pp-test3
2.27. file: til/xmpl/test2.atil
2.28. file: til/xmpl/test2.txt1
2.29. file: til/xmpl/test2.atil.par
2.30. file: til/xmpl/test2.txt2
2.31. file: til/xmpl/til-process
3.1. file: til/sim/til-eval.str
3.2. file: til/sim/til-desugar.str
3.3. file: til/sim/til-simplify.str
3.4. file: til/sim/maak
3.5. file: til/xmpl/simplify-test
4.1. file: til/renaming/til-rename-vars.str
4.2. file: til/xmpl/rename-test
5.1. file: til/tc/til-typecheck.str
5.2. file: til/tc/til-typecheck-exp.str
5.3. file: til/tc/til-typecheck-stats.str
5.4. file: til/tc/til-typecheck-var.str
5.5. file: til/xmpl/typecheck-test1
6.1. file: til/run/til-eval-exp.str
6.2. file: til/run/til-eval-var.str
6.3. file: til/run/til-eval-stats.str
6.4. file: til/run/til-run.str
6.5. file: til/run/maak
6.6. file: til/xmpl/run-test1
6.7. file: til/xmpl/test1.run
7.1. file: til/opt/til-opt-lib.str
7.2. file: til/xmpl/propconst-test2
7.3. file: til/opt/til-propconst.str
7.4. file: til/xmpl/copyprop-test2
7.5. file: til/opt/til-copyprop.str
7.6. file: til/opt/til-copyprop-rev.str
7.7. file: til/xmpl/cse-test2
7.8. file: til/opt/til-cse.str
7.9. file: til/opt/til-forward-subst.str
7.10. file: til/xmpl/dce-test2
7.11. file: til/opt/til-dce.str
7.12. file: til/opt/maak
9.1. file: til/til-eblock/TIL-eblocks.sdf
9.2. file: til/til-eblock/til-eblock-desugar.str
9.3. file: til/xmpl/eblock-desugar-test2

List of Tables

3.1. files: til/xmpl/test1.til, til/xmpl/test1.sim.txt
4.1. files: til/xmpl/test1.til, til/xmpl/test1.rn.txt
5.1. files: til/xmpl/test1.til, til/xmpl/test1.tc
7.1. files: til/xmpl/propconst-test2.til, til/xmpl/propconst-test2.txt
7.2. files: til/xmpl/copyprop-test2.til, til/xmpl/copyprop-test2.txt
7.3. files: til/xmpl/cse-test2.til, til/xmpl/cse-test2.txt
7.4. files: til/xmpl/dce-test2.til, til/xmpl/dce-test2.txt
9.1. files: til/xmpl/eblock-desugar-test2.til, til/xmpl/eblock-desugar-test2.txt
9.2. files: til/xmpl/eblock-desugar-test2.txt, til/xmpl/eblock-desugar-test2.cp.txt