modern syntax for asgops & inits cause Donn's latest ccom rejects the old.
[unix-history] / usr / src / old / lex / lex.1
... / ...
CommitLineData
1.\" @(#)lex.1 6.2 (Berkeley) %G%
2.\"
3.TH LEX 1 ""
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
17(standard input default) contain regular expressions
18to be searched for, and actions written in C to be executed when
19expressions are found.
20.PP
21A C source program, 'lex.yy.c' is generated, to be compiled thus:
22.IP
23cc lex.yy.c \-ll
24.LP
25This program, when run, copies unrecognized portions of
26the input to the output, and executes the associated
27C action for each regular expression that is recognized.
28.PP
29The options have the following meanings.
30.TP
31.B \-t
32Place the result on the standard output instead of in file "lex.yy.c".
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
44"Faster" compilation: don't bother to pack
45the resulting tables; limited to small programs.
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\');
61[ ]+$ ;
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.
72.SH "SEE ALSO"
73yacc(1), sed(1)
74.br
75M. E. Lesk and E. Schmidt,
76.I LEX \- Lexical Analyzer Generator