tl;dr How to get a Bison/Flex parser to periodically run code that checks for an interruption request from the user?
I am looking to make a Bison/Flex based parser stop cleanly in response to interactive input. In other words, the parser should periodically check for user interruption, and if an interruption request is detected, it should exit cleanly. I know that I can stop a Bison parser using YYABORT, but I am not sure where to insert the interruption checks. Which Bison rule is run is determined by the contents of the input file. Is there a way to specify that a certain piece of code should be run periodically regardless of the contents of the file that is being parsed? Should the interruption checks be handled on the Bison side of Flex side?
Take a look at flex's YY_USER_ACTION, the code in that macro is run every time a token is recognized. I'm not sure if bison has anything similar.