# flex(1) - man - phpman

> **TLDR:** Lexical analyzer generator.
>
- Generate an analyzer from a Lex file, storing it to the file `lex.yy.c`:
  `flex {{analyzer.l}}`
- Write analyzer to `stdout`:
  `flex {{-t|--stdout}} {{analyzer.l}}`
- Specify the output file:
  `flex {{analyzer.l}} {{-o|--outfile}} {{analyzer.c}}`
- Generate a batch scanner instead of an interactive scanner:
  `flex {{-B|--batch}} {{analyzer.l}}`
- Compile a C file generated by Lex:
  `cc {{path/to/lex.yy.c}} -o {{executable}}`

*Source: tldr-pages*

---

[FLEX(1)](https://www.chedong.com/phpMan.php/man/FLEX/1/markdown)                                      Programming                                     [FLEX(1)](https://www.chedong.com/phpMan.php/man/FLEX/1/markdown)



## NAME
       flex - the fast lexical analyser generator

## SYNOPSIS
       **flex** [_OPTIONS_] [_FILE_]...

## DESCRIPTION
       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 -f

### -CF -F

### -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 --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
              specify output filename

### -S --skel
              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

       **--backup-file**=_FILE_
              write backing-up information 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
              #define macro defn  (default defn is '1')

### -L --noline
              suppress #line directives in scanner

### -P --prefix
              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

### -n

       -?

### -h --help
              produce this help message

### -V --version
              report flex version

## SEE ALSO
       The full documentation for **flex** is maintained as a Texinfo manual.  If the **info** and **flex** pro‐
       grams are properly installed at your site, the command

              **info** **flex**

       should give you access to the complete manual.



The Flex Project                             March 2022                                      [FLEX(1)](https://www.chedong.com/phpMan.php/man/FLEX/1/markdown)
