What is the difference between Flex/Lex and Yacc/Bison?

ParsingBisonYaccFlex LexerLex

Parsing Problem Overview


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
    

Parsing Solutions


Solution 1 - Parsing

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.

Solution 2 - Parsing

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.

Solution 3 - Parsing

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

Solution 4 - Parsing

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.

Solution 5 - Parsing

Bison in a part of the GNU project. And yacc is used as a utility on Berkeley Software Distribution (BSD).Though its compatible with yacc, but Lex and Yacc are a thing of the past. Flex and bison are widely used today.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDumb QuestionerView Question on Stackoverflow
Solution 1 - ParsingJonathan LefflerView Answer on Stackoverflow
Solution 2 - ParsingJan JungnickelView Answer on Stackoverflow
Solution 3 - ParsingndrView Answer on Stackoverflow
Solution 4 - ParsingDaniel C. SobralView Answer on Stackoverflow
Solution 5 - ParsingAvani RanadeView Answer on Stackoverflow