STR-669: Support anti-pattern matching
Pierre-Etienne Moreau mentioned anti-pattern matching in his talk about TOM at the SUD. The feature is simple and easy to understand (almost obvious). Anti-pattern matching would be a nice feature to have in Stratego.
Example:
———————————————————————————-
AddBlock :
If(e, stm1, stm2) -> If(e, Block([stm1]), stm2)
where
<not(?Block(_))> stm2
———————————————————————————-It would be nice to be able to express this not concisely in the pattern. Currently, it is already possible to do this:
AddBlock :
If(e, <not(?Block(_)); ?stm1>, stm2) -> If(e, Block([stm1]), stm2)
———————————————————————————-but this is a bit of a hack.
Something like this would be cleaner:
AddBlock :
If(e, stm1@not(Block(_)), stm2) -> If(e, Block([stm1]), stm2)
———————————————————————————-where not( ) is a new kind of pattern added to the language
without variable binding it would look like:
AddBlock :
If(e, not(Block(_)), stm2) -> If(e, Block([stm1]), stm2)
———————————————————————————-not is already a reserved keyword in Stratego.
Submitted on 2 December 2006 at 23:08
Issue Log
Log in to post comments