Scroll to navigation

REFLEX(1) User Commands REFLEX(1)

NAME

reflex -- regex-centric, fast and flexible lexical analyzer generator

SYNOPSIS

reflex [OPTIONS] [FILE]

DESCRIPTION

Generates C++ source code programs that perform pattern-matching on text. FILE is a lexer specification source file, usually with extension .l. Generates lex.yy.cpp unless option -o specifies otherwise.

OPTIONS

Scanner:


-+, --flex
generate Flex-compatible C++ scanner
dot in patterns match newline
generate scanner for batch input by buffering the entire input
generate full scanner with FSM opcode tables
generate fast scanner with FSM code
ignore case in patterns
generate interactive scanner
match with boost, boost_perl, pcre2_perl, reflex, std_ecma, ...
use custom pattern class NAME for custom matcher option -m
include header FILE.h for custom matcher option -m
generate search engine to find matches, ignores unmatched input
set default tab size to N (1,2,4,8) for indent/dedent matching
match Unicode . (dot), \p, \s, \w, etc and group UTF-8 bytes
ignore space in patterns

Generated files:

specify output FILE instead of lex.yy.cpp
write scanner on stdout instead of lex.yy.cpp
write the scanner's DFA in Graphviz format to FILE.gv
write a C++ header FILE in addition to the scanner
write the scanner's regular expression patterns to FILE.txt
write the scanner's FSM opcode tables or FSM code to FILE.cpp

Generated code:

use C++ namespace NAME for the generated scanner class, with multiple namespaces specified as NAME1.NAME2.NAME3 ...
use lexer class NAME instead of Lexer or yyFlexLexer
use lex function NAME instead of lex or yylex
declare a user-defined scanner class NAME
generate Flex-compatible scanner with user-defined class NAME
generate main() to invoke lex() or yylex() once
suppress #line directives in scanner
use NAME as prefix of the FlexLexer class name and its members
initialize input to std::cin instead of stdin
generate global yylex() scanner, yytext, yyleng, yylineno
generate reentrant yylex() scanner for bison pure parser
generate bison C++ interface code for bison lalr1.cc skeleton
use namespace NAME with bison lalr1.cc skeleton
use parser class NAME with bison lalr1.cc skeleton
use bison complete-symbols feature, implies bison-cc
include bison yylloc support
generate Flex-compatible yylex() reentrant scanner functions NOTE: adds functions only, reflex scanners are always reentrant
same as --flex and --bison, also generate global yyin, yyout
call yypanic() when scanner jams, requires --flex --nodefault
do not call yywrap() on EOF, requires option --flex
use exception VALUE to throw as the default rule
use NAME as the return type of lex() and yylex() instead of int

Debugging:

enable debug mode in scanner
scanner reports detailed performance statistics to stderr
disable the default rule that echoes unmatched text
report summary of scanner statistics to stdout
do not generate warnings

Miscellaneous:

do-nothing POSIX options

-?, -h, --help
produce this help message and exit
report reflex version and exit

Lex/Flex options that are enabled by default or have no effect:


--7bit n/a

--8bit default

DEPENDENCIES

None, except when option -m specifies an external pattern-matcher engine such as pcre2 or boost that requires the corresponding library.

DOCUMENTATION

The full documentation for reflex is maintained as a Doxygen-generated manual reflex/doc/html/index.html located in the source directory of the reflex installation. Or visit:

<https://www.genivia.com/doc/reflex/html/index.html>

to browse the latest version of the reflex user guide.

COPYRIGHT

Copyright (c) 2016-2024 Robert A. van Engelen <engelen@acm.org>

reflex is released under the BSD-3 license. All parts of the software have reasonable copyright terms permitting free redistribution. This includes the ability to reuse all or parts of the reflex source tree.

BUGS

REJECT is not functional and not available.

Report bugs at: <https://github.com/Genivia/RE-flex/issues>

SEE ALSO

lex(1), flex(1), flex++(1).

January 27, 2025 reflex 5.2.1