I did something of this nature to create a thread-safe interpreter that
accepts arbitrary commands at runtime from a one-liner to an entire file.
I used pure-parser in bison and flex. A GUI can send this parser commands
at runtime and then call yyparse to run the interpreter.

Eliminate globals...

Use %pure_parser
Carry a parameter through the parser calls
#define YYPARSE_PARAM param
#define YYLEX_PARAM param
I had to write a awk script to change the yacc/lex generated files
so that they would carry the 'param' through every
function call. This was important b/c I was using string
input.

Use string input instead of file input...but remember that it's
multithreaded, so you have to have a buffer for each possible thread...

....There's lots of interactions here. Please send me a note if you want a
copy of the files or such...The O'Reilly lex/yacc book is a must when your
doing this kind of stuff too. Good luck.

-Jeffrey Vetter

On 21 Jul 1997, Brian W. Inglis wrote:

> PJ Mealy writes:> > As the GUI is structured around an event processing loop> > I can't just go ahead and do the full parse in one go.> > I need to have the event loop active periodically to process> > progress bar updates and respond to a click on the CANCEL button.>> Sure you can. Just invert the approach. Think INPUT.> Add whatever you need into the yylex() function. ...
--