lex.1 (4094B)
1 .\" 2 .\" Sccsid @(#)lex.1 1.5 (gritter) 11/27/05 3 .\" Derived from lex(1), Unix 7th edition: 4 .\" Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. 5 .\" 6 .\" Redistribution and use in source and binary forms, with or without 7 .\" modification, are permitted provided that the following conditions 8 .\" are met: 9 .\" Redistributions of source code and documentation must retain the 10 .\" above copyright notice, this list of conditions and the following 11 .\" disclaimer. 12 .\" Redistributions in binary form must reproduce the above copyright 13 .\" notice, this list of conditions and the following disclaimer in the 14 .\" documentation and/or other materials provided with the distribution. 15 .\" All advertising materials mentioning features or use of this software 16 .\" must display the following acknowledgement: 17 .\" This product includes software developed or owned by Caldera 18 .\" International, Inc. 19 .\" Neither the name of Caldera International, Inc. nor the names of 20 .\" other contributors may be used to endorse or promote products 21 .\" derived from this software without specific prior written permission. 22 .\" 23 .\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA 24 .\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR 25 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 .\" ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE 28 .\" LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR 29 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 30 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 31 .\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 32 .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 33 .\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 34 .\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 .\" 36 .TH LEX 1 "11/27/05" "Heirloom Development Tools" "User Commands" 37 .SH NAME 38 lex \- generator of lexical analysis programs 39 .SH SYNOPSIS 40 .HP 41 .ad l 42 .nh 43 \fBlex\fR [\fB\-ctvnVew\fR] [\fB\-Q\fR(\fBy\fR|\fBn\fR)] 44 [\fB\-Y\ \fIdirectory\fR] 45 [\fIfiles\fR\ ...] 46 .br 47 .ad b 48 .SH DESCRIPTION 49 .I Lex 50 generates programs to be used in simple lexical analyis of text. 51 The input 52 .I files 53 (standard input default) 54 contain regular expressions 55 to be searched for, and actions written in C to be executed when 56 expressions are found. 57 .PP 58 A C source program, `lex.yy.c' is generated, to be compiled thus: 59 .IP 60 cc lex.yy.c \-ll 61 .LP 62 This program, when run, copies unrecognized portions of 63 the input to the output, 64 and executes the associated 65 C action for each regular expression that is recognized. 66 .PP 67 The following 68 .I lex 69 program converts upper case to lower, 70 removes blanks at the end of lines, 71 and replaces multiple blanks by single blanks. 72 .IP "" 73 .nf 74 .ta \w'[A\-Z] 'u 75 %% 76 [A\-Z] putchar(yytext[0]+\'a\'\-\'A\'); 77 [ ]+$ 78 [ ]+ putchar(\' \'); 79 .fi 80 .PP 81 The options have the following meanings. 82 .TP 83 .B \-c 84 Generate output in the `C' language. 85 This is the default. 86 .TP 87 .B \-e 88 Generates output that can handle multibyte characters, 89 with \fIyytext[]\fR being of type \fIunsigned char[]\fR. 90 This option is an extension. 91 .TP 92 .B \-n 93 Opposite of 94 .BR \-v ; 95 .B \-n 96 is default. 97 .TP 98 \fB\-Q\fR(\fBy\fR|\fBn\fR) 99 With 100 .BR \-Qy , 101 a version identification variable is put into lex.yy.c. 102 With 103 .B \-Qn 104 (the default), no such variable is generated. 105 .TP 106 .B \-t 107 Place the result on the standard output instead of in file 108 `lex.yy.c'. 109 .TP 110 .B \-v 111 Print a one-line summary of statistics of the generated analyzer. 112 .TP 113 .B \-V 114 Causes version information for 115 .I lex 116 to be printed. 117 .TP 118 .B \-w 119 Generates output that can handle multibyte characters, 120 with \fIyytext[]\fR being of type \fIwchar_t[]\fR. 121 This option is an extension. 122 .TP 123 \fB\-Y \fIdirectory\fR 124 Use `\fIdirectory\fR' to locate driver files, 125 instead of the default `/usr/ccs/lib/lex'. 126 This option is an extension. 127 .SH "SEE ALSO" 128 yacc(1) 129 .br 130 M. E. Lesk and E. Schmidt, 131 .I LEX \- Lexical Analyzer Generator