{
    "mode": "man",
    "parameter": "lex",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/lex/1/json",
    "generated": "2026-06-02T20:22:21Z",
    "synopsis": "flex [OPTIONS] [FILE]...",
    "sections": {
        "NAME": {
            "content": "flex - the fast lexical analyser generator\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "flex [OPTIONS] [FILE]...\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Generates programs that perform pattern-matching on text.\n",
            "subsections": [
                {
                    "name": "Table Compression:",
                    "content": ""
                },
                {
                    "name": "-Ca --align",
                    "content": "trade off larger tables for better memory alignment\n",
                    "long": "--align"
                },
                {
                    "name": "-Ce --ecs",
                    "content": "construct equivalence classes\n",
                    "long": "--ecs"
                },
                {
                    "name": "-Cf -f",
                    "content": "",
                    "flag": "-f"
                },
                {
                    "name": "-CF -F",
                    "content": "",
                    "flag": "-F"
                },
                {
                    "name": "-Cm --meta-ecs",
                    "content": "construct meta-equivalence classes\n",
                    "long": "--meta-ecs"
                },
                {
                    "name": "-Cr --read",
                    "content": "use read() instead of stdio for scanner input\n",
                    "long": "--read"
                },
                {
                    "name": "-f --full",
                    "content": "generate fast, large scanner. Same as -Cfr\n",
                    "flag": "-f",
                    "long": "--full"
                },
                {
                    "name": "-F --fast",
                    "content": "use alternate table representation. Same as -CFr\n",
                    "flag": "-F",
                    "long": "--fast"
                },
                {
                    "name": "-Cem --ecs --meta-ecs",
                    "content": "",
                    "long": "--meta-ecs"
                },
                {
                    "name": "Debugging:",
                    "content": ""
                },
                {
                    "name": "-d --debug",
                    "content": "enable debug mode in scanner\n",
                    "flag": "-d",
                    "long": "--debug"
                },
                {
                    "name": "-b --backup",
                    "content": "write backing-up information to lex.backup\n",
                    "flag": "-b",
                    "long": "--backup"
                },
                {
                    "name": "-p --perf-report",
                    "content": "write performance report to stderr\n",
                    "flag": "-p",
                    "long": "--perf-report"
                },
                {
                    "name": "-s --nodefault",
                    "content": "suppress default rule to ECHO unmatched text\n",
                    "flag": "-s",
                    "long": "--nodefault"
                },
                {
                    "name": "-T --trace",
                    "content": "flex should run in trace mode\n",
                    "flag": "-T",
                    "long": "--trace"
                },
                {
                    "name": "-w --nowarn",
                    "content": "do not generate warnings\n",
                    "flag": "-w",
                    "long": "--nowarn"
                },
                {
                    "name": "-v --verbose",
                    "content": "write summary of scanner statistics to stdout\n\n--hex  use hexadecimal numbers instead of octal in debug outputs\n",
                    "flag": "-v",
                    "long": "--verbose"
                }
            ]
        },
        "FILES": {
            "content": "",
            "subsections": [
                {
                    "name": "-o --outfile",
                    "content": "specify output filename\n",
                    "flag": "-o",
                    "long": "--outfile"
                },
                {
                    "name": "-S --skel",
                    "content": "specify skeleton file\n",
                    "flag": "-S",
                    "long": "--skel"
                },
                {
                    "name": "-t --stdout",
                    "content": "write scanner on stdout instead of lex.yy.c\n\n--yyclass=NAME\nname of C++ class\n\n--header-file=FILE\ncreate a C header file in addition to the scanner\n\n--tables-file[=FILE] write tables to FILE\n\n--backup-file=FILE\nwrite backing-up information to FILE\n",
                    "flag": "-t",
                    "long": "--stdout"
                },
                {
                    "name": "Scanner behavior:",
                    "content": ""
                },
                {
                    "name": "-7 --7bit",
                    "content": "generate 7-bit scanner\n",
                    "flag": "-7",
                    "long": "--7bit"
                },
                {
                    "name": "-8 --8bit",
                    "content": "generate 8-bit scanner\n",
                    "flag": "-8",
                    "long": "--8bit"
                },
                {
                    "name": "-B --batch",
                    "content": "generate batch scanner (opposite of -I)\n",
                    "flag": "-B",
                    "long": "--batch"
                },
                {
                    "name": "-i --case-insensitive",
                    "content": "ignore case in patterns\n",
                    "flag": "-i",
                    "long": "--case-insensitive"
                },
                {
                    "name": "-l --lex-compat",
                    "content": "maximal compatibility with original lex\n",
                    "flag": "-l",
                    "long": "--lex-compat"
                },
                {
                    "name": "-X --posix-compat",
                    "content": "maximal compatibility with POSIX lex\n",
                    "flag": "-X",
                    "long": "--posix-compat"
                },
                {
                    "name": "-I --interactive",
                    "content": "generate interactive scanner (opposite of -B)\n",
                    "flag": "-I",
                    "long": "--interactive"
                },
                {
                    "name": "--yylineno",
                    "content": "track line count in yylineno\n",
                    "long": "--yylineno"
                },
                {
                    "name": "Generated code:",
                    "content": "-+,  --c++\ngenerate C++ scanner class\n"
                },
                {
                    "name": "-Dmacro",
                    "content": "#define macro defn  (default defn is '1')\n"
                },
                {
                    "name": "-L --noline",
                    "content": "suppress #line directives in scanner\n",
                    "flag": "-L",
                    "long": "--noline"
                },
                {
                    "name": "-P --prefix",
                    "content": "use STRING as prefix instead of \"yy\"\n",
                    "flag": "-P",
                    "long": "--prefix"
                },
                {
                    "name": "-R --reentrant",
                    "content": "generate a reentrant C scanner\n",
                    "flag": "-R",
                    "long": "--reentrant"
                },
                {
                    "name": "--bison-bridge",
                    "content": "scanner for bison pure parser.\n",
                    "long": "--bison-bridge"
                },
                {
                    "name": "--bison-locations",
                    "content": "include yylloc support.\n",
                    "long": "--bison-locations"
                },
                {
                    "name": "--stdinit",
                    "content": "initialize yyin/yyout to stdin/stdout\n",
                    "long": "--stdinit"
                },
                {
                    "name": "--nounistd",
                    "content": "do not include <unistd.h>\n",
                    "long": "--nounistd"
                },
                {
                    "name": "--noFUNCTION",
                    "content": "do not generate a particular FUNCTION\n",
                    "long": "--noFUNCTION"
                },
                {
                    "name": "Miscellaneous:",
                    "content": ""
                },
                {
                    "name": "-c",
                    "content": "",
                    "flag": "-c"
                },
                {
                    "name": "-n",
                    "content": "-?\n",
                    "flag": "-n"
                },
                {
                    "name": "-h --help",
                    "content": "produce this help message\n",
                    "flag": "-h",
                    "long": "--help"
                },
                {
                    "name": "-V --version",
                    "content": "report flex version\n",
                    "flag": "-V",
                    "long": "--version"
                }
            ]
        },
        "SEE ALSO": {
            "content": "The full documentation for flex is maintained as a Texinfo manual.  If the info and flex pro‐\ngrams are properly installed at your site, the command\n\ninfo flex\n\nshould give you access to the complete manual.\n\n\n\nThe Flex Project                             March 2022                                      FLEX(1)",
            "subsections": []
        }
    },
    "summary": "flex - the fast lexical analyser generator",
    "flags": [
        {
            "flag": "",
            "long": "--align",
            "arg": null,
            "description": "trade off larger tables for better memory alignment"
        },
        {
            "flag": "",
            "long": "--ecs",
            "arg": null,
            "description": "construct equivalence classes"
        },
        {
            "flag": "-f",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "-F",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--meta-ecs",
            "arg": null,
            "description": "construct meta-equivalence classes"
        },
        {
            "flag": "",
            "long": "--read",
            "arg": null,
            "description": "use read() instead of stdio for scanner input"
        },
        {
            "flag": "-f",
            "long": "--full",
            "arg": null,
            "description": "generate fast, large scanner. Same as -Cfr"
        },
        {
            "flag": "-F",
            "long": "--fast",
            "arg": null,
            "description": "use alternate table representation. Same as -CFr"
        },
        {
            "flag": "",
            "long": "--meta-ecs",
            "arg": null,
            "description": ""
        },
        {
            "flag": "-d",
            "long": "--debug",
            "arg": null,
            "description": "enable debug mode in scanner"
        },
        {
            "flag": "-b",
            "long": "--backup",
            "arg": null,
            "description": "write backing-up information to lex.backup"
        },
        {
            "flag": "-p",
            "long": "--perf-report",
            "arg": null,
            "description": "write performance report to stderr"
        },
        {
            "flag": "-s",
            "long": "--nodefault",
            "arg": null,
            "description": "suppress default rule to ECHO unmatched text"
        },
        {
            "flag": "-T",
            "long": "--trace",
            "arg": null,
            "description": "flex should run in trace mode"
        },
        {
            "flag": "-w",
            "long": "--nowarn",
            "arg": null,
            "description": "do not generate warnings"
        },
        {
            "flag": "-v",
            "long": "--verbose",
            "arg": null,
            "description": "write summary of scanner statistics to stdout --hex use hexadecimal numbers instead of octal in debug outputs"
        }
    ],
    "examples": [],
    "see_also": [],
    "tldr": {
        "source": "official",
        "description": "Lexical analyzer generator.",
        "examples": [
            {
                "description": "Generate an analyzer from a Lex file, storing it to the file `lex.yy.c`",
                "command": "lex {{analyzer.l}}"
            },
            {
                "description": "Specify the output file",
                "command": "lex -t {{analyzer.l}} > {{analyzer.c}}"
            },
            {
                "description": "Compile a C file generated by Lex",
                "command": "c99 {{path/to/lex.yy.c}} -o {{executable}}"
            }
        ]
    }
}