Stratego FAQ

Stratego -- Strategies for Program Transformation
Q: Can I get Stratego/XT running on Windows?

A: The 0.17 version does not work on Windows at the moment. The previous stable release, 0.16 does.

Q: Can I get Stratego/XT running on OSX?

A: This is Unix! I know this! (Yes, by either installing it through Nix or compiling from sources.)

Q: What's the difference between spinetd and oncetd?

A: The spine topdown traversal applies a strategy parameter at every aterm on a spine from the root to a leaf. The once topdown strategy applies its strategy parameter at only a single location.

signature

 constructors
    A : Term -> Term
    A : Term * Term -> Term
    A : Term * Term * Term -> Term
    A : Term * Term * Term * Term -> Term
    B : Term -> Term
    B : Term * Term -> Term

strategies

    main = !A(0,1,B(2,3),4) ; spinetd((not(int) ; debug(!"> ") <+ fail))

Running main gives you this:

> A(0,1,B(2,3),4)
> B(2,3)
A(0,1,B(2,3),4) 

Q: Why does sdf2table (SdfChecker?) always complain that the Main module is not defined?

A: When you run sdf2table in the present (0.17) Stratego/XT, e.g.

$ sdf2table -i Expression.def -o Expression.tbl -m Expression

you will always get the error message that the Main module is undefined:

SdfChecker:error: Main module not defined 

This is a known bug. Ignore it. It's been fixed upstream already, and will trickle into newer Stratego/XT releases.

Technical details: The sdf2table script first does a check of the grammar using sdfchecker before it applies the generator, parsetablegen. sdfchecker is the one emitting the error message. Since parsetablegen is the tool responsible for actually generating the .tbl file, it doesn't matter that sdfchecker is being unreasonably cranky.

If this annoys you unbearably, name your main module Main.sdf.

Q: Where is this "alt" stuff coming from?

A: Don't use alternatives in your SDF, i.e. don't use productions of the form

   "foo" (A | B) "bar" -> C

Instead, write

   "foo" AorB "bar" -> C
   A                -> AorB
   B                -> AorB

This is really equivalent, since the SDF normalizer transforms the first production to

   "foo" (A | B) "bar" -> C
   A                   -> (A | B)
   B                   -> (A | B)

However, asfix-implode interprets the latter to include alt constructors. This is needed to cover cases such as

   "foo" ("a" A | "b" B) "bar" -> C

such that the alternatives can be reconstructed (e.g. when pretty-printing). Since the alternatives need to be named to distinghuish them, this is better written as

  "foo" AorB "bar" -> C {cons("Foo")}
  "a" A            -> AorB {cons("A")}
  "b" B            -> AorB {cons("B")}

so that you can actually control the names used.

-- KarlTrygveKalleberg - 30 Oct 2008