Ragel http://www.complang.org/ragel/ is a tool that integrates regular expressions and state machines under one umbrella. It has backends currently for C, C++, Objective-C, D, Java and Ruby. I do not think having an elisp backend would be a very big task. After that (in my estimate) org-mode code would (could) become half as long and twice as fast -- at least those sections that are heavily regex oriented