diff --git a/pages/common/flex.md b/pages/common/flex.md index 07c223952..82b618baf 100644 --- a/pages/common/flex.md +++ b/pages/common/flex.md @@ -1,17 +1,26 @@ # flex -> Lexical analyzer generator. Based on `lex`. +> Lexical analyzer generator. A rewrite of `lex` with extensions to the POSIX specification. > Given the specification for a lexical analyzer, generates C code implementing it. +> NOTE: long options don't work on OpenBSD. > More information: . -- Generate an analyzer from a flex file: +- Generate an analyzer from a flex file, storing it to the file `lex.yy.c`: -`flex {{analyzer.l}}` +`lex {{analyzer.l}}` + +- Write analyzer to `stdout`: + +`lex -{{-stdout|t}} {{analyzer.l}}` - Specify the output file: -`flex --outfile {{analyzer.c}} {{analyzer.l}}` +`lex {{analyzer.l}} -o {{analyzer.c}}` -- Compile a C file generated by flex: +- Generate a [B]atch scanner instead of an interactive scanner: + +`lex -B {{analyzer.l}}` + +- Compile a C file generated by Lex: `cc {{path/to/lex.yy.c}} --output {{executable}}` diff --git a/pages/common/lex.md b/pages/common/lex.md index 5c9e6ae53..949c912b9 100644 --- a/pages/common/lex.md +++ b/pages/common/lex.md @@ -2,9 +2,10 @@ > 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: . -- Generate an analyzer from a Lex file: +- Generate an analyzer from a Lex file, storing it to the file `lex.yy.c`: `lex {{analyzer.l}}` diff --git a/pages/linux/lex.md b/pages/linux/lex.md index cfa562194..691cfc6b9 100644 --- a/pages/linux/lex.md +++ b/pages/linux/lex.md @@ -4,14 +4,22 @@ > Given the specification for a lexical analyzer, generates C code implementing it. > More information: . -- Generate an analyzer from a Lex file: +- Generate an analyzer from a Lex file, storing it to the file `lex.yy.c`: `lex {{analyzer.l}}` +- Write analyzer to `stdout`: + +`lex -{{-stdout|t}} {{analyzer.l}}` + - Specify the output file: `lex {{analyzer.l}} --outfile {{analyzer.c}}` +- Generate a [B]atch scanner instead of an interactive scanner: + +`lex -B {{analyzer.l}}` + - Compile a C file generated by Lex: `cc {{path/to/lex.yy.c}} --output {{executable}}` diff --git a/pages/osx/lex.md b/pages/osx/lex.md deleted file mode 100644 index 8f005f4c9..000000000 --- a/pages/osx/lex.md +++ /dev/null @@ -1,17 +0,0 @@ -# lex - -> Lexical analyzer generator. -> Given the specification for a lexical analyzer, generates C code implementing it. -> More information: . - -- Generate an analyzer from a Lex file: - -`lex {{analyzer.l}}` - -- Specify the output file: - -`lex {{analyzer.l}} --outfile {{analyzer.c}}` - -- Compile a C file generated by Lex: - -`cc {{path/to/lex.yy.c}} --output {{executable}}`