Rtg To Type Match

XT -- A Bundle of Program Transformation Tools

Introduction

rtg2typematch is a tool for generating a duck-typing-based strategies that check if an ATerm is of a type as defined in an RTG?. An example will make this more clear.

Example

Let's take the RTG produced by the example in the manual page of sdf2rtg?:

regular tree grammar
  start Exp
  productions
    Exp      -> Minus(Exp,Exp)
    Exp      -> Plus(Exp,Exp)
    Exp      -> Mod(Exp,Exp)
    Exp      -> Div(Exp,Exp)
    Exp      -> Mul(Exp,Exp)
    Exp      -> Int(IntConst)
    Exp      -> Var(Id)
    IntConst -> <string>
    Id       -> <string>

Apply rtg2typematch:

  > rtg2typematch -i Exp.rtg -o Exp-typematch.str

will result in the module

  ...

You can call is-Exp to check whether a term is of sort Exp. Notice that the generated code only looks at the name of the constructor. If the same constructor can be used to produce different sorts, the typematch strategy of all these sort will accept a term that is an application of this constructor.

Tools.RtgToTypeMatch moved from Stratego.SignatureToTypeMatch on 29 Jun 2004 - 08:09 by MartinBravenboer - put it back