Symbol Table
Stratego -- Strategies for Program Transformation
Question: Is there any symbol table implementation in stratego?
Yes. There are several ways to go about using symbol table like
functionality in Stratego programs.
First of all you could the strategies in module tables.str in
SSL, which provides strategies such as
<table-push> (st, key, val)
for pushing a new binding of val to key in symbol table st. These
strategies maintain a stack of bindings for each key.
This method is rather low-level though.
The preferred method is to use dynamic rules, rewrite rules 'generated' at run-time can be used to bind any values to any
keys and can be applied as ordinary rules. The liveness of these
bindings can be regulated using the scope mechanism
{| Rule : strat |}
The dynamic rule mechanism takes care of storing information in
a table, retrieving it, and cleaning up after leaving a scope.
See the paper '
Scoped Dynamic Rewrite Rules' for an explanation
of this method. The examples in the paper are examples of the
use of a symbol table, but maybe not the ones you are looking
for. More examples can be found in the implementation of the
Tiger compiler,
for instance, in the typechecker and the translation to IR.
--
EelcoVisser - 23 Jul 2003