views:

2415

answers:

4

What is the difference between Flex & Lex and Yacc & Bison. I searched the Internet wildly and I didn't find any solid answer.

Can I install pure Lex and Yacc on Ubuntu, or I can install only flex and bison. I am confused.

Is Lex or Yacc still being maintained by someone ?

Are all of them free ?

If Lex is not free why do I have it installed on my Ubuntu distribution ?

lex --version

lex 2.5.35

+4  A: 

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.

Jan Jungnickel
Additionally, byacc, the Berkeley implementation of yacc, is widely available (I see it in my Debian repository list).
Michael E
+8  A: 

There are some differences between Lex and Flex, but you have to be abusing Lex to run into the problems with Flex. (I have a program which abuses Lex and doesn't work under Flex, therefore.) This is primarily in the area of input lookahead; in Lex, you can provide your own input code and modify the character stream; Flex won't let you do that.

Yacc and Bison are pretty closely compatible, though Bison has some extra tricks it can do.

You probably can't find legitimate copies of (the original, AT&T versions of) Lex and Yacc to install on Ubuntu. I wouldn't necessarily say it is impossible, but I'm not aware of such. Flex and Bison are readily available and are equivalent for most purposes. You may also find various alternative and approximately equivalent programs from the BSD world.

Lex and Yacc are maintained by the Unix SVRx licencees - companies such as IBM (AIX), HP (HP-UX) and Sun (Solaris) have modified versions of Lex and Yacc at their command. MKS also provides MKS Lex and MKS Yacc; however, the Yacc at least has some non-standard extensions.

Flex and Bison are free. (AT&T) Lex and Yacc are not.

Jonathan Leffler
The information about Yacc is incorrect. Berkeley has a Yacc, which is present and available under the BSD license on all open source BSD operating systems. I downvoted on this account, but if the answer is corrected quickly enough I'll remove the downvote.
Daniel
Jonathan Leffler
+1  A: 

On most (all?) Linux systems, "Lex" is actually a symbolic link to flex. Basically, it's only a different name to the free version.

ndr
+1  A: 

YACC is available under open source licenses from both Plan 9 and Open Solaris. Also, there is also Berkeley YACC, which is compatible with the original YACC, but does not share source code. Berkeley YACC can be found on any of the open source BSD operating systems.

Daniel