This file is indexed.

/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"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="flex_18.html#Performance" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="flex_16.html#YACC-interface" title="Beginning of this chapter or previous chapter"> &lt;&lt; </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"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </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> &lsquo;<samp>-b</samp>&rsquo;</dt>
<dd><p>Generate backing-up information to &lsquo;<tt>lex.backup</tt>&rsquo;.
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 &lsquo;<samp>-Cf</samp>&rsquo; or &lsquo;<samp>-CF</samp>&rsquo; is used, the generated scanner will
run faster (see the &lsquo;<samp>-p</samp>&rsquo; 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> &lsquo;<samp>-c</samp>&rsquo;</dt>
<dd><p>is a do-nothing, deprecated option included for
POSIX compliance.
</p>
</dd>
<dt> &lsquo;<samp>-d</samp>&rsquo;</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>&nbsp;</td><td><pre class="example">--accepting rule at line 53 (&quot;the matched text&quot;)
</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&rsquo;s concerned), or reaches
an end-of-file.
</p>
</dd>
<dt> &lsquo;<samp>-f</samp>&rsquo;</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 &lsquo;<samp>-Cfr</samp>&rsquo; (see
below).
</p>
</dd>
<dt> &lsquo;<samp>-h</samp>&rsquo;</dt>
<dd><p>generates a &quot;help&quot; summary of <code>flex's</code> options to
<code>stdout</code> and then exits.  &lsquo;<samp>-?</samp>&rsquo; and &lsquo;<samp>--help</samp>&rsquo; are synonyms
for &lsquo;<samp>-h</samp>&rsquo;.
</p>
</dd>
<dt> &lsquo;<samp>-i</samp>&rsquo;</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> &lsquo;<samp>-l</samp>&rsquo;</dt>
<dd><p>turns on maximum compatibility with the original
AT&amp;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 &lsquo;<samp>-+, -f, -F, -Cf</samp>&rsquo;, or &lsquo;<samp>-CF</samp>&rsquo; options.
For details on the compatibilities it provides, see
the section &quot;Incompatibilities With Lex And POSIX&quot;
below.  This option also results in the name
<code>YY_FLEX_LEX_COMPAT</code> being #define&rsquo;d in the generated
scanner.
</p>
</dd>
<dt> &lsquo;<samp>-n</samp>&rsquo;</dt>
<dd><p>is another do-nothing, deprecated option included
only for POSIX compliance.
</p>
</dd>
<dt> &lsquo;<samp>-p</samp>&rsquo;</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>, &lsquo;<samp>%option yylineno</samp>&rsquo; and
variable trailing context (see the Deficiencies / Bugs section below)
entails a substantial performance penalty; use of &lsquo;<samp>yymore()</samp>&rsquo;,
the &lsquo;<samp>^</samp>&rsquo; operator, and the &lsquo;<samp>-I</samp>&rsquo; flag entail minor performance
penalties.
</p>
</dd>
<dt> &lsquo;<samp>-s</samp>&rsquo;</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&rsquo;s
rule set.
</p>
</dd>
<dt> &lsquo;<samp>-t</samp>&rsquo;</dt>
<dd><p>instructs <code>flex</code> to write the scanner it generates to
standard output instead of &lsquo;<tt>lex.yy.c</tt>&rsquo;.
</p>
</dd>
<dt> &lsquo;<samp>-v</samp>&rsquo;</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 &lsquo;<samp>-V</samp>&rsquo;), and
the next line the flags used when generating the
scanner, including those that are on by default.
</p>
</dd>
<dt> &lsquo;<samp>-w</samp>&rsquo;</dt>
<dd><p>suppresses warning messages.
</p>
</dd>
<dt> &lsquo;<samp>-B</samp>&rsquo;</dt>
<dd><p>instructs <code>flex</code> to generate a <em>batch</em> scanner, the
opposite of <em>interactive</em> scanners generated by &lsquo;<samp>-I</samp>&rsquo;
(see below).  In general, you use &lsquo;<samp>-B</samp>&rsquo; 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 &lsquo;<samp>-Cf</samp>&rsquo; or &lsquo;<samp>-CF</samp>&rsquo; options (discussed below),
which turn on &lsquo;<samp>-B</samp>&rsquo; automatically anyway.
</p>
</dd>
<dt> &lsquo;<samp>-F</samp>&rsquo;</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 &lsquo;<samp>(-f)</samp>&rsquo;, and for some sets of patterns
will be considerably smaller (and for others,
larger).  In general, if the pattern set contains
both &quot;keywords&quot; and a catch-all, &quot;identifier&quot; rule,
such as in the set:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">&quot;case&quot;    return TOK_CASE;
&quot;switch&quot;  return TOK_SWITCH;
...
&quot;default&quot; return TOK_DEFAULT;
[a-z]+    return TOK_ID;
</pre></td></tr></table>

<p>then you&rsquo;re better off using the full table
representation.  If only the &quot;identifier&quot; rule is
present and you then use a hash table or some such to
detect the keywords, you&rsquo;re better off using &lsquo;<samp>-F</samp>&rsquo;.
</p>
<p>This option is equivalent to &lsquo;<samp>-CFr</samp>&rsquo; (see below).  It
cannot be used with &lsquo;<samp>-+</samp>&rsquo;.
</p>
</dd>
<dt> &lsquo;<samp>-I</samp>&rsquo;</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 &lsquo;<samp>-Cf</samp>&rsquo; or &lsquo;<samp>-CF</samp>&rsquo; table-compression options (see
below).  That&rsquo;s because if you&rsquo;re looking for
high-performance you should be using one of these
options, so if you didn&rsquo;t, <code>flex</code> assumes you&rsquo;d
rather trade off a bit of run-time performance for
intuitive interactive behavior.  Note also that you
<em>cannot</em> use &lsquo;<samp>-I</samp>&rsquo; in conjunction with &lsquo;<samp>-Cf</samp>&rsquo; or &lsquo;<samp>-CF</samp>&rsquo;.
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 &lsquo;<samp>-B</samp>&rsquo; (see above).
</p>
</dd>
<dt> &lsquo;<samp>-L</samp>&rsquo;</dt>
<dd><p>instructs <code>flex</code> not to generate &lsquo;<samp>#line</samp>&rsquo; 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
&lsquo;<tt>lex.yy.c</tt>&rsquo; (if the errors are <code>flex's</code> fault &ndash; you
should report these sorts of errors to the email
address given below).
</p>
</dd>
<dt> &lsquo;<samp>-T</samp>&rsquo;</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> &lsquo;<samp>-V</samp>&rsquo;</dt>
<dd><p>prints the version number to <code>stdout</code> and exits.
&lsquo;<samp>--version</samp>&rsquo; is a synonym for &lsquo;<samp>-V</samp>&rsquo;.
</p>
</dd>
<dt> &lsquo;<samp>-7</samp>&rsquo;</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 &lsquo;<samp>-7</samp>&rsquo; is that the
scanner&rsquo;s tables can be up to half the size of
those generated using the &lsquo;<samp>-8</samp>&rsquo; 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 &lsquo;<samp>-Cf</samp>&rsquo; or &lsquo;<samp>-CF</samp>&rsquo; table compression options,
use of &lsquo;<samp>-7</samp>&rsquo; 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 &lsquo;<samp>-Cf</samp>&rsquo; or &lsquo;<samp>-CF</samp>&rsquo;, 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 &lsquo;<samp>-v</samp>&rsquo; output as described
above.
</p>
<p>Note that if you use &lsquo;<samp>-Cfe</samp>&rsquo; or &lsquo;<samp>-CFe</samp>&rsquo; (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> &lsquo;<samp>-8</samp>&rsquo;</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
&lsquo;<samp>-Cf</samp>&rsquo; or &lsquo;<samp>-CF</samp>&rsquo;, as otherwise flex defaults to
generating an 8-bit scanner anyway.
</p>
<p>See the discussion of &lsquo;<samp>-7</samp>&rsquo; above for flex&rsquo;s default
behavior and the tradeoffs between 7-bit and 8-bit
scanners.
</p>
</dd>
<dt> &lsquo;<samp>-+</samp>&rsquo;</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> &lsquo;<samp>-C[aefFmr]</samp>&rsquo;</dt>
<dd><p>controls the degree of table compression and, more
generally, trade-offs between small scanners and
fast scanners.
</p>
<p>&lsquo;<samp>-Ca</samp>&rsquo; (&quot;align&quot;) 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>&lsquo;<samp>-Ce</samp>&rsquo; 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 &quot;[0-9]&quot; then the digits &rsquo;0&rsquo;, &rsquo;1&rsquo;, &hellip;, &rsquo;9&rsquo;
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>&lsquo;<samp>-Cf</samp>&rsquo; 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>&lsquo;<samp>-CF</samp>&rsquo; specifies that the alternate fast scanner
representation (described above under the &lsquo;<samp>-F</samp>&rsquo; flag)
should be used.  This option cannot be used with
&lsquo;<samp>-+</samp>&rsquo;.
</p>
<p>&lsquo;<samp>-Cm</samp>&rsquo; 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 &quot;if&quot; tests and one array
look-up per character scanned).
</p>
<p>&lsquo;<samp>-Cr</samp>&rsquo; causes the generated scanner to <em>bypass</em> use of
the standard I/O library (stdio) for input.
Instead of calling &lsquo;<samp>fread()</samp>&rsquo; or &lsquo;<samp>getc()</samp>&rsquo;, the scanner
will use the &lsquo;<samp>read()</samp>&rsquo; system call, resulting in a
performance gain which varies from system to
system, but in general is probably negligible unless
you are also using &lsquo;<samp>-Cf</samp>&rsquo; or &lsquo;<samp>-CF</samp>&rsquo;.  Using &lsquo;<samp>-Cr</samp>&rsquo; 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>&lsquo;<samp>-Cr</samp>&rsquo; has no effect if you define <code>YY_INPUT</code> (see The
Generated Scanner above).
</p>
<p>A lone &lsquo;<samp>-C</samp>&rsquo; specifies that the scanner tables should
be compressed but neither equivalence classes nor
meta-equivalence classes should be used.
</p>
<p>The options &lsquo;<samp>-Cf</samp>&rsquo; or &lsquo;<samp>-CF</samp>&rsquo; and &lsquo;<samp>-Cm</samp>&rsquo; 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 &lsquo;<samp>-Cem</samp>&rsquo;, 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>&nbsp;</td><td><pre class="example">slowest &amp; smallest
      -Cem
      -Cm
      -Ce
      -C
      -C{f,F}e
      -C{f,F}
      -C{f,F}a
fastest &amp; 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>&lsquo;<samp>-Cfe</samp>&rsquo; is often a good compromise between speed and
size for production scanners.
</p>
</dd>
<dt> &lsquo;<samp>-ooutput</samp>&rsquo;</dt>
<dd><p>directs flex to write the scanner to the file &lsquo;<samp>out-</samp>&rsquo;
<code>put</code> instead of &lsquo;<tt>lex.yy.c</tt>&rsquo;.  If you combine &lsquo;<samp>-o</samp>&rsquo; with
the &lsquo;<samp>-t</samp>&rsquo; option, then the scanner is written to
<code>stdout</code> but its &lsquo;<samp>#line</samp>&rsquo; directives (see the &lsquo;<samp>-L</samp>&rsquo; option
above) refer to the file <code>output</code>.
</p>
</dd>
<dt> &lsquo;<samp>-Pprefix</samp>&rsquo;</dt>
<dd><p>changes the default &lsquo;<samp>yy</samp>&rsquo; prefix used by <code>flex</code> for all
globally-visible variable and function names to
instead be <var>prefix</var>.  For example, &lsquo;<samp>-Pfoo</samp>&rsquo; changes the
name of <code>yytext</code> to &lsquo;<tt>footext</tt>&rsquo;.  It also changes the
name of the default output file from &lsquo;<tt>lex.yy.c</tt>&rsquo; to
&lsquo;<tt>lex.foo.c</tt>&rsquo;.  Here are all of the names affected:
</p>
<table><tr><td>&nbsp;</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
&lsquo;<samp>yywrap()</samp>&rsquo;, so you now <em>must</em> either provide your own
(appropriately-named) version of the routine for
your scanner, or use &lsquo;<samp>%option noyywrap</samp>&rsquo;, as linking
with &lsquo;<samp>-lfl</samp>&rsquo; no longer provides one for you by
default.
</p>
</dd>
<dt> &lsquo;<samp>-Sskeleton_file</samp>&rsquo;</dt>
<dd><p>overrides the default skeleton file from which <code>flex</code>
constructs its scanners.  You&rsquo;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 &lsquo;<samp>%option</samp>&rsquo;
directives in the first section of the scanner
specification.  You can specify multiple options with a single
&lsquo;<samp>%option</samp>&rsquo; 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 &quot;no&quot;
(with no intervening whitespace) to negate their meaning.
A number are equivalent to flex flags or their negation:
</p>
<table><tr><td>&nbsp;</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 &quot;%option nowarn&quot; for -w)

array           equivalent to &quot;%array&quot;
pointer         equivalent to &quot;%pointer&quot; (default)
</pre></td></tr></table>

<p>Some &lsquo;<samp>%option's</samp>&rsquo; provide features otherwise not available:
</p>
<dl compact="compact">
<dt> &lsquo;<samp>always-interactive</samp>&rsquo;</dt>
<dd><p>instructs flex to generate a scanner which always
considers its input &quot;interactive&quot;.  Normally, on
each new input file the scanner calls &lsquo;<samp>isatty()</samp>&rsquo; in
an attempt to determine whether the scanner&rsquo;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> &lsquo;<samp>main</samp>&rsquo;</dt>
<dd><p>directs flex to provide a default &lsquo;<samp>main()</samp>&rsquo; program
for the scanner, which simply calls &lsquo;<samp>yylex()</samp>&rsquo;.  This
option implies <code>noyywrap</code> (see below).
</p>
</dd>
<dt> &lsquo;<samp>never-interactive</samp>&rsquo;</dt>
<dd><p>instructs flex to generate a scanner which never
considers its input &quot;interactive&quot; (again, no call
made to &lsquo;<samp>isatty())</samp>&rsquo;.  This is the opposite of &lsquo;<samp>always-</samp>&rsquo;
<em>interactive</em>.
</p>
</dd>
<dt> &lsquo;<samp>stack</samp>&rsquo;</dt>
<dd><p>enables the use of start condition stacks (see
Start Conditions above).
</p>
</dd>
<dt> &lsquo;<samp>stdinit</samp>&rsquo;</dt>
<dd><p>if unset (i.e., &lsquo;<samp>%option nostdinit</samp>&rsquo;) 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> &lsquo;<samp>yylineno</samp>&rsquo;</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 &lsquo;<samp>%option lex-compat</samp>&rsquo;.
</p>
</dd>
<dt> &lsquo;<samp>yywrap</samp>&rsquo;</dt>
<dd><p>if unset (i.e., &lsquo;<samp>%option noyywrap</samp>&rsquo;), makes the
scanner not call &lsquo;<samp>yywrap()</samp>&rsquo; 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
&lsquo;<samp>yylex()</samp>&rsquo; again).
</p></dd>
</dl>

<p><code>flex</code> scans your rule actions to determine whether you use
the <code>REJECT</code> or &lsquo;<samp>yymore()</samp>&rsquo; 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.,
&lsquo;<samp>%option reject</samp>&rsquo;) to indicate the feature is indeed used, or
unsetting them to indicate it actually is not used (e.g.,
&lsquo;<samp>%option noyymore</samp>&rsquo;).
</p>
<p>Three options take string-delimited values, offset with &rsquo;=&rsquo;:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">%option outfile=&quot;ABC&quot;
</pre></td></tr></table>

<p>is equivalent to &lsquo;<samp>-oABC</samp>&rsquo;, and
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">%option prefix=&quot;XYZ&quot;
</pre></td></tr></table>

<p>is equivalent to &lsquo;<samp>-PXYZ</samp>&rsquo;.
</p>
<p>Finally,
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">%option yyclass=&quot;foo&quot;
</pre></td></tr></table>

<p>only applies when generating a C++ scanner (&lsquo;<samp>-+</samp>&rsquo; option).  It
informs <code>flex</code> that you have derived &lsquo;<samp>foo</samp>&rsquo; as a subclass of
<code>yyFlexLexer</code> so <code>flex</code> will place your actions in the member
function &lsquo;<samp>foo::yylex()</samp>&rsquo; instead of &lsquo;<samp>yyFlexLexer::yylex()</samp>&rsquo;.
It also generates a &lsquo;<samp>yyFlexLexer::yylex()</samp>&rsquo; member function that
emits a run-time error (by invoking &lsquo;<samp>yyFlexLexer::LexerError()</samp>&rsquo;)
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>&nbsp;</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 &lsquo;<samp>yy_push_state()</samp>&rsquo; and friends won&rsquo;t appear anyway
unless you use &lsquo;<samp>%option stack</samp>&rsquo;).
</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"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="flex_18.html#Performance" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </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>