mirror of https://github.com/CrimsonTome/tldr.git
27 lines
690 B
Markdown
27 lines
690 B
Markdown
# flex
|
|
|
|
> Lexical analyzer generator. A rewrite of `lex` with extensions to the POSIX specification.
|
|
> Given the specification for a lexical analyzer, generates C code implementing it.
|
|
> NOTE: long options don't work on OpenBSD.
|
|
> More information: <https://manned.org/flex>.
|
|
|
|
- Generate an analyzer from a flex file, storing it to the file `lex.yy.c`:
|
|
|
|
`lex {{analyzer.l}}`
|
|
|
|
- Write analyzer to `stdout`:
|
|
|
|
`lex -{{-stdout|t}} {{analyzer.l}}`
|
|
|
|
- Specify the output file:
|
|
|
|
`lex {{analyzer.l}} -o {{analyzer.c}}`
|
|
|
|
- Generate a [B]atch scanner instead of an interactive scanner:
|
|
|
|
`lex -B {{analyzer.l}}`
|
|
|
|
- Compile a C file generated by Lex:
|
|
|
|
`cc {{path/to/lex.yy.c}} --output {{executable}}`
|