FLEX(1) Programming FLEX(1)

# [NAME](#NAME)

flex - the fast lexical analyser generator

# [SYNOPSIS](#SYNOPSIS)

**flex** \[*OPTIONS*] \[*FILE*]...

# [DESCRIPTION](#DESCRIPTION)

Generates programs that perform pattern-matching on text.

## [Table Compression:](#Table_Compression:)

[**-Ca**, **--align**](#Ca)

trade off larger tables for better memory alignment

[**-Ce**, **--ecs**](#Ce)

construct equivalence classes

[**-Cf**](#Cf)

do not compress tables; use **-f** representation

[**-CF**](#CF)

do not compress tables; use **-F** representation

[**-Cm**, **--meta-ecs**](#Cm)

construct meta-equivalence classes

[**-Cr**, **--read**](#Cr)

use read() instead of stdio for scanner input

[**-f**, **--full**](#f)

generate fast, large scanner. Same as **-Cfr**

[**-F**, **--fast**](#F)

use alternate table representation. Same as **-CFr**

[**-Cem**](#Cem)

default compression (same as **--ecs** **--meta-ecs**)

## [Debugging:](#Debugging:)

[**-d**, **--debug**](#d)

enable debug mode in scanner

[**-b**, **--backup**](#b)

write backing-up information to lex.backup

[**-p**, **--perf-report**](#p)

write performance report to stderr

[**-s**, **--nodefault**](#s)

suppress default rule to ECHO unmatched text

[**-T**, **--trace**](#T)

flex should run in trace mode

[**-w**, **--nowarn**](#w)

do not generate warnings

[**-v**, **--verbose**](#v)

write summary of scanner statistics to stdout

[**--hex**](#hex)

use hexadecimal numbers instead of octal in debug outputs

# [FILES](#FILES)

[**-o**, **--outfile**=*FILE*](#o)

specify output filename

[**-S**, **--skel**=*FILE*](#S)

specify skeleton file

[**-t**, **--stdout**](#t)

write scanner on stdout instead of lex.yy.c

[**--yyclass**=*NAME*](#yyclass)

name of C++ class

[**--header-file**=*FILE*](#header)

create a C header file in addition to the scanner

**--tables-file**\[=*FILE*] write tables to FILE

## [Scanner behavior:](#Scanner_behavior:)

**-7**, **--7bit**

generate 7-bit scanner

**-8**, **--8bit**

generate 8-bit scanner

[**-B**, **--batch**](#B)

generate batch scanner (opposite of **-I**)

[**-i**, **--case-insensitive**](#i)

ignore case in patterns

[**-l**, **--lex-compat**](#l)

maximal compatibility with original lex

[**-X**, **--posix-compat**](#X)

maximal compatibility with POSIX lex

[**-I**, **--interactive**](#I)

generate interactive scanner (opposite of **-B**)

[**--yylineno**](#yylineno)

track line count in yylineno

## [Generated code:](#Generated_code:)

-+, **--c**++

generate C++ scanner class

[**-Dmacro**\[=*defn*\]](#Dmacro)

#define macro defn (default defn is '1')

[**-L**, **--noline**](#L)

suppress #line directives in scanner

[**-P**, **--prefix**=*STRING*](#P)

use STRING as prefix instead of "yy"

[**-R**, **--reentrant**](#R)

generate a reentrant C scanner

[**--bison-bridge**](#bison)

scanner for bison pure parser.

[**--bison-locations**](#bison~2)

include yylloc support.

[**--stdinit**](#stdinit)

initialize yyin/yyout to stdin/stdout

[**--nounistd**](#nounistd)

do not include &lt;unistd.h&gt;

[**--noFUNCTION**](#noFUNCTION)

do not generate a particular FUNCTION

## [Miscellaneous:](#Miscellaneous:)

[**-c**](#c)

do-nothing POSIX option

[**-n**](#n)

do-nothing POSIX option

-?

[**-h**, **--help**](#h)

produce this help message

[**-V**, **--version**](#V)

report flex version

# [SEE ALSO](#SEE_ALSO)

The full documentation for **flex** is maintained as a Texinfo manual. If the **info** and **flex** programs are properly installed at your site, the command

**info flex**

should give you access to the complete manual.

November 2026 The Flex Project

---

Document: flex(1) from flex 2.6.4-r16 (Chainguard OS)
Source: https://github.com/westes/flex
