Contents    Page-10    Prev    Next    Page+10    Index   


lex is a lexical analyzer generator, part of a compiler-compiler system when paired with yacc.[There are Gnu versions of lex and yacc called flex and bison. These are mostly, but not completely, compatible with lex and yacc.]

lex allows a lexical analyzer to be constructed more easily than writing one by hand. lex allows the grammar to be specified using regular expressions; these are converted to a nondeterministic finite automaton (NFA), which is converted to a deterministic finite automaton (DFA), which is converted to tables to control a table-driven parser.

lex reads a source file, named using a .l suffix, compiles it, and produces an output file that is always called lex.yy.c . This is a C file that can be compiled using the C compiler to produce an executable.