Commit | Line | Data |
---|---|---|
d8649de5 C |
1 | .TH LEX 1 "7 February 1983" |
2 | .SH NAME | |
3 | lex \- generator of lexical analysis programs | |
4 | .SH SYNOPSIS | |
5 | .B lex | |
6 | [ | |
7 | .B \-tvfn | |
8 | ] [ file ] ... | |
9 | .SH DESCRIPTION | |
10 | .I Lex | |
11 | generates programs to be used in simple lexical analyis of text. | |
12 | The input | |
13 | .I files | |
14 | (standard input default) contain regular expressions | |
15 | to be searched for, and actions written in C to be executed when | |
16 | expressions are found. | |
17 | .PP | |
18 | A C source program, 'lex.yy.c' is generated, to be compiled thus: | |
19 | .IP | |
20 | cc lex.yy.c \-ll | |
21 | .LP | |
22 | This program, when run, copies unrecognized portions of | |
23 | the input to the output, and executes the associated | |
24 | C action for each regular expression that is recognized. | |
25 | .PP | |
26 | The options have the following meanings. | |
27 | .TP | |
28 | .B \-t | |
29 | Place the result on the standard output instead of in file "lex.yy.c". | |
30 | .TP | |
31 | .B \-v | |
32 | Print a one-line summary of statistics of the generated analyzer. | |
33 | .TP | |
34 | .B \-n | |
35 | Opposite of | |
36 | .BR \-v ; | |
37 | .B \-n | |
38 | is default. | |
39 | .TP | |
40 | .B \-f | |
41 | "Faster" compilation: don't bother to pack | |
42 | the resulting tables; limited to small programs. | |
43 | .SH EXAMPLE | |
44 | .IP | |
45 | lex lexcommands | |
46 | .PP | |
47 | would draw | |
48 | .I lex | |
49 | instructions from the file | |
50 | .I lexcommands, | |
51 | and 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 | |
62 | is an example of a | |
63 | .I lex | |
64 | program that would be put into a | |
65 | .I lex | |
66 | command file. This program converts upper case to lower, | |
67 | removes blanks at the end of lines, | |
68 | and replaces multiple blanks by single blanks. | |
69 | .SH "SEE ALSO" | |
70 | yacc(1), sed(1) | |
71 | .br | |
72 | M. E. Lesk and E. Schmidt, | |
73 | .I LEX \- Lexical Analyzer Generator |