Rules & Canonizers
Experimental
Rewrite rules cannot be written in SPL today: the left-hand side of a rule is parsed as an expression, and an expression already reads lhs => rhs as an implication, so the parser then finds no => to separate the two sides. Every rules declaration with at least one rule is rejected. Canonizers parse, but have no rule set to refer to.
Rewrite rules#
The intended form is a named, parameterised rule set whose rules are pattern => replacement ;:
rules ArithSimplify(x) {
x + 0 => x ;
}An empty rule set parses:
rules Empty(x) { }Canonizers#
A canonizer names a normalisation strategy for a type as a list of steps, each applying a rule set with a traversal strategy:
canonizer NormalForm for Int {
apply(rules: ArithSimplify, strategy: bottomUp) ;
apply(rules: BoolSimplify, strategy: topDown) ;
}