Name

lex

Synopsis

    lex [options] [files]

Generate a lexical analysis program (named lex.yy.c) based on the regular expressions and C statements contained in one or more input files. On GNU/Linux and Mac OS X, lex is actually flex. See also yacc, bison, flex, and lex & yacc, which is listed in the Bibliography.

Options

The -e and -w options may not be available on other Unix systems where lex is the original Unix version.

-c

file’s program statements are in C (default).

-e

Handle EUC (Extended Unix Code, i.e., eight-bit) characters. Mutually exclusive with -w. This gives yytext[] type unsigned char.

-n

Suppress the output summary.

-Q c

Print version information in lex.yy.c (if c = y) or suppress information (if c = n, the default).

-t

Write program to standard output, not lex.yy.c.

-v

Print a summary of machine-generated statistics.

-V

Print version information on standard error.

-w

Handle EUC (eight-bit or wider) characters. Mutually exclusive with -e. This gives yytext[] type wchar_t.

Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.