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 options have the following meanings.
26
27 -t Place the result on the standard output instead of in file
28 "lex.yy.c".
29
30 -v Print a one-line summary of statistics of the generated ana‐
31 lyzer.
32
33 -n Opposite of -v; -n is default.
34
35 -f "Faster" compilation: don't bother to pack the resulting tables;
36 limited to small programs.
37
39 lex lexcommands
40
41 would draw lex instructions from the file lexcommands, and place the
42 output in lex.yy.c
43
44
45 %%
46 [A-Z] putchar(yytext[0]+´a´-´A´);
47 [ ]+$ ;
48 [ ]+ putchar(´ ´);
49
50 is an example of a lex program that would be put into a lex command
51 file. This program converts upper case to lower, removes blanks at the
52 end of lines, and replaces multiple blanks by single blanks.
53
55 yacc(1), sed(1)
56 M. E. Lesk and E. Schmidt, LEX - Lexical Analyzer Generator
57
58
59
607th Edition April 14, 1986 LEX(1)