Grammar Tools

XT -- A Bundle of Program Transformation Tools

The GrammarTools (GT) package contains a collection of grammar-related tools. These include tools for creating grammars, transforming grammars, generating code from grammars, testing grammars.




  • packsdfGT: collect Sdf modules into a single Sdf definition file.
  • unpacksdfGT: split a single Sdf definition file into separate Sdf modules (unpackGT is a non-Sdf-specific variant).
  • sdfppGT, sdf2textGT: pretty-print Sdf syntax definitions.
  • ast2boxGT: a generic pretty-printer.
  • ast2aboxGT: ??
  • parseGT: parse terms over grammars in the GrammarBase?.
  • ppgenGT: generate a pretty-print table for a grammar.
  • ast2aboxGT: transforms an abstract syntax tree to BOX.
  • asfix2aboxGT: transforms a parse tree to BOX.

  • sdf2sdfGT: combine transformations on Sdf syntax definitions

Grammar analysis

  • sdfbenchGT: benchmarking parsers generated from grammars.
  • sdfwfGT: grammar well-formedness checker.
  • tohtmlsdfGT: creating clickable (visual) representations of grammars.
  • importssdfGT: analyze the import structure of a grammar.
  • importsstrategoGT: analyze the import structure of a Stratego specification.
  • getsortgraphGT, sdf2sgGT, sdfdocGT, GraphXML2dot?.

Grammar (re)construction

  • yacc2sdfGT: transform Yacc input into an Sdf definition.
  • happy2yaccGT: transform Happy input into Yacc input.
  • dtd2sdfGT: transform an XML DTD into an Sdf definition.
  • sdfconsGT, rmconsGT: add cons annotations to an Sdf grammar, or remove them.
  • addlabelsGT, rmlabelsGT: add labels to an Sdf grammar, or remove them.
  • asfix2sdfGT: reconstruct an Sdf grammar from a parse tree.
  • sdfnormalizeGT, sdfdenormalizeGT: introduce kernel Sdf productions, or eliminate them.

Tree manipulation

  • asfixyieldGT, also known as asourceGT: unparsing parse trees.
  • implodeasfixGT: transforming parse trees to abstract syntax trees.
  • sdf2asdfGT: generating an AbstractSdf? definition from an Sdf definition.


  • asfixGT: library code related to the parse tree formalism AsFix.
  • libGT: miscelaneous library code.


  • XtDownload: The grammar tools are distributed as part of the XT distribution.


If you have questions or suggestions, or if you would like to contribute to the GrammarTools package, feel free to contact the GrammarToolsMaintainers?.