BSD 3 development
[unix-history] / usr / man / man1 / lex.1
CommitLineData
e6817382
BJ
1.TH LEX 1
2.SH NAME
3lex \- generator of lexical analysis programs
4.SH SYNOPSIS
5.B lex
6[
7.B \-tvfn
8] [ file ] ...
9.SH DESCRIPTION
10.I Lex
11generates programs to be used in simple lexical analyis of text.
12The input
13.I files
14(standard input default)
15contain regular expressions
16to be searched for, and actions written in C to be executed when
17expressions are found.
18.PP
19A C source program, `lex.yy.c' is generated, to be compiled thus:
20.IP
21cc lex.yy.c \-ll
22.LP
23This program, when run, copies unrecognized portions of
24the input to the output,
25and executes the associated
26C action for each regular expression that is recognized.
27.PP
28The following
29.I lex
30program converts upper case to lower,
31removes blanks at the end of lines,
32and replaces multiple blanks by single blanks.
33.IP ""
34.nf
35.ta \w'[A\-Z] 'u
36%%
37[A\-Z] putchar(yytext[0]+\'a\'\-\'A\');
38[ ]+$
39[ ]+ putchar(\' \');
40.fi
41.PP
42The options have the following meanings.
43.TP
44.B \-t
45Place the result on the standard output instead of in file
46`lex.yy.c'.
47.TP
48.B \-v
49Print a one-line summary of statistics of the generated analyzer.
50.TP
51.B \-n
52Opposite of
53.BR \-v ;
54.B \-n
55is default.
56.TP
57.B \-f
58`Faster' compilation: don't bother to pack
59the resulting tables; limited to small programs.
60.SH "SEE ALSO"
61yacc(1)
62.br
63M. E. Lesk and E. Schmidt,
64.I LEX \- Lexical Analyzer Generator