SmaCC Transformation Toolkit methods
Scripts can define methods that can be called from other rewrite rules or methods. These methods are compiled into a specially created subclass of SmaCCRewriteMatchContext
, and they can be invoked using self when evaluated in a rewrite match or method.
For example, in the JavaScript conversion we compute the free variables used by the program or function and generate a JavaScript var statement. Because this logic is shared, we can define a method that creates the var statement and call it from different locations: