🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #6963

Re: Thread-safe code from bison (yacc) and flex (lex)

#6963
From: 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
Technical Details
Message-ID: <m34sp7jow1.fsf@obelix.wegge.dk>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <791orb$p3a$1@winter.news.rcn.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f891f,b3abb9a70fbfad7f
X-Google-Attributes: gidf891f,public
X-Google-Thread: 1025b4,b3abb9a70fbfad7f
X-Google-Attributes: gid1025b4,public
From: Anders Wegge Jakobsen <wegge@wegge.dk>
Subject: Re: Thread-safe code from bison (yacc) and flex (lex)
Date: 1999/01/31
Message-ID: <m34sp7jow1.fsf@obelix.wegge.dk>
X-Deja-AN: 439079703
References: <791orb$p3a$1@winter.news.rcn.net>
Content-Type: text/plain; charset=US-ASCII
X-Complaints-To: news@daimi.au.dk
X-Trace: xinwen.daimi.au.dk 917806341 4542 255.255.255.255 (31 Jan 1999 18:12:21 GMT)
Organization: Trolderiet
Mime-Version: 1.0 (generated by tm-edit 7.108)
Reply-To: wegge@wegge.dk
NNTP-Posting-Date: 31 Jan 1999 18:12:21 GMT
Newsgroups: comp.lang.misc,gnu.misc.discuss