modern syntax for asgops & inits cause Donn's latest ccom rejects the old.
[unix-history] / usr / src / old / lex / lex.1
CommitLineData
0d1c5a97 1.\" @(#)lex.1 6.2 (Berkeley) %G%
74585891 2.\"
f2db4a3c 3.TH LEX 1 ""
74585891
KM
4.AT 3
5.SH NAME
6lex \- generator of lexical analysis programs
7.SH SYNOPSIS
8.B lex
9[
10.B \-tvfn
11] [ file ] ...
12.SH DESCRIPTION
13.I Lex
14generates programs to be used in simple lexical analyis of text.
15The input
16.I files
c16b12ba 17(standard input default) contain regular expressions
74585891
KM
18to be searched for, and actions written in C to be executed when
19expressions are found.
20.PP
c16b12ba 21A C source program, 'lex.yy.c' is generated, to be compiled thus:
74585891
KM
22.IP
23cc lex.yy.c \-ll
24.LP
25This program, when run, copies unrecognized portions of
c16b12ba 26the input to the output, and executes the associated
74585891
KM
27C action for each regular expression that is recognized.
28.PP
74585891
KM
29The options have the following meanings.
30.TP
31.B \-t
c16b12ba 32Place the result on the standard output instead of in file "lex.yy.c".
74585891
KM
33.TP
34.B \-v
35Print a one-line summary of statistics of the generated analyzer.
36.TP
37.B \-n
38Opposite of
39.BR \-v ;
40.B \-n
41is default.
42.TP
43.B \-f
c16b12ba 44"Faster" compilation: don't bother to pack
74585891 45the resulting tables; limited to small programs.
c16b12ba
KM
46.SH EXAMPLE
47.IP
48lex lexcommands
49.PP
50would draw
51.I lex
52instructions from the file
53.I lexcommands,
54and place the output in
55.I lex.yy.c
56.IP ""
57.nf
58.ta \w'[A\-Z] 'u
59%%
60[A\-Z] putchar(yytext[0]+\'a\'\-\'A\');
0d1c5a97 61[ ]+$ ;
c16b12ba
KM
62[ ]+ putchar(\' \');
63.fi
64.PP
65is an example of a
66.I lex
67program that would be put into a
68.I lex
69command file. This program converts upper case to lower,
70removes blanks at the end of lines,
71and replaces multiple blanks by single blanks.
74585891
KM
72.SH "SEE ALSO"
73yacc(1), sed(1)
74.br
75M. E. Lesk and E. Schmidt,
76.I LEX \- Lexical Analyzer Generator