tldr/pages/common/lex.md

19 lines
486 B
Markdown
Raw Normal View History

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.
> Note: on most major OSes, this command is an alias for `flex`.
> More information: <https://manned.org/lex.1>.
2017-12-11 13:57:43 +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:
`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
`c99 {{path/to/lex.yy.c}} -o {{executable}}`