[COLUG] Lets talk about FLEX

paul.bender at acm.org paul.bender at acm.org
Wed Apr 18 17:35:17 EDT 2007


On 18 Apr, Tom Hanlon wrote:
> What is flex, what is lex ?
> 
> The wikipedia page helps.. but the big picture overview could be useful.
> 
> Also it seems that when i need Lex, I use FLEX  and also sometimes,  
> YACC or BISON end up in the mix.
> 
> Are these all code generators of some sort ?

Yes.

Flex and lex generate scanners, or Lexical Analyzers. The two programs
are basically equivalent.

Bison and Yacc are parser generators.  Again, the two programs are
basically equivalent.

When used together, you can look at the code generated by flex or lex as
recognizing words in a language, and the code generated by bison or yacc
recognizes the grammar of that language.  In other words, the two
programs together generate code for a parser, based on the rules you set
forth in your input files.

> I also recall though my memory may be faulty that sometimes FLEX or  
> BISON are required to deliver error output from soome programs.  
> Meaning I *think* that i have sometimes seen a failing program make a  
> call to one of them and then the error becomes the lack of flex ?

I don't believe this is the case.  When flex and bison are used to build
a parser, the result is C code, which is then compiled in to the
application.  It's possible there could be an automated call to one of
the programs, but that wouldn't generate an error like you describe.

Paul


More information about the colug432 mailing list