FLEX(1)
π NAME
flex - the fast lexical analyser generator
π Quick Reference
| Use Case | Command | Description |
| π Compile a lexer file | flex lexer.l | Generate the default C scanner lex.yy.c |
| π€ Specify output file | flex -o lexer.c lexer.l | Write scanner to lexer.c instead of the default |
| 𧬠Generate C++ scanner | flex -+ lexer.l | Create a C++ scanner class |
| π Produce header file | flex --header-file=lexer.h lexer.l | Generate a C header file alongside the scanner |
| π Debug mode | flex -d lexer.l | Enable debug output in the generated scanner |
| π€ Caseβinsensitive scanning | flex -i lexer.l | Ignore case in patterns |
| π Reentrant scanner | flex -R lexer.l | Generate a reentrant (threadβsafe) C scanner |
| π€« Suppress warnings | flex -w lexer.l | Do not generate warning messages |
π 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 π 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
- --backup-file=FILE πΎ write backingβup information to FILE
βοΈ Scanner Behavior
- -7, --7bit 7οΈβ£ generate 7βbit scanner
- -8, --8bit 8οΈβ£ 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
π 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.
FLEX(1)