That's pretty cool. It reminds me of writing peep-hole patterns for an optimizing compiler.