Lex

From LQWiki
Jump to navigation Jump to search

lex is a program which generates code in the C programming language to create a lexical analyser - that is, a program which creates a program that can perform certain tasks based on matching input.

The program makes use of regular expressions to identify certain elements of the input known as tokens. Different code fragments can be assigned to be executed once a certain token is encountered in the input.

lex is often used with yacc/biSon, but they have different purposes.

flex is an open source implementation of lex.

See also