OS Manuals

/usr/bin/flex

tool for generating text-scanning programs

From flex 2.6.4-r16 (os), captured 2026-11-05 by running flex --help (exit 0). permalink

Usage: flex [OPTIONS] [FILE]...
Generates programs that perform pattern-matching on text.

Table Compression:
  -Ca, --align      trade off larger tables for better memory alignment
  -Ce, --ecs        construct equivalence classes
  -Cf               do not compress tables; use -f representation
  -CF               do not compress tables; use -F representation
  -Cm, --meta-ecs   construct meta-equivalence classes
  -Cr, --read       use read() instead of stdio for scanner input
  -f, --full        generate fast, large scanner. Same as -Cfr
  -F, --fast        use alternate table representation. Same as -CFr
  -Cem              default compression (same as --ecs --meta-ecs)

Debugging:
  -d, --debug             enable debug mode in scanner
  -b, --backup            write backing-up information to lex.backup
  -p, --perf-report       write performance report to stderr
  -s, --nodefault         suppress default rule to ECHO unmatched text
  -T, --trace             flex should run in trace mode
  -w, --nowarn            do not generate warnings
  -v, --verbose           write summary of scanner statistics to stdout
      --hex               use hexadecimal numbers instead of octal in debug outputs

Files:
  -o, --outfile=FILE      specify output filename
  -S, --skel=FILE         specify skeleton file
  -t, --stdout            write scanner on stdout instead of lex.yy.c
      --yyclass=NAME      name of C++ class
      --header-file=FILE   create a C header file in addition to the scanner
      --tables-file[=FILE] write tables to FILE

Scanner behavior:
  -7, --7bit              generate 7-bit scanner
  -8, --8bit              generate 8-bit scanner
  -B, --batch             generate batch scanner (opposite of -I)
  -i, --case-insensitive  ignore case in patterns
  -l, --lex-compat        maximal compatibility with original lex
  -X, --posix-compat      maximal compatibility with POSIX lex
  -I, --interactive       generate interactive scanner (opposite of -B)
      --yylineno          track line count in yylineno

Generated code:
  -+,  --c++               generate C++ scanner class
  -Dmacro[=defn]           #define macro defn  (default defn is '1')
  -L,  --noline            suppress #line directives in scanner
  -P,  --prefix=STRING     use STRING as prefix instead of "yy"
  -R,  --reentrant         generate a reentrant C scanner
       --bison-bridge      scanner for bison pure parser.
       --bison-locations   include yylloc support.
       --stdinit           initialize yyin/yyout to stdin/stdout
       --nounistd          do not include <unistd.h>
       --noFUNCTION        do not generate a particular FUNCTION

Miscellaneous:
  -c                      do-nothing POSIX option
  -n                      do-nothing POSIX option
  -?
  -h, --help              produce this help message
  -V, --version           report flex version
Options (44)
OptionDescriptionSource
-Ca, --aligntrade off larger tables for better memory alignmenthelp + man
-Ce, --ecsconstruct equivalence classeshelp + man
-Cfdo not compress tables;help + man
-CFdo not compress tables;help + man
-Cm, --meta-ecsconstruct meta-equivalence classeshelp + man
-Cr, --readuse read() instead of stdio for scanner inputhelp + man
-f, --fullgenerate fast, large scanner.help + man
-F, --fastuse alternate table representation.help + man
-Cemdefault compression (same as --ecs --meta-ecs)help + man
-d, --debugenable debug mode in scannerhelp + man
-b, --backupwrite backing-up information to lex.backuphelp + man
-p, --perf-reportwrite performance report to stderrhelp + man
-s, --nodefaultsuppress default rule to ECHO unmatched texthelp + man
-T, --traceflex should run in trace modehelp + man
-w, --nowarndo not generate warningshelp + man
-v, --verbosewrite summary of scanner statistics to stdouthelp + man
--hexuse hexadecimal numbers instead of octal in debug outputshelp + man
-o, --outfile FILEspecify output filenamehelp
-S, --skel FILEspecify skeleton filehelp
-t, --stdoutwrite scanner on stdout instead of lex.yy.chelp
--yyclass NAMEname of C++ classhelp
--header-file FILEcreate a C header file in addition to the scannerhelp
-7, --7bitgenerate 7-bit scannerhelp
-8, --8bitgenerate 8-bit scannerhelp
-B, --batchgenerate batch scanner (opposite of -I)help
-i, --case-insensitiveignore case in patternshelp
-l, --lex-compatmaximal compatibility with original lexhelp
-X, --posix-compatmaximal compatibility with POSIX lexhelp
-I, --interactivegenerate interactive scanner (opposite of -B)help
--yylinenotrack line count in yylinenohelp
-Dmacro defn#define macro defn (default defn is '1')help
-L--noline suppress #line directives in scannerhelp
-P--prefix=STRING use STRING as prefix instead of "yy"help
-R--reentrant generate a reentrant C scannerhelp
--bison-bridgescanner for bison pure parser.help
--bison-locationsinclude yylloc support.help
--stdinitinitialize yyin/yyout to stdin/stdouthelp
--nounistddo not include <unistd.h>help
--noFUNCTIONdo not generate a particular FUNCTIONhelp
-cdo-nothing POSIX optionhelp
-ndo-nothing POSIX optionhelp
-?help
-h, --helpproduce this help messagehelp
-V, --versionreport flex versionhelp

Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.