Re: re-entrant parsers, pure_parser, bison, flex

Jeffrey Vetter <vetter@cc.gatech.edu>
22 Jul 1997 21:00:28 -0400

          From comp.compilers

Related articles
re-entrant parsers, pure_parser, bison, flex lmipjmy@eei.ericsson.se (PJ Mealy) (1997-07-13)
Re: re-entrant parsers, pure_parser, bison, flex lmipjmy@eei.ericsson.se (PJ Mealy) (1997-07-16)
Re: re-entrant parsers, pure_parser, bison, flex tiggr@ics.ele.tue.nl (1997-07-16)
Re: re-entrant parsers, pure_parser, bison, flex lmipjmy@eei.ericsson.se (PJ Mealy) (1997-07-18)
Re: re-entrant parsers, pure_parser, bison, flex cfc@world.std.com (1997-07-18)
Re: re-entrant parsers, pure_parser, bison, flex 71511.3711@CompuServe.COM (Brian W. Inglis) (1997-07-21)
Re: re-entrant parsers, pure_parser, bison, flex bear@sonic.net (Ray Dillinger) (1997-07-22)
Re: re-entrant parsers, pure_parser, bison, flex vetter@cc.gatech.edu (Jeffrey Vetter) (1997-07-22)
Re: re-entrant parsers, pure_parser, bison, flex jlilley@empathy.com (John Lilley) (1997-08-24)
| List of all articles for this month |

From: Jeffrey Vetter <vetter@cc.gatech.edu>
Newsgroups: comp.compilers
Date: 22 Jul 1997 21:00:28 -0400
Organization: Georgia Tech; Atlanta
References: 97-07-081 97-07-098
Keywords: parse, parallel

Hi,


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...


#ifdef HAVE_FLEX
#undef YY_INPUT
#define YY_INPUT(b,r,ms) (r=_fake_parser_input_with_string(b,ms,param))
#endif


#undef YY_DECL
#define YY_DECL int yylex(lvalp,param)YYSTYPE*lvalp;void*param;


....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. ...
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.