/usr/share/doc/flex-old-doc/flex_10.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 | 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: 10. The generated scanner</title>
<meta name="description" content="Flex - a scanner generator: 10. The generated scanner">
<meta name="keywords" content="Flex - a scanner generator: 10. The generated scanner">
<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="Generated-scanner"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="flex_9.html#Actions" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="flex_11.html#Start-conditions" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="flex_9.html#Actions" 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_11.html#Start-conditions" 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="The-generated-scanner"></a>
<h1 class="chapter">10. The generated scanner</h1>
<p>The output of <code>flex</code> is the file ‘<tt>lex.yy.c</tt>’, which contains
the scanning routine ‘<samp>yylex()</samp>’, a number of tables used by
it for matching tokens, and a number of auxiliary routines
and macros. By default, ‘<samp>yylex()</samp>’ is declared as follows:
</p>
<table><tr><td> </td><td><pre class="example">int yylex()
{
… various definitions and the actions in here …
}
</pre></td></tr></table>
<p>(If your environment supports function prototypes, then it
will be "int yylex( void )".) This definition may be
changed by defining the "YY_DECL" macro. For example, you
could use:
</p>
<table><tr><td> </td><td><pre class="example">#define YY_DECL float lexscan( a, b ) float a, b;
</pre></td></tr></table>
<p>to give the scanning routine the name <code>lexscan</code>, returning a
float, and taking two floats as arguments. Note that if
you give arguments to the scanning routine using a
K&R-style/non-prototyped function declaration, you must
terminate the definition with a semi-colon (‘<samp>;</samp>’).
</p>
<p>Whenever ‘<samp>yylex()</samp>’ is called, it scans tokens from the
global input file <code>yyin</code> (which defaults to stdin). It
continues until it either reaches an end-of-file (at which
point it returns the value 0) or one of its actions
executes a <code>return</code> statement.
</p>
<p>If the scanner reaches an end-of-file, subsequent calls are undefined
unless either <code>yyin</code> is pointed at a new input file (in which case
scanning continues from that file), or ‘<samp>yyrestart()</samp>’ is called.
‘<samp>yyrestart()</samp>’ takes one argument, a ‘<samp>FILE *</samp>’ pointer (which
can be nil, if you’ve set up <code>YY_INPUT</code> to scan from a source
other than <code>yyin</code>), and initializes <code>yyin</code> for scanning from
that file. Essentially there is no difference between just assigning
<code>yyin</code> to a new input file or using ‘<samp>yyrestart()</samp>’ to do so;
the latter is available for compatibility with previous versions of
<code>flex</code>, and because it can be used to switch input files in the
middle of scanning. It can also be used to throw away the current
input buffer, by calling it with an argument of <code>yyin</code>; but
better is to use <code>YY_FLUSH_BUFFER</code> (see above). Note that
‘<samp>yyrestart()</samp>’ does <em>not</em> reset the start condition to
<code>INITIAL</code> (see Start Conditions, below).
</p>
<p>If ‘<samp>yylex()</samp>’ stops scanning due to executing a <code>return</code>
statement in one of the actions, the scanner may then be called
again and it will resume scanning where it left off.
</p>
<p>By default (and for purposes of efficiency), the scanner
uses block-reads rather than simple ‘<samp>getc()</samp>’ calls to read
characters from <code>yyin</code>. The nature of how it gets its input
can be controlled by defining the <code>YY_INPUT</code> macro.
YY_INPUT’s calling sequence is
"YY_INPUT(buf,result,max_size)". Its action is to place
up to <var>max_size</var> characters in the character array <var>buf</var> and
return in the integer variable <var>result</var> either the number of
characters read or the constant YY_NULL (0 on Unix
systems) to indicate EOF. The default YY_INPUT reads from
the global file-pointer "yyin".
</p>
<p>A sample definition of YY_INPUT (in the definitions
section of the input file):
</p>
<table><tr><td> </td><td><pre class="example">%{
#define YY_INPUT(buf,result,max_size) \
{ \
int c = getchar(); \
result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \
}
%}
</pre></td></tr></table>
<p>This definition will change the input processing to occur
one character at a time.
</p>
<p>When the scanner receives an end-of-file indication from
YY_INPUT, it then checks the ‘<samp>yywrap()</samp>’ function. If
‘<samp>yywrap()</samp>’ returns false (zero), then it is assumed that the
function has gone ahead and set up <code>yyin</code> to point to
another input file, and scanning continues. If it returns
true (non-zero), then the scanner terminates, returning 0
to its caller. Note that in either case, the start
condition remains unchanged; it does <em>not</em> revert to <code>INITIAL</code>.
</p>
<p>If you do not supply your own version of ‘<samp>yywrap()</samp>’, then you
must either use ‘<samp>%option noyywrap</samp>’ (in which case the scanner
behaves as though ‘<samp>yywrap()</samp>’ returned 1), or you must link with
‘<samp>-lfl</samp>’ to obtain the default version of the routine, which always
returns 1.
</p>
<p>Three routines are available for scanning from in-memory
buffers rather than files: ‘<samp>yy_scan_string()</samp>’,
‘<samp>yy_scan_bytes()</samp>’, and ‘<samp>yy_scan_buffer()</samp>’.
See section <a href="flex_12.html#Multiple-buffers">Multiple Input Buffers</a>.
</p>
<p>The scanner writes its ‘<samp>ECHO</samp>’ output to the <code>yyout</code> global
(default, stdout), which may be redefined by the user
simply by assigning it to some other <code>FILE</code> pointer.
</p>
<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="flex_9.html#Actions" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="flex_11.html#Start-conditions" 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>
|