/[eiffelstudio]/vendor/gobosoft.com/gobo/current/doc/gelex/description.html
ViewVC logotype

Contents of /vendor/gobosoft.com/gobo/current/doc/gelex/description.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 90767 - (show annotations)
Tue Jan 22 00:56:30 2013 UTC (6 years, 8 months ago) by manus
File MIME type: text/xml
File size: 9731 byte(s)
Updated svn:eol-style to be native and svn:mime-style to be text/xml

1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3
4 <head>
5 <meta http-equiv="Content-Type"
6 content="text/html; charset=iso-8859-1">
7 <meta name="GENERATOR" content="Microsoft FrontPage 2.0">
8 <title>Gelex: Scanner Description File</title>
9 </head>
10
11 <body bgcolor="#FFFFFF">
12
13 <table border="0" width="100%">
14 <tr>
15 <td><font size="6"><strong>Scanner Description File</strong></font></td>
16 <td align="right"><a href="examples.html"><img
17 src="../image/previous.gif" alt="Previous" border="0"
18 width="40" height="40"></a><a href="scanner.html"><img
19 src="../image/next.gif" alt="Next" border="0" width="40"
20 height="40"></a></td>
21 </tr>
22 </table>
23
24 <hr size="1">
25
26 <p>The <em>gelex</em> input file consists of three sections,
27 separated by a line with just <font color="#0000FF"><tt>%%</tt></font>
28 in it:</p>
29
30 <blockquote>
31 <pre><tt>declarations
32 </tt><font color="#0000FF"><tt>%%</tt></font><tt>
33 rules
34 </tt><font color="#0000FF"><tt>%%</tt></font><tt>
35 user code</tt></pre>
36 </blockquote>
37
38 <p>Comments follow Eiffel style conventions and have no effect on
39 the description's semantics.</p>
40
41 <h2><a name="declarations">Declarations section</a></h2>
42
43 <p>The declarations section contains declarations of <a
44 href="options.html">options</a> and <a
45 href="start_conditions.html">start conditions</a> which are
46 explained elsewhere, declarations of simple name definitions to
47 simplify the scanner specification, and declarations of Eiffel
48 code to be copied at the beginning of the generated scanner
49 class.</p>
50
51 <h4><a name="definitions">Name definitions</a></h4>
52
53 <p>Name definitions have the form:</p>
54
55 <blockquote>
56 <pre><font color="#800080"><tt>name</tt></font><tt> </tt><font
57 color="#FF0000"><tt>definition</tt></font></pre>
58 </blockquote>
59
60 <p>The <font color="#800080"><tt>name</tt></font> is a word
61 beginning with a letter and followed by zero or more letters,
62 digits, or underscores. It must appear at the beginning of the
63 line and is case-insensitive, which means that the three
64 following lines are equivalent:</p>
65
66 <blockquote>
67 <pre><font color="#800080">name</font> <font color="#FF0000">definition</font>
68 <font color="#800080">NAME</font> <font color="#FF0000">definition</font>
69 <font color="#800080">nAmE</font> <font color="#FF0000">definition</font></pre>
70 </blockquote>
71
72 <p>The definition is taken to begin at the first non-whitespace
73 character following the name and continuing to the end of the
74 line. The definition can subsequently be referred to using <font
75 color="#FF0000"><tt>{name}</tt></font>, which will expand to <font
76 color="#FF0000"><tt>(definition)</tt></font>. For example,</p>
77
78 <blockquote>
79 <pre><font color="#800080"><tt>DIGIT</tt></font><tt> </tt><font
80 color="#FF0000"><tt> [0-9]</tt></font><tt>
81 </tt><font color="#800080"><tt>ID</tt></font><tt> </tt><font
82 color="#FF0000"><tt>[a-z][a-z0-9]*</tt></font></pre>
83 </blockquote>
84
85 <p>defines <font color="#800080"><tt>DIGIT</tt></font> to be a <a
86 href="patterns.html">regular expression</a> which matches a
87 single digit, and <font color="#800080"><tt>ID</tt></font> to be
88 a regular expression which matches a letter followed by
89 zero-or-more letters-or-digits. A subsequent reference to:</p>
90
91 <blockquote>
92 <pre><font color="#FF0000">{DIGIT}+&quot;.&quot;{DIGIT}*</font></pre>
93 </blockquote>
94
95 <p>is identical to:</p>
96
97 <blockquote>
98 <pre><font color="#FF0000">([0-9])+&quot;.&quot;([0-9])*</font></pre>
99 </blockquote>
100
101 <p>and matches one-or-more digits followed by a dot followed by
102 zero-or-more digits.</p>
103
104 <p>Note that the <font color="#FF0000">definition </font>part can
105 be defined in terms of other definitions. For example:</p>
106
107 <blockquote>
108 <pre><font color="#800080"><tt>ID</tt></font><font
109 color="#FF0000"><tt> {LETTER}({LETTER}|{DIGIT})*
110 </tt></font><font color="#800080"><tt>DIGIT</tt></font><tt> </tt><font
111 color="#FF0000"><tt> [0-9]</tt></font><font color="#800080"><tt>
112 LETTER</tt></font><tt> </tt><font color="#FF0000"><tt>[a-z]</tt></font></pre>
113 </blockquote>
114
115 <p>Then a subsequent reference to:</p>
116
117 <blockquote>
118 <pre><font color="#FF0000"><tt>{ID}</tt></font></pre>
119 </blockquote>
120
121 <p>is identical to:</p>
122
123 <blockquote>
124 <pre><font color="#FF0000"><tt>([a-z])(([a-z])|([0-9]))*</tt></font></pre>
125 </blockquote>
126
127 <p>As opposed to <a href="start_conditions.html">start conditions</a>,
128 the name definition mechanism has its own name space. Names that
129 are otherwise used as feature names in the generated scanner
130 class can therefore be used as definition names without
131 ambiguity.</p>
132
133 <h4><a name="eiffel_declarations">Eiffel declarations</a></h4>
134
135 <p>The declarations section may also contain Eiffel code to be
136 copied verbatim to the beginning of the generated scanner class.
137 The Eiffel text has to be enclosed between two unindented lines
138 containing the two marks <font color="#0000FF"><tt>%{</tt></font>
139 and <font color="#0000FF"><tt>%}</tt></font> such as in the
140 following example:</p>
141
142 <blockquote>
143 <pre><font color="#0000FF">%{</font>
144 <font color="#008080"><em><strong>class</strong></em><em> MY_SCANNER
145
146 </em><em><strong>inherit</strong></em><em>
147
148 YY_COMPRESSED_SCANNER_SKELETON
149
150 </em><em><strong>create</strong></em><em>
151
152 make</em></font>
153 <font color="#0000FF">%}</font></pre>
154 </blockquote>
155
156 <p><em>Gelex</em> does not generate the note, class header,
157 formal generics, obsolete, inheritance and creation clauses. As
158 the example above shows, Eiffel declarations are used to specify
159 such clauses in order to ensure that the generated scanner class
160 is syntactically and semantically correct. Here, the name of the
161 generated class is <font color="#008080"><em><tt>MY_SCANNER</tt></em></font>
162 and its creation procedure is <font color="#008080"><em><tt>make</tt></em></font>,
163 a routine inherited from class <font color="#008080"><em><tt>YY_COMPRESSED_SCANNER_SKELETON</tt></em></font>.
164 This class contains the pattern-matching engine <font size="4"
165 face="Courier New">-</font> a Deterministic Finite Automaton (or <font
166 size="2">DFA</font> for short) <font size="4" face="Courier New">-</font>
167 which is optimized in size, hence the name of the class. It also
168 provides numerous facilities such as routine <font
169 color="#008080"><em><tt>scan</tt></em></font> for analyzing a
170 given input text. The generated scanner class has to inherit from
171 one such class to work properly. Other alternatives are <font
172 color="#008080"><em><tt>YY_FULL_SCANNER_SKELETON</tt></em></font>,
173 whose <font size="2">DFA</font> is optimized in speed but not in
174 space, and <font color="#008080"><em><tt>YY_INTERACTIVE_SCANNER_SKELETON</tt></em></font><font
175 size="3">, whose </font><font size="2">DFA</font><font size="3">
176 can deal with interactive input such as input from the keyboard.</font></p>
177
178 <p>If several of these Eiffel blocks appear in the declarations
179 section, they are all copied to the generated scanner class in
180 their order of appearance in the input file.</p>
181
182 <h2><a name="rules">Rules section</a></h2>
183
184 <p>The rules section of the <em>gelex</em> input contains a
185 series of rules of the form:</p>
186
187 <blockquote>
188 <pre><font color="#FF0000">pattern</font> <font
189 color="#008080">action</font></pre>
190 </blockquote>
191
192 <p>where the pattern can be indented and the action must begin on
193 the same line. A further description of <a href="patterns.html">patterns</a>
194 and <a href="actions.html">actions</a> is provided in other
195 chapters.</p>
196
197 <h2><a name="user_code">User code section</a></h2>
198
199 <p>Finally, the user code section is simply copied verbatim to
200 the end of the generated scanner class. <em>Gelex</em> does not
201 generate the invariant clause and the end of class keyword. This
202 section is hence used to specify such clauses and also to define
203 features called from the semantic actions. The presence of this
204 section is optional (if it is missing, the second <font
205 color="#0000FF"><tt>%%</tt></font> in the input file may be
206 skipped, too) but is highly recommended if only to specify the
207 end of the generated scanner class and thus ensure that this
208 class is syntactically correct.</p>
209
210 <p>Names of implementation features in inherited classes <font
211 color="#008080"><em><tt>YY_*_SCANNER_SKELETON</tt></em></font>
212 are prefixed by <font color="#008080"><em><tt>yy</tt></em></font>.
213 As a consequence, user-declarared feature names beginning with
214 this prefix should be avoided. </p>
215
216 <hr size="1">
217
218 <table border="0" width="100%">
219 <tr>
220 <td><address>
221 <font size="2"><b>Copyright 1997-2005</b></font><font
222 size="1"><b>, </b></font><font size="2"><strong>Eric
223 Bezault</strong></font><strong> </strong><font
224 size="2"><br>
225 <strong>mailto:</strong></font><a
226 href="mailto:ericb@gobosoft.com"><font size="2">ericb@gobosoft.com</font></a><font
227 size="2"><br>
228 <strong>http:</strong></font><a
229 href="http://www.gobosoft.com"><font size="2">//www.gobosoft.com</font></a><font
230 size="2"><br>
231 <strong>Last Updated:</strong> 21 February 2005</font><br>
232 <!--webbot bot="PurpleText"
233 preview="
234 $Date$
235 $Revision$"
236 -->
237 </address>
238 </td>
239 <td align="right" valign="top"><a
240 href="http://www.gobosoft.com"><img
241 src="../image/home.gif" alt="Home" border="0" width="40"
242 height="40"></a><a href="index.html"><img
243 src="../image/toc.gif" alt="Toc" border="0" width="40"
244 height="40"></a><a href="examples.html"><img
245 src="../image/previous.gif" alt="Previous" border="0"
246 width="40" height="40"></a><a href="scanner.html"><img
247 src="../image/next.gif" alt="Next" border="0" width="40"
248 height="40"></a></td>
249 </tr>
250 </table>
251 </body>
252 </html>

Properties

Name Value
svn:mime-type text/xml

  ViewVC Help
Powered by ViewVC 1.1.23