HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

flex — Lexical analyzer generator. Given the specification for a lexical analyzer, generates C code impleme

Submitted by: @import:tldr-pages··
0
Viewed 0 times
thegivencommandgeneratorlexicalflexclianalyzer
linux

Problem

How to use the flex command: Lexical analyzer generator. Given the specification for a lexical analyzer, generates C code implementing it. More information: <https://manned.org/flex>.

Solution

flex — Lexical analyzer generator. Given the specification for a lexical analyzer, generates C code implementing it. More information: <https://manned.org/flex>.

Generate an analyzer from a Lex file, storing it to the file lex.yy.c:
flex {{analyzer.l}}


Write analyzer to stdout:
flex {{[-t|--stdout]}} {{analyzer.l}}


Specify the output file:
flex {{analyzer.l}} {{[-o|--outfile]}} {{analyzer.c}}


Generate a batch scanner instead of an interactive scanner:
flex {{[-B|--batch]}} {{analyzer.l}}


Compile a C file generated by Lex:
cc {{path/to/lex.yy.c}} -o {{executable}}

Code Snippets

Generate an analyzer from a Lex file, storing it to the file `lex.yy.c`

flex {{analyzer.l}}

Write analyzer to `stdout`

flex {{[-t|--stdout]}} {{analyzer.l}}

Specify the output file

flex {{analyzer.l}} {{[-o|--outfile]}} {{analyzer.c}}

Generate a batch scanner instead of an interactive scanner

flex {{[-B|--batch]}} {{analyzer.l}}

Compile a C file generated by Lex

cc {{path/to/lex.yy.c}} -o {{executable}}

Context

tldr-pages: linux/flex

Revisions (0)

No revisions yet.