/usr/share/doc/flex-old-doc/flex_6.html is in flex-old-doc 2.5.4a-10.
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 | html2
<html>
<!-- Created on May 24, 2011 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: 6. Format of the input file</title>
<meta name="description" content="Flex - a scanner generator: 6. Format of the input file">
<meta name="keywords" content="Flex - a scanner generator: 6. Format of the input file">
<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="Format"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="flex_5.html#Examples" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="flex_7.html#Patterns" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="flex_5.html#Examples" 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_7.html#Patterns" 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="Format-of-the-input-file"></a>
<h1 class="chapter">6. Format of the input file</h1>
<p>The <code>flex</code> input file consists of three sections, separated
by a line with just ‘<samp>%%</samp>’ in it:
</p>
<table><tr><td> </td><td><pre class="example">definitions
%%
rules
%%
user code
</pre></td></tr></table>
<p>The <em>definitions</em> section contains declarations of simple
<em>name</em> definitions to simplify the scanner specification,
and declarations of <em>start conditions</em>, which are explained
in a later section.
Name definitions have the form:
</p>
<table><tr><td> </td><td><pre class="example">name definition
</pre></td></tr></table>
<p>The "name" is a word beginning with a letter or an
underscore (’_’) followed by zero or more letters, digits, ’_’,
or ’-’ (dash). The definition is taken to begin at the
first non-white-space character following the name and
continuing to the end of the line. The definition can
subsequently be referred to using "{name}", which will
expand to "(definition)". For example,
</p>
<table><tr><td> </td><td><pre class="example">DIGIT [0-9]
ID [a-z][a-z0-9]*
</pre></td></tr></table>
<p>defines "DIGIT" to be a regular expression which matches a
single digit, and "ID" to be a regular expression which
matches a letter followed by zero-or-more
letters-or-digits. A subsequent reference to
</p>
<table><tr><td> </td><td><pre class="example">{DIGIT}+"."{DIGIT}*
</pre></td></tr></table>
<p>is identical to
</p>
<table><tr><td> </td><td><pre class="example">([0-9])+"."([0-9])*
</pre></td></tr></table>
<p>and matches one-or-more digits followed by a ’.’ followed
by zero-or-more digits.
</p>
<p>The <var>rules</var> section of the <code>flex</code> input contains a series of
rules of the form:
</p>
<table><tr><td> </td><td><pre class="example">pattern action
</pre></td></tr></table>
<p>where the pattern must be unindented and the action must
begin on the same line.
</p>
<p>See section <a href="flex_7.html#Patterns">Patterns</a>, for a further description of patterns and
actions.
</p>
<p>Finally, the user code section is simply copied to
‘<tt>lex.yy.c</tt>’ verbatim. It is used for companion routines
which call or are called by the scanner. The presence of
this section is optional; if it is missing, the second ‘<samp>%%</samp>’
in the input file may be skipped, too.
</p>
<p>In the definitions and rules sections, any <em>indented</em> text or
text enclosed in ‘<samp>%{</samp>’ and ‘<samp>%}</samp>’ is copied verbatim to the
output (with the ‘<samp>%{}</samp>’’s removed). The ‘<samp>%{}</samp>’’s must
appear unindented on lines by themselves.
</p>
<p>In the rules section, any indented or %{} text appearing
before the first rule may be used to declare variables
which are local to the scanning routine and (after the
declarations) code which is to be executed whenever the
scanning routine is entered. Other indented or %{} text
in the rule section is still copied to the output, but its
meaning is not well-defined and it may well cause
compile-time errors (this feature is present for <code>POSIX</code> compliance;
see below for other such features).
</p>
<p>In the definitions section (but not in the rules section),
an unindented comment (i.e., a line beginning with "/*")
is also copied verbatim to the output up to the next "*/".
</p>
<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="flex_5.html#Examples" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="flex_7.html#Patterns" 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 on <i>May 24, 2011</i> using <a href="http://www.nongnu.org/texi2html/"><i>texi2html 1.82</i></a>.
</font>
<br>
</p>
</body>
</html>
|