Thread-safety, lex and yacc.

Nicholas Dronen <>
31 Mar 2001 02:35:00 -0500

          From comp.compilers

Related articles
Thread-safety, lex and yacc. (Nicholas Dronen) (2001-03-31)
Re: Thread-safety, lex and yacc. (2001-04-04)
Re: Thread-safety, lex and yacc. (Troy Cauble) (2001-04-10)
Re: Re: Thread-safety, lex and yacc. (John W. Millaway) (2001-04-12)
Re: Thread-safety, lex and yacc. (Clark) (2001-04-12)
Re: Re: Thread-safety, lex and yacc. (Ethan Eade) (2001-04-14)
| List of all articles for this month |

From: Nicholas Dronen <>
Newsgroups: comp.compilers
Date: 31 Mar 2001 02:35:00 -0500
Organization: Front Range Internet, Inc. (800.935.6527)
Keywords: lex, yacc, parallel, comment
Posted-Date: 31 Mar 2001 02:35:00 EST


I noticed that yylval is a global variable in the lex file for an
application I'm auditing for thread-safety. In the C++ source file
generated by lex, the variable is global as well. I suspect that this
doesn't bode well for the thread-safety of the application.

We use MKS lex. The reference manual says that yylval is a global
variable. On the other hand, it also says you can use the -DYYALLOC
preprocessor directive to yacc to generate reentrant code. I don't
see where it says anything about the reentrancy of the scanner.

Does anyone have experience with making an apparantly non-thread-safe
lex/yacc code base thread-safe? Suggestions and pointers welcome.


Nicholas Dronen
[If you tell flex to generate a C++ lexer, it's thread safe. Haven't
seen a thread-safe yacc but I haven't looked very hard either. It
wouldn't be hard to do. -John]

Post a followup to this message

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