bison-flex-cpp-example
bison-flex-cpp-example copied to clipboard
the parser is not reentrant
Thank you for publishing this useful example! I compiled and ran it fine using bison 3.0.4 and VS2013. However, as soon as I try to call parser from multiple thread, it crashes. For example: Interpreter i; concurrency::parallel_for(size_t(0), totalCommands, [&](size_t i) { res = i.parse(); } It crashes on this call yystack_[yylen] - index overflow. Is this a reentrancy issue, or I'm missing smth?
Bison/flex is not reentrant by default. There is a solution for this problem. I'd be happy to accept a PR.
https://stackoverflow.com/q/32535097/3602072
Thank you for the quick reply! I will research this further. It is unfortunate that bison docs and examples are very poor. They attempted to introduce "pure" keyword in 2.7, and then removed support for the keyword in all later releases. All parsers generated by bison that I have seen contain yystack_ which makes them non-reentrant. I'm using workaround: each thread created its own instance of driver/interpreter. Not very efficient but it accomplishes the goal of parallel parsing.
I'd be happy to include it if you don't mind. That example could be handy.
Thank you for the quick reply! I will research this further. It is unfortunate that bison docs and examples are very poor. They attempted to introduce "pure" keyword in 2.7, and then removed support for the keyword in all later releases. All parsers generated by bison that I have seen contain yystack_ which makes them non-reentrant. I'm using workaround: each thread created its own instance of driver/interpreter. Not very efficient but it accomplishes the goal of parallel parsing.