With flex, you can use %option reentrant with bison %pure-parser to generate %option reentrant code that does not have global data. You may need some synchronization to prevent multiple threads from using the same data blocks at the same time.
source share