rtg2typematch — generates a set of Stratego strategies for typechecking terms against a regular tree grammar (RTG)
file | --input
file | --output
[-S | --silent]
level | --keep
[-h | -? | --help]
The rtg2typematch utility is used to generate a collection of Stratego strategies with can be used to typecheck terms against a regular tree grammar.
The regular tree grammar is derived from the syntax definition, so the strategies generated by rtg2typematch are useful for checking the well-formedness of a term against a particular SDF grammar.
Common Input/Output Options
The input term given by the file name
In the absence of the
-i option, input
will be read from
The output will be written to the file given by the file name
In the absence of the
output will be written to
The output will be written in the binary (BAF) ATerm format.
ATerms in the BAF format require a lot less space than ones in the TAF format, but the Java ATerm library does not currently support baf ATerms. ATerms in the baf format is the preferred format of exchange between Stratego tools.
Common Debugging Options
Display usage information.
Keep intermediate results produced by the internal stages in the
pretty-printing process. This is only useful for debugging. A high
int indicates increased eagerness
for keeping intermediate results.
Default setting is 0, indicating that no intermediates will be kept.
Silent execution. Same as
Set verbosity level to numerical value
higher the number, the more information about pp-aterm's inner workings are
int can be set to either of the
following verbosity levels, given in increasing order of verbosity:
Displays the tool name and version.
Consider the regular tree grammar given below (the exciting part about how we created this from an SDF definition can be gleaned from the example for 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>
We run rtg2typematch as shown below, to obtain the
following Stratego module. Assume the regular tree grammar above is
$rtg2typematch -i Exp.rtg -o Exp-typematch.rtg
module Exp-typematch strategies is-Exp = ?Minus(_, _) + ?Plus(_, _) + ?Mod(_, _) + ?Div(_, _) + ?Mul(_, _) + ?Int(_) + ?Var(_) is-IntConst = is-string is-Id = is-string
From inspecting the generated code, we see that
is-Exp can be used
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.
Please report bugs to
Copyright (C) 2002-2005 Eelco Visser
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.