SDF2RTG(1)

NAME
sdf2rtg - generates a abstract regular tree grammar (RTG) from an SDF concrete syntax definition.

SYNOPSIS

sdf2rtg [-m mod | --main mod] [-i file | --input file] [-o file | --input file] [-b] [-S | --silent] [--verbose level] [-k level | --keep level] [--check] [-h | -? | --help] [--about] [--version]

DESCRIPTION

The sdf2rtg utility is used to generate an abstract regular tree grammar (RTG) from a SDF concrete syntax definition.

Regular tree grammars are useful for doing format checking of terms. Refer to Format Checking with format-check for further details.

OPTIONS

Grammar Options

-m mod, --main mod
    Set the main module in the SDF syntax definition to mod. The default main module is Main.

Common Input/Output Options

-i file
    The input term given by the file name file.

    In the absence of the -i option, input will be read from stdin.

-o file
    The output will be written to the file given by the file name file.

    In the absence of the -o option, output will be written to stdout.

-b  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

--about
    See --version.

-h, -?, --help
    Display usage information.

--keep int
    Keep intermediate results produced by the internal stages in the pretty-printing process. This is only useful for debugging. A high value of int indicates increased eagerness for keeping intermediate results.

    Default setting is 0, indicating that no intermediates will be kept.

-S, --silent
    Silent execution. Same as --verbose 0.

--verbose int
    Set verbosity level to numerical value int. The higher the number, the more information about pp-aterm's inner workings are printed.

    Alternatively, int can be set to either of the following verbosity levels, given in increasing order of verbosity: emergency, alert, critical, error, warning, notice, info, debug, vomit.

--version
    Displays the tool name and version.

EXAMPLE

Consider the following SDF syntax definition for a simple expression language:

definition
module Exp
exports
  sorts Exp
  lexical syntax
    [\ \t\n]  -> LAYOUT
    [a-zA-Z]+ -> Id
    [0-9]+    -> IntConst
  context-free syntax
    Id        -> Exp {cons("Var")}
    IntConst  -> Exp {cons("Int")}
    Exp "*"  Exp -> Exp  {left, cons("Mul")}
    Exp "/"  Exp -> Exp  {left, cons("Div")}
    Exp "%"  Exp -> Exp  {left, cons("Mod")}
    Exp "+"  Exp -> Exp  {left, cons("Plus")}
    Exp "-"  Exp -> Exp  {left, cons("Minus")}
  context-free priorities
    {left:
      Exp "*"  Exp -> Exp
      Exp "/"  Exp -> Exp
      Exp "%"  Exp -> Exp
    }
  > {left:
      Exp "+"  Exp -> Exp
      Exp "-"  Exp -> Exp
    }

Invoking sdf2rtg with sdf2rtg -i Exp.def --main Exp will result in the following regular tree grammar:

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>

REPORTING BUGS

Please report bugs to <stratego-bugs@cs.uu.nl>

COPYRIGHT

Copyright (C) 2002-2005 Eelco Visser <visser@acm.org>

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.