2017-12-11 13:57:43 +00:00
|
|
|
# lex
|
|
|
|
|
2022-06-27 11:23:12 +01:00
|
|
|
> Lexical analyzer generator.
|
|
|
|
> Given the specification for a lexical analyzer, generates C code implementing it.
|
2024-02-05 07:04:49 +00:00
|
|
|
> Note: on most major OSes, this command is an alias for `flex`.
|
2021-09-23 19:34:23 +01:00
|
|
|
> More information: <https://manned.org/lex.1>.
|
2017-12-11 13:57:43 +00:00
|
|
|
|
2024-01-07 09:14:19 +00:00
|
|
|
- Generate an analyzer from a Lex file, storing it to the file `lex.yy.c`:
|
2017-12-11 13:57:43 +00:00
|
|
|
|
2022-06-27 11:23:12 +01:00
|
|
|
`lex {{analyzer.l}}`
|
2017-12-11 13:57:43 +00:00
|
|
|
|
2017-12-11 21:30:23 +00:00
|
|
|
- Specify the output file:
|
|
|
|
|
2023-04-01 05:50:08 +01:00
|
|
|
`lex -t {{analyzer.l}} > {{analyzer.c}}`
|
2017-12-11 21:30:23 +00:00
|
|
|
|
2017-12-28 02:16:22 +00:00
|
|
|
- Compile a C file generated by Lex:
|
2017-12-11 13:57:43 +00:00
|
|
|
|
2023-04-01 05:50:08 +01:00
|
|
|
`c99 {{path/to/lex.yy.c}} -o {{executable}}`
|