Bison, flex and pthreads, is bison or flex holding state info?
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Bison, flex and pthreads, is bison or flex holding state info?




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Bison, flex and pthreads, is bison or flex holding state info?  
examnotes


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:36 PM

Hello,

I'm creating a small program which runs as a MT daemon where users can
connect using HTTP and perform misc tasks. One thing the user can do is
to post source code for a tiny special purpose language I designed.

I use Bison & Flex to parse the source code and believe I've created a
thread save version, using the %pure_parser directive. The parser reads
its input from a character buffer, not from file.

The problem is this: The first time I try to compile some source,
everything works well. The second time I get a "syntax error" message on
line 1.

My "theory" is that either flex or bison holds some kind of state info
and that they need to be reset in some way. If that is correct, doesn't
that indicate that the parser isn't reentrant?

I've browsed the C source generated by flex, and IMHO it looks quite
suspicious. Here's a few lines from the generated code:
quote:
> static YY_BUFFER_STATE yy_current_buffer = 0; > > /* We provide macros for accessing buffer states in case in the > * future we want to put the buffer states in a more general > * "scanner state". > */ > #define YY_CURRENT_BUFFER yy_current_buffer > > > /* yy_hold_char holds the character lost when yytext is formed. */ > static char yy_hold_char; > > static int yy_n_chars; /* number of characters read into yy_ch_buf */ > > > int yyleng; > > /* Points to current character in buffer. */ > static char *yy_c_buf_p = (char *) 0; > static int yy_init = 1; /* whether we need to initialize */ > static int yy_start = 0; /* start state number */ > > /* Flag which is used to allow yywrap()'s to do buffer switches > * instead of setting up a fresh yyin. A bit of a hack ... > */ > static int yy_did_buffer_switch_on_eof;
All of these variables have file scope. This doesn't look good, does it? Has anyone out there successfully used bison&flex in a multithreaded program before? Is it doable, and if so, what am I doing wrong? Regards, Bjørn -- The worlds fastest web server is now available at http://highlander.metasystems.no:2000. Enjoy!




[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 01:26 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register