Research Article

SPOT: A DSL for Extending Fortran Programs with Metaprogramming

Algorithm 1

An example of rules defined with Stratego/XT.
module exampleStrategoXT
rules
For2While:
  For(a, exp1, exp2, stmt*) ->
   Block(
    DeclarationTyped(b, TypeName("int")),
    Assign(a, exp1),
    Assign(b,  exp2),
    While(Leq(Var(a), Var(b)),
     <conc>(stmt*, Assign(a, Add(Var(a), Int("1"))))
    )
   )
  where new => b
IfThen2IfElse:
  IfThen(exp, stmt) -> IfElse(exp, stmt, )