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