2023-04-01 05:50:08 +01:00
|
|
|
# lex
|
|
|
|
|
|
|
|
> Lexical analyzer generator.
|
|
|
|
> Given the specification for a lexical analyzer, generates C code implementing it.
|
|
|
|
> More information: <https://manned.org/lex.1>.
|
|
|
|
|
2024-01-07 09:14:19 +00:00
|
|
|
- Generate an analyzer from a Lex file, storing it to the file `lex.yy.c`:
|
2023-04-01 05:50:08 +01:00
|
|
|
|
|
|
|
`lex {{analyzer.l}}`
|
|
|
|
|
2024-01-07 09:14:19 +00:00
|
|
|
- Write analyzer to `stdout`:
|
|
|
|
|
|
|
|
`lex -{{-stdout|t}} {{analyzer.l}}`
|
|
|
|
|
2023-04-01 05:50:08 +01:00
|
|
|
- Specify the output file:
|
|
|
|
|
|
|
|
`lex {{analyzer.l}} --outfile {{analyzer.c}}`
|
|
|
|
|
2024-01-07 09:14:19 +00:00
|
|
|
- Generate a [B]atch scanner instead of an interactive scanner:
|
|
|
|
|
|
|
|
`lex -B {{analyzer.l}}`
|
|
|
|
|
2023-04-01 05:50:08 +01:00
|
|
|
- Compile a C file generated by Lex:
|
|
|
|
|
|
|
|
`cc {{path/to/lex.yy.c}} --output {{executable}}`
|