1LEX(1) General Commands Manual LEX(1)
2
3
4
6 lex - generator of lexical analysis programs
7
9 lex [ -tvfn ] [ file ] ...
10
12 Lex generates programs to be used in simple lexical analyis of text.
13 The input files (standard input default) contain regular expressions to
14 be searched for, and actions written in C to be executed when expres‐
15 sions are found.
16
17 A C source program, `lex.yy.c' is generated, to be compiled thus:
18
19 cc lex.yy.c -ll
20
21 This program, when run, copies unrecognized portions of the input to
22 the output, and executes the associated C action for each regular
23 expression that is recognized.
24
25 The following lex program converts upper case to lower, removes blanks
26 at the end of lines, and replaces multiple blanks by single blanks.
27
28
29 %%
30 [A-Z] putchar(yytext[0]+´a´-´A´);
31 [ ]+$
32 [ ]+ putchar(´ ´);
33
34 The options have the following meanings.
35
36 -t Place the result on the standard output instead of in file
37 `lex.yy.c'.
38
39 -v Print a one-line summary of statistics of the generated ana‐
40 lyzer.
41
42 -n Opposite of -v; -n is default.
43
44 -f `Faster' compilation: don't bother to pack the resulting tables;
45 limited to small programs.
46
48 yacc(1)
49 M. E. Lesk and E. Schmidt, LEX - Lexical Analyzer Generator
50
51
52
53 LEX(1)