BSD 4_2 development
[unix-history] / usr / man / man1 / lex.1
CommitLineData
d8649de5
C
1.TH LEX 1 "7 February 1983"
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) contain regular expressions
15to be searched for, and actions written in C to be executed when
16expressions are found.
17.PP
18A C source program, 'lex.yy.c' is generated, to be compiled thus:
19.IP
20cc lex.yy.c \-ll
21.LP
22This program, when run, copies unrecognized portions of
23the input to the output, and executes the associated
24C action for each regular expression that is recognized.
25.PP
26The options have the following meanings.
27.TP
28.B \-t
29Place the result on the standard output instead of in file "lex.yy.c".
30.TP
31.B \-v
32Print a one-line summary of statistics of the generated analyzer.
33.TP
34.B \-n
35Opposite of
36.BR \-v ;
37.B \-n
38is default.
39.TP
40.B \-f
41"Faster" compilation: don't bother to pack
42the resulting tables; limited to small programs.
43.SH EXAMPLE
44.IP
45lex lexcommands
46.PP
47would draw
48.I lex
49instructions from the file
50.I lexcommands,
51and place the output in
52.I lex.yy.c
53.IP ""
54.nf
55.ta \w'[A\-Z] 'u
56%%
57[A\-Z] putchar(yytext[0]+\'a\'\-\'A\');
58[ ]+$
59[ ]+ putchar(\' \');
60.fi
61.PP
62is an example of a
63.I lex
64program that would be put into a
65.I lex
66command file. This program converts upper case to lower,
67removes blanks at the end of lines,
68and replaces multiple blanks by single blanks.
69.SH "SEE ALSO"
70yacc(1), sed(1)
71.br
72M. E. Lesk and E. Schmidt,
73.I LEX \- Lexical Analyzer Generator