Writing a lexical analyzer by hand is tedious and error-prone. A state machine to match all lexemes in a real language will have many states. Flex makes this process easier by automatically producing a lexical analyzer from a specification. Flex is an improved version of Lex which was originally written in the early 70's for UNIX systems. Flex is a newer, open source, program that adds support for C++.