BSD 4_3_Tahoe development
[unix-history] / usr / man / cat1 / lex.0
CommitLineData
362b077f
C
1
2
3
4LEX(1) UNIX Programmer's Manual LEX(1)
5
6
7
8N\bNA\bAM\bME\bE
9 lex - generator of lexical analysis programs
10
11S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
12 l\ble\bex\bx [ -\b-t\btv\bvf\bfn\bn ] [ file ] ...
13
14D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
15 _\bL_\be_\bx generates programs to be used in simple lexical analyis
16 of text. The input _\bf_\bi_\bl_\be_\bs (standard input default) contain
17 regular expressions to be searched for, and actions written
18 in C to be executed when expressions are found.
19
20 A C source program, 'lex.yy.c' is generated, to be compiled
21 thus:
22
23 cc lex.yy.c -ll
24
25 This program, when run, copies unrecognized portions of the
26 input to the output, and executes the associated C action
27 for each regular expression that is recognized.
28
29 The options have the following meanings.
30
31 -\b-t\bt Place the result on the standard output instead of in
32 file "lex.yy.c".
33
34 -\b-v\bv Print a one-line summary of statistics of the generated
35 analyzer.
36
37 -\b-n\bn Opposite of -\b-v\bv; -\b-n\bn is default.
38
39 -\b-f\bf "Faster" compilation: don't bother to pack the result-
40 ing tables; limited to small programs.
41
42E\bEX\bXA\bAM\bMP\bPL\bLE\bE
43 lex lexcommands
44
45 would draw _\bl_\be_\bx instructions from the file _\bl_\be_\bx_\bc_\bo_\bm_\bm_\ba_\bn_\bd_\bs, and
46 place the output in _\bl_\be_\bx._\by_\by._\bc
47
48
49 %%
50 [A-Z] putchar(yytext[0]+'a'-'A');
51 [ ]+$ ;
52 [ ]+ putchar(' ');
53
54 is an example of a _\bl_\be_\bx program that would be put into a _\bl_\be_\bx
55 command file. This program converts upper case to lower,
56 removes blanks at the end of lines, and replaces multiple
57 blanks by single blanks.
58
59
60
61
62
63Printed 7/9/88 April 14, 1986 1
64
65
66
67
68
69
70LEX(1) UNIX Programmer's Manual LEX(1)
71
72
73
74S\bSE\bEE\bE A\bAL\bLS\bSO\bO
75 yacc(1), sed(1)
76 M. E. Lesk and E. Schmidt, _\bL_\bE_\bX - _\bL_\be_\bx_\bi_\bc_\ba_\bl _\bA_\bn_\ba_\bl_\by_\bz_\be_\br _\bG_\be_\bn_\be_\br_\ba_\bt_\bo_\br
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129Printed 7/9/88 April 14, 1986 2
130
131
132