help-flex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

reentrancy


From: Laurence Finston
Subject: reentrancy
Date: Wed, 10 Mar 2004 17:45:20 +0100
User-agent: IMHO/0.98.3+G (Webmail for Roxen)

Hello,

I've started working on writing the input routine for GNU 3DLDF using Bison
and Flex.  Now I'd like use multiple processes, or possibly threads, for
reading from more than one file at a time.  Is there any way of making Flex
reentrant, aside from using it to generate a C++ scanner class?  

I wouldn't mind using a C++ scanner class, since 3DLDF is written in C++
anyway, except that the Flex manual indicates that this feature is
experimental, and I don't know how to get Bison to use an object of this class
rather than just calling `yylex()'. 

I've already changed the calling convention for `yylex()' in order to make
`yyparse()' reentrant, as described in the Bison manual, so the value of the
token and the location are no longer stored in global variables.  I believe it
will work to redefine `YYINPUT' so that it doesn't use `yyin' and pass the
`File*' as a parameter to `yylex()', but I don't know what other global
variables might be involved.

I thought it might help to call `yylex()' something else, e.g., `lexscan()',
and define a `yylex()' in the Bison input file that wraps `lexscan()'.  Then I
could make the calls to `lexscan()' atomic.  I think this would only work with
non-preemptive scheduling, though, and I do want it to be possible to use
threads with preemptive scheduling, or heavyweight processes. 

I'd really appreciate it if someone could help me with this.

Laurence Finston



reply via email to

[Prev in Thread] Current Thread [Next in Thread]