Regular expression stuff using Thompson's algorithm and NDAs