Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flex/lex yacc/bison multithreaded environment

Can I use the code generated by flex/bison|lex/yacc in a multithreaded environment ? I'm afraid there are a lot of global variables. How can it be fixed ?

like image 338
Pierre Avatar asked Nov 04 '09 22:11

Pierre


People also ask

What do you mean by flex lex Yacc and bison?

Lex and Yacc were the first popular and efficient lexers and parsers generators, flex and Bison were the first widespread open-source versions compatible with the original software. Each of these software has more than 30 years of history, which is an achievement in itself.

What is Flex and Bison used for?

Flex and Bison are tools for building programs that handle structured input. They were originally tools for building compilers, but they have proven to be useful in many other areas.

What is the difference between Yacc and bison?

Bison is the GNU implementation/extension of Yacc, Flex is the successor of Lex. In either case, it's fine (and recommended) to use bison / flex. Additionally, byacc, the Berkeley implementation of yacc, is widely available (I see it in my Debian repository list). flex is called that because it is (was?)

Is flex and Lex same?

Flex (fast lexical analyzer generator) is a free and open-source software alternative to lex. It is a computer program that generates lexical analyzers (also known as "scanners" or "lexers").


1 Answers

With flex you can use %option reentrant and with bison %pure-parser to generate re-entrant code that does not have global data. You may still need some sort of synchronization to prevent multiple threads using the same data blocks at the same time.

like image 180
laalto Avatar answered Oct 10 '22 17:10

laalto