🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Donald A. Thompson Sun, 31 Jan 1999 00:00
Thread-safe code from bison (yacc) and flex (lex)
#6962
Author: Donald A. Thompson
Date: Sun, 31 Jan 1999 00:00
11 lines
1010 bytes
I am looking for versions of bison (or yacc) and flex (or lex) that produce
thread-safe C code.

Alternatively, I'd like pointers on methods to modify the C code produced by
these programs to make the C code thread-safe.  I think the problem is that
some basic data structures (e.g., yytext) in the C code are global
variables.

Thank you.

-Don Thompson
Re: Thread-safe code from bison (yacc) and flex (lex)
#6963
Author: Anders Wegge Jakobsen
Date: Sun, 31 Jan 1999 00:00
23 lines
1698 bytes
"Donald A. Thompson" <dont@pluto.njcc.com> writes:

> I am looking for versions of bison (or yacc) and flex (or lex) that produce
> thread-safe C code.
> 
> Alternatively, I'd like pointers on methods to modify the C code produced by
> these programs to make the C code thread-safe.  I think the problem is that
> some basic data structures (e.g., yytext) in the C code are global
> variables.

 Parsers generated by bison can be made reentrant with the declaration 
%pure_parser. 

 It's a bit harder to make flex scanners thread-safe, but depending on 
the problem at hand, a semaphore wrapped around the flex code might
do the trick. If that's not enough, yy_swithch_to_buffer() and
yy_restart(), will take you a bit further. If you can determine a
finite need for concurrent scanners, the -Pprefix option can at least
give each scanner it's own namespace.


-- 
/Wegge
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads