BSD 4_3_Tahoe development
[unix-history] / usr / man / cat1 / lex.0
LEX(1) UNIX Programmer's Manual LEX(1)
N\bNA\bAM\bME\bE
lex - generator of lexical analysis programs
S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
l\ble\bex\bx [ -\b-t\btv\bvf\bfn\bn ] [ file ] ...
D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
_\bL_\be_\bx generates programs to be used in simple lexical analyis
of text. The input _\bf_\bi_\bl_\be_\bs (standard input default) contain
regular expressions to be searched for, and actions written
in C to be executed when expressions are found.
A C source program, 'lex.yy.c' is generated, to be compiled
thus:
cc lex.yy.c -ll
This program, when run, copies unrecognized portions of the
input to the output, and executes the associated C action
for each regular expression that is recognized.
The options have the following meanings.
-\b-t\bt Place the result on the standard output instead of in
file "lex.yy.c".
-\b-v\bv Print a one-line summary of statistics of the generated
analyzer.
-\b-n\bn Opposite of -\b-v\bv; -\b-n\bn is default.
-\b-f\bf "Faster" compilation: don't bother to pack the result-
ing tables; limited to small programs.
E\bEX\bXA\bAM\bMP\bPL\bLE\bE
lex lexcommands
would draw _\bl_\be_\bx instructions from the file _\bl_\be_\bx_\bc_\bo_\bm_\bm_\ba_\bn_\bd_\bs, and
place the output in _\bl_\be_\bx._\by_\by._\bc
%%
[A-Z] putchar(yytext[0]+'a'-'A');
[ ]+$ ;
[ ]+ putchar(' ');
is an example of a _\bl_\be_\bx program that would be put into a _\bl_\be_\bx
command file. This program converts upper case to lower,
removes blanks at the end of lines, and replaces multiple
blanks by single blanks.
Printed 7/9/88 April 14, 1986 1
LEX(1) UNIX Programmer's Manual LEX(1)
S\bSE\bEE\bE A\bAL\bLS\bSO\bO
yacc(1), sed(1)
M. E. Lesk and E. Schmidt, _\bL_\bE_\bX - _\bL_\be_\bx_\bi_\bc_\ba_\bl _\bA_\bn_\ba_\bl_\by_\bz_\be_\br _\bG_\be_\bn_\be_\br_\ba_\bt_\bo_\br
Printed 7/9/88 April 14, 1986 2