解决方法
我不知道最好的,但你可以看看
Ragel:
Ragel compiles executable finite state machines from regular languages. Ragel targets C,C++,Objective-C,D,Java and Ruby. Ragel state machines can not only recognize byte sequences as regular expression machines do,but can also execute code at arbitrary points in the recognition of a regular language.