A dynamic rule is an ordinary RewriteRule that is generated at run-time. A dynamic rule can inherit bindings of variables from its generation context. Dynamic rules solve the problem caused by the context-free nature of normal rewrite rules.

Syntax

A set of dynamic rules is introduced by the keyword rules as follows

rules(
  Lab1 : l1 -> r1 where s1 
  ... 
  Labn : ln -> rn where sn
)
This construct itself defines a RewritingStrategy that can be applied. All variables that are statically bound before the rules construct is invoked are inherited by the dynamic rules.

Resources

Dynamic rules are useful in many transformation problems. Several examples of dynamic rules are presented in the paper Scoped Dynamic Rewrite Rules.

The dynamic rule semantics has undergone some changes over time. Hairy issues include overlapping left-hand sides in dynamic rules with the same label and the application of dynamic rules to terms with annotations.

Pragmatics

In order to use dynamic rules in a module it is necessary to import the module dynamic-rules.

Dynamic Rules Rethought

We're currently rethinking the concept of dynamic rules. Quite some changes are at stake. We maintain (some of) our thoughts at Dynamic Rules Rethought.

Related Constructs in Other Languages

Dynamic rules are an innovation of Stratego. Some other languages have constructs that have commonalities with dynamic rules. See Dynamic Rules Related for a discussion.


-- EelcoVisser - 06 Dec 2001
-- EelcoVisser - 07 May 2002
-- ArthurVanDam - 25 Mar 2004

Revision: r1.6 - 28 Apr 2005 - 22:24 - Main.wiki
Stratego > StrategoGlossary > DynamicRule
Copyright © 1999-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback