Perhaps a job for Ragel, if it supports binary grammars?
Activity