![]() The set of descriptions you give to lex is called a lex specification. Lex helps you by taking a set of descriptions of possible tokens and producing a C routine, which we call a lexical analyzer, or a lexer, or a scanner for short, that can identify those tokens. This division into units (which are usually called tokens) is known as lexical analysis, or lexing for short. ![]() For a C program, the units are variable names, constants, strings, operators, punctuation, and so forth. For a text search program, the units would probably be lines of text, with a distinction between lines that contain a match of the target string and lines that don’t. In programs with structured input, two tasks that occur over and over are dividing the input into meaningful units, and then discovering the relationship among the units. This includes an enormous range of applications-anything from a simple text search program that looks for patterns in its input file to a C compiler that transforms a source program into optimized object code. ![]() Lex and yacc help you write programs that transform structured input.
0 Comments
Leave a Reply. |