stdinit if unset ("%option nostdinit"), initialize yyin
and yyout statically to nil FILE* pointers, instead
of stdin and stdout
+ yylineno if set, keep track of the current line
+ number in global yylineno (this option is expensive
+ in terms of performance)
yywrap if unset ("%option noyywrap"), scanner does not
call yywrap() upon EOF but simply assumes there
are no more files to scan
- input() no longer trashes yytext.
+ - interactive scanners now read characters in YY_INPUT up to a
+ newline, a large performance gain.
+
- C++ scanner objects now work with the -P option. You include
<FlexLexer.h> once per scanner - see comments in <FlexLexer.h>
(or flex.1) for details.
switches to new input files or different input buffers. If you
want to e.g., return to INITIAL, you must explicitly do so.
+ - The "Performance Considerations" section of the manual has been
+ updated.
+
- Documented the "yy_act" variable, which when YY_USER_ACTION is
invoked holds the number of the matched rule, and added an
example of using yy_act to profile how often each rule is matched.
features that lead to minor performance losses.
.IP
Note that the use of
-.B REJECT
+.B REJECT,
+.B %option yylineno,
and variable trailing context (see the Deficiencies / Bugs section below)
entails a substantial performance penalty; use of
.I yymore(),
yyin
yyleng
yylex
+ yylineno
yyout
yyrestart
yytext
and
.I stdout.
.TP
+.B yylineno
+directs
+.I flex
+to generate a scanner that maintains the number of the current line
+read from its input in the global variable
+.B yylineno.
+This option is implied by
+.B %option lex-compat.
+.TP
.B yywrap
if unset (i.e.,
.B %option noyywrap),
.nf
REJECT
+ %option yylineno
+ arbitrary trailing context
pattern sets that require backing up
- arbitrary trailing context
+ %array
+ %option interactive
+ %option always-interactive
'^' beginning-of-line operator
yymore()
.I flex
to generate a C++ scanner class, using the
.B \-+
-option, which is automatically specified if the name of the flex
+option (or, equivalently,
+.B %option c++),
+which is automatically specified if the name of the flex
executable ends in a '+', such as
.I flex++.
When using this option, flex defaults to generating the scanner to the file
.B int YYLeng()
returns the length of the most recently matched token, the equivalent of
.B yyleng.
+.TP
+.B int lineno() const
+returns the current input line number
+(see
+.B %option yylineno),
+or
+.B 1
+if
+.B %option yylineno
+was not used.
+.TP
+.B void set_debug( int flag )
+sets the debugging flag for the scanner, equivalent to assigning to
+.B yy_flex_debug
+(see the Options section above). Note that you must build the scanner
+using
+.B %option debug
+to include debugging information in it.
+.TP
+.B int debug() const
+returns the current setting of the debugging flag.
.PP
Also provided are member functions equivalent to
.B yy_switch_to_buffer(),
.B yylineno
is not supported unless
.B \-l
+or
+.B %option yylineno
is used.
.IP
yylineno is not part of the POSIX specification.