2017-12-30 16:16:30 +00:00
|
|
|
# flex
|
|
|
|
|
2024-01-07 09:14:19 +00:00
|
|
|
> Lexical analyzer generator. A rewrite of `lex` with extensions to the POSIX specification.
|
2022-06-27 11:23:12 +01:00
|
|
|
> Given the specification for a lexical analyzer, generates C code implementing it.
|
2024-01-07 09:14:19 +00:00
|
|
|
> NOTE: long options don't work on OpenBSD.
|
2021-04-17 16:15:37 +01:00
|
|
|
> More information: <https://manned.org/flex>.
|
2017-12-30 16:16:30 +00:00
|
|
|
|
2024-01-07 09:14:19 +00:00
|
|
|
- Generate an analyzer from a flex file, storing it to the file `lex.yy.c`:
|
2017-12-30 16:16:30 +00:00
|
|
|
|
2024-01-07 09:14:19 +00:00
|
|
|
`lex {{analyzer.l}}`
|
|
|
|
|
|
|
|
- Write analyzer to `stdout`:
|
|
|
|
|
|
|
|
`lex -{{-stdout|t}} {{analyzer.l}}`
|
2017-12-30 16:16:30 +00:00
|
|
|
|
|
|
|
- Specify the output file:
|
|
|
|
|
2024-01-07 09:14:19 +00:00
|
|
|
`lex {{analyzer.l}} -o {{analyzer.c}}`
|
|
|
|
|
|
|
|
- Generate a [B]atch scanner instead of an interactive scanner:
|
|
|
|
|
|
|
|
`lex -B {{analyzer.l}}`
|
2017-12-30 16:16:30 +00:00
|
|
|
|
2024-01-07 09:14:19 +00:00
|
|
|
- Compile a C file generated by Lex:
|
2017-12-30 16:16:30 +00:00
|
|
|
|
|
|
|
`cc {{path/to/lex.yy.c}} --output {{executable}}`
|