Stratego/XT 0.17
Stratego -- Strategies for Program Transformation
NOTE: we're editing the NEWS in SVN. Please copy here after an update.
Stratego/XT 0.17 - released April 2008
Summary of Changes
Stratego/XT 0.17 introduces a major improvements across the board,
including language additions, a new compiler library, numerous
improvements to the compiler, significant changes to the library
handling, new libraries for parsing, pretty printing and term
validation, 64-bit support, stack traces and more.
For this release, over 200 outstanding issues have been addressed,
much thanks to the efforts of external bug reporters and contributors.
The manual has been updated to reflect the changes made to the
language and libraries, and the new libraries come with up-to-date
source code documentation.
Stratego Compiler
Standard C: Dropped GCC's nested functions
The backend has been changed so that the GCC-specific nested functions
feature is no longer required. This makes the C-code a lot more
portable across GCC-supported platforms, since nested functions are
not reliably supported on all architectures, notably not on MIPS and
OSX/Intel. Furthermore, this allows Stratego to use other C compilers
for than GCC for the generation of platform-specific binary code.
- [STR-697] - Standalone strc; allow users to override --cc and ---ld
- [STR-119] - Replace GCC nested functions by stack-allocated closures as structs
Stack traces on "rewriting failed"
The compiler backend and supporting runtime code have been modified to
provide full stack traces for the dreaded "rewriting failed"
situations.
Consider the following program:
main = foo
foo = bar
bar = fap ; zap
fap = id
zap = fail
When executed, it will print:
prog: rewriting failed, trace:
main_0_0
foo_0_0
bar_0_0
zap_0_0
This also works when you use
io-wrap and friends, but there are some
caveats:
- Only code compiled with the new compiler will show up in the
stack trace: if you call old libraries, stack frames for those
strategies will be invisble.
- =let=-blocks and other reasons for lifting will show up as
lifted_X frames.
A tiny set of stack introspection strategies for debugging purposes
has also been introduced.
Compiler library
The compiler has been librarified. Program analysis and transformation
tools which work on Stratego code may now be based on the Stratego
compiler library. The intent is to make meta-programming with Stratego
a lot easier and speedup the Stratego compiler.
- [STR-311]
- strc-lib : a library for compilation (meta-programming)
Stratego
Stratego Language
Dynamic rules
Improved flow-sensitive transformations
Thanks to Bogdan Dumitriu, the dynamic rule facility of Stratego has been
extended to deal with additional control flow constructs, including break,
break to label, continue and exceptions (try-catch-finally). Some of the
dynamic rule strategies, such as
dr-fix-and-intersect and
dr-fix-and-union
have been extended to work with labels, and new dynamic rule prefixes
break-
and
break-to-label- are introduced.
A
presentation
from Stratego User Days 2006 provides a high-level walk-through.
Scoped global variables
Stratego now supports
scoped global variables. In the context of a dynamic rules section one
can now write
rules( Foo := <compute> )
which abbreviates the following commonly used programming pattern:
x := <compute>
; rules( Foo : _ -> x )
The value bound in the assignment can be retrieved by the application <Foo>.
The usual scoping features of dynamic rules apply to global variable as well.
For more information see this
blog.
External Constructor Declarations
Assignment operator
An assignment operator has been added to the language as a more
attractive syntax for the common pattern
s => t. In the assignment
operator, the variable name is now before the right-hand side. Also,
the right-hand side is a term pattern.
get-signature(|file) :
Method(_, returntype, name, types, _, _) -> MethodSignature(cn, returntype, name, types)
where
cn := <get-classname> file
This used to be written as:
<get-classname> file => cn
Note that this is a purely syntactic change: the variable can only be
assigned to once.
Rule syntax in let
The
let construct now allows the defition of rules in addition to strategies:
let R : p1 -> p2
in
...
end
Import ATerm from file
A new language construct called
import-term was added which allows
the embedding of terms (data) directly into the program.
get-pp-table = import-term(pptable.trm)
This removes the need for external data files, such as parse and
pretty-print tables. The resulting executable is self-contained, thus
making deployment of your program transformation tools easier.
- [STR-577] - Stratego: support import of an ATerm from a file
Stratego Libraries
A new discipline for library naming and usage is introduces in
0.17. The standard library is now named
libstratego-lib, whereas the
XTC library is named
libstratego-xtc. Additional libraries have been
added for parsing, pretty printing and term validation, see below.
Migrating from XTC to libraries
To avoid the term serialization paid when composing transformation
pipelines using
XTC, the compiler and all supporting tools have been
rearchitected to as libraries in addition to the familiar
XTC
components.
For Stratego/XT users, the most significant change is that the
SGLR
parser, the various RTG tools and the
GPP tools are now available as
libraries, respectively named
libstratego-sglr,
libstratego-rtg
and
libstratego-gpp.
The librarification allows parse tables to be loaded once, at startup,
and used repeatedly when multiple files must be parsed (when using
XTC, the parse table is loaded by the
sglr child process every time
a file must be parsed).
Consider the following program:
module foo
imports
libstratego-lib
libstratego-sglr
strategies
main =
tbl := <import-term(Exp.tbl); open-parse-table>
; <parse-string(|tbl)> "a+b"
It assumes the existence of a parse table (
Exp.tbl). This table be
included into the program using the
import-term construct
(introduced above). The call to
open-parse-table will register the
parse table with the
libstratego-sglr library, and subsequent calls
to
parse-string will not need to reload the parse table.
Compiling and executing the program:
$ strc -i foo.str $(strcflags stratego-lib stratego-sglr)
$ ./foo
Plus(Var("a"),Var("b"))
The resulting program
foo is now fully self-contained. It does not need
the
Exp.tbl file to execute.
API documentation for the Stratego Libraries is available from the
Documentation page on the Stratego/XT website.
strcflags
The new tool
strcflags makes it no longer necessary to know all the
details of how to invoke the Stratego compiler when you're using a
certain library. Given the name of a package or Stratego library, the
tool returns the flags (such as include paths) for strc.
Example:
$ strc -i foo.str $(strcflags stratego-lib)
You can also specify multiple packages. For example, if you're using
java-front, then you usually using the Stratego library as well.
$ strc -i foo.str $(strcflags stratego-lib java-front)
The tool strcflags is a simple wrapper around the tool
pkg-config,
which we are using for configuring Stratego/XT packages when building
packages from source.
To support strcflags with your own packages, add a declaration of a
variable
strcflags to the pkg-config
.pc files.
Easy library creation
Creating libraries using the Stratego compiler has never been
easier. By using the
--library option to the compiler, all necessary
library files will be created.
$ strc -i foo.str --library
The resulting output includes static and dynamic libraries, as well as
libtool support files:
libfoo.a libfoo.c libfoo.la libfoo.lo libfoo.o libfoo.rtree libfoo.so
This option is intended for creating libraries that are not part of an
autoconf/automake package, similar to invoking
strc to compile a
program all the way to an executable.
Deployment
This release brings about major improvements to the deployment capabilities of
Stratego/XT.
Standards-compliant libraries
The Stratego libraries expose various features from the underlying
platform Stratego/XT executes on. In 0.17, the library has been
refactored so that the dependence on platforms is clearer, and this
gives rise to several variants of the library, including one for C99,
POSIX and one for POSIX+XSI. The great majority of Stratego/XT
programs, use the high-level strategies for file and term I/O, and
these programs will be unaffected.
The main benefit of this change is that we can now build all the
Stratego libraries on platforms that only support functions from
standard C99 (i.e. not full POSIX). This enables the deployment of
Stratego applications on such platforms. Some strategies from the
Stratego library are only available in the POSIX and POSIX+XSI
extensions. The name of the modules defining these strategies reflect
this.
- [STR-613] - Stratego library: Allow creation of library for specific standard (C99, POSIX, POSIX XSI)
Native Windows Support (MinGW?)
Stratego/XT now supports compiling natively on Microsoft Windows using
MinGW?. This results in a smaller footprint because of significantly
fewer and smaller dependencies as compared with Cygwin.
Binaries created for
MinGW? can be deployed to Microsoft Windows users
without any dependencies.
For this purpose, the
stratego-libraries package is also available
separately from Stratego/XT as source tarball and native Microsoft
Windows binaries. If you already have Stratego/XT, then there is no
need to install the
stratego-libraries.
OSX support
Stratego/XT 0.17 now fully supports OSX on PowerPC as well as Intel CPUs.
x86-64 support
Thanks to patches from Eelco Dolstra, the ATerm library now supports
64-bit machines, and the final blocker preventing Stratego/XT running
on 64-bit is now removed. This means 64-bit support is finally
here. Binary packages for 64-bit Linux distributions are provided for
your convenience.
Detailed List of Issues
The full list of issues closed in this release is available at:
Download and Installation
The release page contains the source distributions, binary RPMs, and
detailed instructions on how to install the distributions:
Bugs and Known Problems
See our issue tracking systems for reports about (open) bugs:
Please report any problems with installation or bugs in the
implementation to our issue tracking system. Please check the existing
issues to see if a report about the problem was already submitted.
Contributions
Developments, bug reports, and beta tests carried out by
- Sigoure Benoit
- Eric Bouwers
- Martin Bravenboer
- Arthur van Dam
- Valentin David
- Eelco Dolstra
- Bogdan Dumitriu
- Karl Trygve Kalleberg
- Lennart Kats
- Nicolas Pierron
- Rob Vermaas
- Eelco Visser
Thanks!