/usr/share/doc/flex-old-doc/flex_17.html is in flex-old-doc 2.5.4a-10ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 | html2
<html>
<!-- Created on February 6, 2012 by texi2html 1.82
texi2html was written by:
Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>
-->
<head>
<title>Flex - a scanner generator: 17. Options</title>
<meta name="description" content="Flex - a scanner generator: 17. Options">
<meta name="keywords" content="Flex - a scanner generator: 17. Options">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.82">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Options"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="flex_16.html#YACC-interface" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="flex_18.html#Performance" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="flex_16.html#YACC-interface" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="flex.html#Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="flex_18.html#Performance" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="flex.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="flex_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[Index]</td>
<td valign="middle" align="left">[<a href="flex_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Options-1"></a>
<h1 class="chapter">17. Options</h1>
<p><code>flex</code> has the following options:
</p>
<dl compact="compact">
<dt> ‘<samp>-b</samp>’</dt>
<dd><p>Generate backing-up information to ‘<tt>lex.backup</tt>’.
This is a list of scanner states which require
backing up and the input characters on which they
do so. By adding rules one can remove backing-up
states. If <em>all</em> backing-up states are eliminated
and ‘<samp>-Cf</samp>’ or ‘<samp>-CF</samp>’ is used, the generated scanner will
run faster (see the ‘<samp>-p</samp>’ flag). Only users who wish
to squeeze every last cycle out of their scanners
need worry about this option. (see section <a href="flex_18.html#Performance">Performance Considerations</a>)
</p>
</dd>
<dt> ‘<samp>-c</samp>’</dt>
<dd><p>is a do-nothing, deprecated option included for
POSIX compliance.
</p>
</dd>
<dt> ‘<samp>-d</samp>’</dt>
<dd><p>makes the generated scanner run in <em>debug</em> mode.
Whenever a pattern is recognized and the global
<code>yy_flex_debug</code> is non-zero (which is the default),
the scanner will write to <code>stderr</code> a line of the
form:
</p>
<table><tr><td> </td><td><pre class="example">--accepting rule at line 53 ("the matched text")
</pre></td></tr></table>
<p>The line number refers to the location of the rule
in the file defining the scanner (i.e., the file
that was fed to flex). Messages are also generated
when the scanner backs up, accepts the default
rule, reaches the end of its input buffer (or
encounters a NUL; at this point, the two look the
same as far as the scanner’s concerned), or reaches
an end-of-file.
</p>
</dd>
<dt> ‘<samp>-f</samp>’</dt>
<dd><p>specifies <em>fast scanner</em>. No table compression is
done and stdio is bypassed. The result is large
but fast. This option is equivalent to ‘<samp>-Cfr</samp>’ (see
below).
</p>
</dd>
<dt> ‘<samp>-h</samp>’</dt>
<dd><p>generates a "help" summary of <code>flex's</code> options to
<code>stdout</code> and then exits. ‘<samp>-?</samp>’ and ‘<samp>--help</samp>’ are synonyms
for ‘<samp>-h</samp>’.
</p>
</dd>
<dt> ‘<samp>-i</samp>’</dt>
<dd><p>instructs <code>flex</code> to generate a <em>case-insensitive</em>
scanner. The case of letters given in the <code>flex</code> input
patterns will be ignored, and tokens in the input
will be matched regardless of case. The matched
text given in <code>yytext</code> will have the preserved case
(i.e., it will not be folded).
</p>
</dd>
<dt> ‘<samp>-l</samp>’</dt>
<dd><p>turns on maximum compatibility with the original
AT&T <code>lex</code> implementation. Note that this does not
mean <em>full</em> compatibility. Use of this option costs
a considerable amount of performance, and it cannot
be used with the ‘<samp>-+, -f, -F, -Cf</samp>’, or ‘<samp>-CF</samp>’ options.
For details on the compatibilities it provides, see
the section "Incompatibilities With Lex And POSIX"
below. This option also results in the name
<code>YY_FLEX_LEX_COMPAT</code> being #define’d in the generated
scanner.
</p>
</dd>
<dt> ‘<samp>-n</samp>’</dt>
<dd><p>is another do-nothing, deprecated option included
only for POSIX compliance.
</p>
</dd>
<dt> ‘<samp>-p</samp>’</dt>
<dd><p>generates a performance report to stderr. The
report consists of comments regarding features of
the <code>flex</code> input file which will cause a serious loss
of performance in the resulting scanner. If you
give the flag twice, you will also get comments
regarding features that lead to minor performance
losses.
</p>
<p>Note that the use of <code>REJECT</code>, ‘<samp>%option yylineno</samp>’ and
variable trailing context (see the Deficiencies / Bugs section below)
entails a substantial performance penalty; use of ‘<samp>yymore()</samp>’,
the ‘<samp>^</samp>’ operator, and the ‘<samp>-I</samp>’ flag entail minor performance
penalties.
</p>
</dd>
<dt> ‘<samp>-s</samp>’</dt>
<dd><p>causes the <em>default rule</em> (that unmatched scanner
input is echoed to <code>stdout</code>) to be suppressed. If
the scanner encounters input that does not match
any of its rules, it aborts with an error. This
option is useful for finding holes in a scanner’s
rule set.
</p>
</dd>
<dt> ‘<samp>-t</samp>’</dt>
<dd><p>instructs <code>flex</code> to write the scanner it generates to
standard output instead of ‘<tt>lex.yy.c</tt>’.
</p>
</dd>
<dt> ‘<samp>-v</samp>’</dt>
<dd><p>specifies that <code>flex</code> should write to <code>stderr</code> a
summary of statistics regarding the scanner it
generates. Most of the statistics are meaningless to
the casual <code>flex</code> user, but the first line identifies
the version of <code>flex</code> (same as reported by ‘<samp>-V</samp>’), and
the next line the flags used when generating the
scanner, including those that are on by default.
</p>
</dd>
<dt> ‘<samp>-w</samp>’</dt>
<dd><p>suppresses warning messages.
</p>
</dd>
<dt> ‘<samp>-B</samp>’</dt>
<dd><p>instructs <code>flex</code> to generate a <em>batch</em> scanner, the
opposite of <em>interactive</em> scanners generated by ‘<samp>-I</samp>’
(see below). In general, you use ‘<samp>-B</samp>’ when you are
<em>certain</em> that your scanner will never be used
interactively, and you want to squeeze a <em>little</em> more
performance out of it. If your goal is instead to
squeeze out a <em>lot</em> more performance, you should be
using the ‘<samp>-Cf</samp>’ or ‘<samp>-CF</samp>’ options (discussed below),
which turn on ‘<samp>-B</samp>’ automatically anyway.
</p>
</dd>
<dt> ‘<samp>-F</samp>’</dt>
<dd><p>specifies that the <em>fast</em> scanner table
representation should be used (and stdio bypassed). This
representation is about as fast as the full table
representation ‘<samp>(-f)</samp>’, and for some sets of patterns
will be considerably smaller (and for others,
larger). In general, if the pattern set contains
both "keywords" and a catch-all, "identifier" rule,
such as in the set:
</p>
<table><tr><td> </td><td><pre class="example">"case" return TOK_CASE;
"switch" return TOK_SWITCH;
...
"default" return TOK_DEFAULT;
[a-z]+ return TOK_ID;
</pre></td></tr></table>
<p>then you’re better off using the full table
representation. If only the "identifier" rule is
present and you then use a hash table or some such to
detect the keywords, you’re better off using ‘<samp>-F</samp>’.
</p>
<p>This option is equivalent to ‘<samp>-CFr</samp>’ (see below). It
cannot be used with ‘<samp>-+</samp>’.
</p>
</dd>
<dt> ‘<samp>-I</samp>’</dt>
<dd><p>instructs <code>flex</code> to generate an <em>interactive</em> scanner.
An interactive scanner is one that only looks ahead
to decide what token has been matched if it
absolutely must. It turns out that always looking one
extra character ahead, even if the scanner has
already seen enough text to disambiguate the
current token, is a bit faster than only looking ahead
when necessary. But scanners that always look
ahead give dreadful interactive performance; for
example, when a user types a newline, it is not
recognized as a newline token until they enter
<em>another</em> token, which often means typing in another
whole line.
</p>
<p><code>Flex</code> scanners default to <em>interactive</em> unless you use
the ‘<samp>-Cf</samp>’ or ‘<samp>-CF</samp>’ table-compression options (see
below). That’s because if you’re looking for
high-performance you should be using one of these
options, so if you didn’t, <code>flex</code> assumes you’d
rather trade off a bit of run-time performance for
intuitive interactive behavior. Note also that you
<em>cannot</em> use ‘<samp>-I</samp>’ in conjunction with ‘<samp>-Cf</samp>’ or ‘<samp>-CF</samp>’.
Thus, this option is not really needed; it is on by
default for all those cases in which it is allowed.
</p>
<p>You can force a scanner to <em>not</em> be interactive by
using ‘<samp>-B</samp>’ (see above).
</p>
</dd>
<dt> ‘<samp>-L</samp>’</dt>
<dd><p>instructs <code>flex</code> not to generate ‘<samp>#line</samp>’ directives.
Without this option, <code>flex</code> peppers the generated
scanner with #line directives so error messages in
the actions will be correctly located with respect
to either the original <code>flex</code> input file (if the
errors are due to code in the input file), or
‘<tt>lex.yy.c</tt>’ (if the errors are <code>flex's</code> fault – you
should report these sorts of errors to the email
address given below).
</p>
</dd>
<dt> ‘<samp>-T</samp>’</dt>
<dd><p>makes <code>flex</code> run in <code>trace</code> mode. It will generate a
lot of messages to <code>stderr</code> concerning the form of
the input and the resultant non-deterministic and
deterministic finite automata. This option is
mostly for use in maintaining <code>flex</code>.
</p>
</dd>
<dt> ‘<samp>-V</samp>’</dt>
<dd><p>prints the version number to <code>stdout</code> and exits.
‘<samp>--version</samp>’ is a synonym for ‘<samp>-V</samp>’.
</p>
</dd>
<dt> ‘<samp>-7</samp>’</dt>
<dd><p>instructs <code>flex</code> to generate a 7-bit scanner, i.e.,
one which can only recognized 7-bit characters in
its input. The advantage of using ‘<samp>-7</samp>’ is that the
scanner’s tables can be up to half the size of
those generated using the ‘<samp>-8</samp>’ option (see below).
The disadvantage is that such scanners often hang
or crash if their input contains an 8-bit
character.
</p>
<p>Note, however, that unless you generate your
scanner using the ‘<samp>-Cf</samp>’ or ‘<samp>-CF</samp>’ table compression options,
use of ‘<samp>-7</samp>’ will save only a small amount of table
space, and make your scanner considerably less
portable. <code>Flex's</code> default behavior is to generate
an 8-bit scanner unless you use the ‘<samp>-Cf</samp>’ or ‘<samp>-CF</samp>’, in
which case <code>flex</code> defaults to generating 7-bit
scanners unless your site was always configured to
generate 8-bit scanners (as will often be the case
with non-USA sites). You can tell whether flex
generated a 7-bit or an 8-bit scanner by inspecting
the flag summary in the ‘<samp>-v</samp>’ output as described
above.
</p>
<p>Note that if you use ‘<samp>-Cfe</samp>’ or ‘<samp>-CFe</samp>’ (those table
compression options, but also using equivalence
classes as discussed see below), flex still
defaults to generating an 8-bit scanner, since
usually with these compression options full 8-bit
tables are not much more expensive than 7-bit
tables.
</p>
</dd>
<dt> ‘<samp>-8</samp>’</dt>
<dd><p>instructs <code>flex</code> to generate an 8-bit scanner, i.e.,
one which can recognize 8-bit characters. This
flag is only needed for scanners generated using
‘<samp>-Cf</samp>’ or ‘<samp>-CF</samp>’, as otherwise flex defaults to
generating an 8-bit scanner anyway.
</p>
<p>See the discussion of ‘<samp>-7</samp>’ above for flex’s default
behavior and the tradeoffs between 7-bit and 8-bit
scanners.
</p>
</dd>
<dt> ‘<samp>-+</samp>’</dt>
<dd><p>specifies that you want flex to generate a C++
scanner class. See section <a href="flex_19.html#C_002b_002b">Generating C++ Scanners</a>.
</p>
</dd>
<dt> ‘<samp>-C[aefFmr]</samp>’</dt>
<dd><p>controls the degree of table compression and, more
generally, trade-offs between small scanners and
fast scanners.
</p>
<p>‘<samp>-Ca</samp>’ ("align") instructs flex to trade off larger
tables in the generated scanner for faster
performance because the elements of the tables are better
aligned for memory access and computation. On some
RISC architectures, fetching and manipulating
long-words is more efficient than with smaller-sized
units such as shortwords. This option can quadruple
the size of the tables used by your scanner. It has the
side effect of permitting much larger scanners, however,
if you need this.
</p>
<p>‘<samp>-Ce</samp>’ directs <code>flex</code> to construct <em>equivalence classes</em>,
i.e., sets of characters which have identical
lexical properties (for example, if the only appearance
of digits in the <code>flex</code> input is in the character
class "[0-9]" then the digits ’0’, ’1’, …, ’9’
will all be put in the same equivalence class).
Equivalence classes usually give dramatic
reductions in the final table/object file sizes
(typically a factor of 2-5) and are pretty cheap
performance-wise (one array look-up per character
scanned).
</p>
<p>‘<samp>-Cf</samp>’ specifies that the <em>full</em> scanner tables should
be generated - <code>flex</code> should not compress the tables
by taking advantages of similar transition
functions for different states.
</p>
<p>‘<samp>-CF</samp>’ specifies that the alternate fast scanner
representation (described above under the ‘<samp>-F</samp>’ flag)
should be used. This option cannot be used with
‘<samp>-+</samp>’.
</p>
<p>‘<samp>-Cm</samp>’ directs <code>flex</code> to construct <em>meta-equivalence
classes</em>, which are sets of equivalence classes (or
characters, if equivalence classes are not being
used) that are commonly used together.
Meta-equivalence classes are often a big win when using
compressed tables, but they have a moderate
performance impact (one or two "if" tests and one array
look-up per character scanned).
</p>
<p>‘<samp>-Cr</samp>’ causes the generated scanner to <em>bypass</em> use of
the standard I/O library (stdio) for input.
Instead of calling ‘<samp>fread()</samp>’ or ‘<samp>getc()</samp>’, the scanner
will use the ‘<samp>read()</samp>’ system call, resulting in a
performance gain which varies from system to
system, but in general is probably negligible unless
you are also using ‘<samp>-Cf</samp>’ or ‘<samp>-CF</samp>’. Using ‘<samp>-Cr</samp>’ can cause
strange behavior if, for example, you read from
<code>yyin</code> using stdio prior to calling the scanner
(because the scanner will miss whatever text your
previous reads left in the stdio input buffer).
</p>
<p>‘<samp>-Cr</samp>’ has no effect if you define <code>YY_INPUT</code> (see The
Generated Scanner above).
</p>
<p>A lone ‘<samp>-C</samp>’ specifies that the scanner tables should
be compressed but neither equivalence classes nor
meta-equivalence classes should be used.
</p>
<p>The options ‘<samp>-Cf</samp>’ or ‘<samp>-CF</samp>’ and ‘<samp>-Cm</samp>’ do not make sense
together - there is no opportunity for
meta-equivalence classes if the table is not being
compressed. Otherwise the options may be freely
mixed, and are cumulative.
</p>
<p>The default setting is ‘<samp>-Cem</samp>’, which specifies that
<code>flex</code> should generate equivalence classes and
meta-equivalence classes. This setting provides the
highest degree of table compression. You can trade
off faster-executing scanners at the cost of larger
tables with the following generally being true:
</p>
<table><tr><td> </td><td><pre class="example">slowest & smallest
-Cem
-Cm
-Ce
-C
-C{f,F}e
-C{f,F}
-C{f,F}a
fastest & largest
</pre></td></tr></table>
<p>Note that scanners with the smallest tables are
usually generated and compiled the quickest, so
during development you will usually want to use the
default, maximal compression.
</p>
<p>‘<samp>-Cfe</samp>’ is often a good compromise between speed and
size for production scanners.
</p>
</dd>
<dt> ‘<samp>-ooutput</samp>’</dt>
<dd><p>directs flex to write the scanner to the file ‘<samp>out-</samp>’
<code>put</code> instead of ‘<tt>lex.yy.c</tt>’. If you combine ‘<samp>-o</samp>’ with
the ‘<samp>-t</samp>’ option, then the scanner is written to
<code>stdout</code> but its ‘<samp>#line</samp>’ directives (see the ‘<samp>-L</samp>’ option
above) refer to the file <code>output</code>.
</p>
</dd>
<dt> ‘<samp>-Pprefix</samp>’</dt>
<dd><p>changes the default ‘<samp>yy</samp>’ prefix used by <code>flex</code> for all
globally-visible variable and function names to
instead be <var>prefix</var>. For example, ‘<samp>-Pfoo</samp>’ changes the
name of <code>yytext</code> to ‘<tt>footext</tt>’. It also changes the
name of the default output file from ‘<tt>lex.yy.c</tt>’ to
‘<tt>lex.foo.c</tt>’. Here are all of the names affected:
</p>
<table><tr><td> </td><td><pre class="example">yy_create_buffer
yy_delete_buffer
yy_flex_debug
yy_init_buffer
yy_flush_buffer
yy_load_buffer_state
yy_switch_to_buffer
yyin
yyleng
yylex
yylineno
yyout
yyrestart
yytext
yywrap
</pre></td></tr></table>
<p>(If you are using a C++ scanner, then only <code>yywrap</code>
and <code>yyFlexLexer</code> are affected.) Within your scanner
itself, you can still refer to the global variables
and functions using either version of their name;
but externally, they have the modified name.
</p>
<p>This option lets you easily link together multiple
<code>flex</code> programs into the same executable. Note,
though, that using this option also renames
‘<samp>yywrap()</samp>’, so you now <em>must</em> either provide your own
(appropriately-named) version of the routine for
your scanner, or use ‘<samp>%option noyywrap</samp>’, as linking
with ‘<samp>-lfl</samp>’ no longer provides one for you by
default.
</p>
</dd>
<dt> ‘<samp>-Sskeleton_file</samp>’</dt>
<dd><p>overrides the default skeleton file from which <code>flex</code>
constructs its scanners. You’ll never need this
option unless you are doing <code>flex</code> maintenance or
development.
</p></dd>
</dl>
<p><code>flex</code> also provides a mechanism for controlling options
within the scanner specification itself, rather than from
the flex command-line. This is done by including ‘<samp>%option</samp>’
directives in the first section of the scanner
specification. You can specify multiple options with a single
‘<samp>%option</samp>’ directive, and multiple directives in the first
section of your flex input file. Most options are given
simply as names, optionally preceded by the word "no"
(with no intervening whitespace) to negate their meaning.
A number are equivalent to flex flags or their negation:
</p>
<table><tr><td> </td><td><pre class="example">7bit -7 option
8bit -8 option
align -Ca option
backup -b option
batch -B option
c++ -+ option
caseful or
case-sensitive opposite of -i (default)
case-insensitive or
caseless -i option
debug -d option
default opposite of -s option
ecs -Ce option
fast -F option
full -f option
interactive -I option
lex-compat -l option
meta-ecs -Cm option
perf-report -p option
read -Cr option
stdout -t option
verbose -v option
warn opposite of -w option
(use "%option nowarn" for -w)
array equivalent to "%array"
pointer equivalent to "%pointer" (default)
</pre></td></tr></table>
<p>Some ‘<samp>%option's</samp>’ provide features otherwise not available:
</p>
<dl compact="compact">
<dt> ‘<samp>always-interactive</samp>’</dt>
<dd><p>instructs flex to generate a scanner which always
considers its input "interactive". Normally, on
each new input file the scanner calls ‘<samp>isatty()</samp>’ in
an attempt to determine whether the scanner’s input
source is interactive and thus should be read a
character at a time. When this option is used,
however, then no such call is made.
</p>
</dd>
<dt> ‘<samp>main</samp>’</dt>
<dd><p>directs flex to provide a default ‘<samp>main()</samp>’ program
for the scanner, which simply calls ‘<samp>yylex()</samp>’. This
option implies <code>noyywrap</code> (see below).
</p>
</dd>
<dt> ‘<samp>never-interactive</samp>’</dt>
<dd><p>instructs flex to generate a scanner which never
considers its input "interactive" (again, no call
made to ‘<samp>isatty())</samp>’. This is the opposite of ‘<samp>always-</samp>’
<em>interactive</em>.
</p>
</dd>
<dt> ‘<samp>stack</samp>’</dt>
<dd><p>enables the use of start condition stacks (see
Start Conditions above).
</p>
</dd>
<dt> ‘<samp>stdinit</samp>’</dt>
<dd><p>if unset (i.e., ‘<samp>%option nostdinit</samp>’) initializes <code>yyin</code>
and <code>yyout</code> to nil <code>FILE</code> pointers, instead of <code>stdin</code>
and <code>stdout</code>.
</p>
</dd>
<dt> ‘<samp>yylineno</samp>’</dt>
<dd><p>directs <code>flex</code> to generate a scanner that maintains the number
of the current line read from its input in the global variable
<code>yylineno</code>. This option is implied by ‘<samp>%option lex-compat</samp>’.
</p>
</dd>
<dt> ‘<samp>yywrap</samp>’</dt>
<dd><p>if unset (i.e., ‘<samp>%option noyywrap</samp>’), makes the
scanner not call ‘<samp>yywrap()</samp>’ upon an end-of-file, but
simply assume that there are no more files to scan
(until the user points <code>yyin</code> at a new file and calls
‘<samp>yylex()</samp>’ again).
</p></dd>
</dl>
<p><code>flex</code> scans your rule actions to determine whether you use
the <code>REJECT</code> or ‘<samp>yymore()</samp>’ features. The <code>reject</code> and <code>yymore</code>
options are available to override its decision as to
whether you use the options, either by setting them (e.g.,
‘<samp>%option reject</samp>’) to indicate the feature is indeed used, or
unsetting them to indicate it actually is not used (e.g.,
‘<samp>%option noyymore</samp>’).
</p>
<p>Three options take string-delimited values, offset with ’=’:
</p>
<table><tr><td> </td><td><pre class="example">%option outfile="ABC"
</pre></td></tr></table>
<p>is equivalent to ‘<samp>-oABC</samp>’, and
</p>
<table><tr><td> </td><td><pre class="example">%option prefix="XYZ"
</pre></td></tr></table>
<p>is equivalent to ‘<samp>-PXYZ</samp>’.
</p>
<p>Finally,
</p>
<table><tr><td> </td><td><pre class="example">%option yyclass="foo"
</pre></td></tr></table>
<p>only applies when generating a C++ scanner (‘<samp>-+</samp>’ option). It
informs <code>flex</code> that you have derived ‘<samp>foo</samp>’ as a subclass of
<code>yyFlexLexer</code> so <code>flex</code> will place your actions in the member
function ‘<samp>foo::yylex()</samp>’ instead of ‘<samp>yyFlexLexer::yylex()</samp>’.
It also generates a ‘<samp>yyFlexLexer::yylex()</samp>’ member function that
emits a run-time error (by invoking ‘<samp>yyFlexLexer::LexerError()</samp>’)
if called. See section <a href="flex_19.html#C_002b_002b">Generating C++ Scanners</a>.
</p>
<p>A number of options are available for lint purists who
want to suppress the appearance of unneeded routines in
the generated scanner. Each of the following, if unset,
results in the corresponding routine not appearing in the
generated scanner:
</p>
<table><tr><td> </td><td><pre class="example">input, unput
yy_push_state, yy_pop_state, yy_top_state
yy_scan_buffer, yy_scan_bytes, yy_scan_string
</pre></td></tr></table>
<p>(though ‘<samp>yy_push_state()</samp>’ and friends won’t appear anyway
unless you use ‘<samp>%option stack</samp>’).
</p>
<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="flex_16.html#YACC-interface" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="flex_18.html#Performance" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="flex.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="flex_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[Index]</td>
<td valign="middle" align="left">[<a href="flex_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p>
<font size="-1">
This document was generated by <em>Build Daemon user</em> on <em>February 6, 2012</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.82</em></a>.
</font>
<br>
</p>
</body>
</html>
|