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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--NewPage-->
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- Generated by javadoc on Mon Jun 17 10:56:34 EDT 2002 -->
<title>W3C Flute version 1.3 - Java API: Interface
CharStream</title>
<link rel="stylesheet" type="text/css" href=
"../../../../stylesheet.css" title="Style" />
</head>
<body bgcolor="white">
<!-- ========== START OF NAVBAR ========== -->
<a id="navbar_top" name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan="2" bgcolor="#EEEEFF" class="NavBarCell1"><a id=
"navbar_top_firstrow" name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
<tr align="center" valign="top">
<td bgcolor="#EEEEFF" class="NavBarCell1"><a href=
"../../../../index.html"><span class=
"NavBarFont1"><b>Overview</b></span></a> </td>
<td bgcolor="#EEEEFF" class="NavBarCell1"><a href=
"package-summary.html"><span class=
"NavBarFont1"><b>Package</b></span></a> </td>
<td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <span class=
"NavBarFont1Rev"><b>Class</b></span> </td>
<td bgcolor="#EEEEFF" class="NavBarCell1"><a href=
"package-tree.html"><span class=
"NavBarFont1"><b>Tree</b></span></a> </td>
<td bgcolor="#EEEEFF" class="NavBarCell1"><a href=
"../../../../index-all.html"><span class=
"NavBarFont1"><b>Index</b></span></a> </td>
<td bgcolor="#EEEEFF" class="NavBarCell1"><a href=
"../../../../help-doc.html"><span class=
"NavBarFont1"><b>Help</b></span></a> </td>
</tr>
</table>
</td>
<td align="right" valign="top" rowspan="3"><em><a href=
'http://www.w3.org/'><img border='0' src=
'http://www.w3.org/Icons/w3c_home' alt='W3C logo' /></a></em> </td>
</tr>
<tr>
<td bgcolor="white" class="NavBarCell2"> PREV CLASS
<a href=
"../../../../org/w3c/flute/parser/ParserConstants.html"><b>NEXT
CLASS</b></a></td>
<td bgcolor="white" class="NavBarCell2"></td>
</tr>
<tr>
<td valign="top" class="NavBarCell3">SUMMARY:
INNER | FIELD | CONSTR | <a
href="#method_summary">METHOD</a></td>
<td valign="top" class="NavBarCell3">DETAIL:
FIELD | CONSTR | <a href=
"#method_detail">METHOD</a></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->
<hr />
<!-- ======== START OF CLASS DATA ======== -->
<h2>org.w3c.flute.parser<br />
Interface CharStream</h2>
<dl>
<dt><b>All Known Implementing Classes:</b></dt>
<dd><a href=
"../../../../org/w3c/flute/parser/Generic_CharStream.html">Generic_CharStream</a></dd>
</dl>
<hr />
<dl>
<dt>public interface <b>CharStream</b></dt>
</dl>
<p>This interface describes a character stream that maintains line
and column number positions of the characters. It also has the
capability to backup the stream to some extent. An implementation
of this interface is used in the TokenManager implementation
generated by JavaCCParser. All the methods except backup can be
implemented in any fashion. backup needs to be implemented
correctly for the correct operation of the lexer. Rest of the
methods are all used to get information like line number, column
number and the String that constitutes a token and are not used by
the lexer. Hence their implementation won't affect the generated
lexer's operation.</p>
<hr />
<p><!-- ======== INNER CLASS SUMMARY ======== -->
<!-- =========== FIELD SUMMARY =========== -->
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<!-- ========== METHOD SUMMARY =========== -->
<a id="method_summary" name="method_summary"><!-- --></a></p>
<table border="1" cellpadding="3" cellspacing="0" width="100%">
<tr bgcolor="#CCCCFF" class="TableHeadingColor">
<td colspan="2"><b>Method Summary</b></td>
</tr>
<tr bgcolor="white" class="TableRowColor">
<td align="right" valign="top" width="1%">
<code> void</code></td>
<td><code><b><a href=
"../../../../org/w3c/flute/parser/CharStream.html#backup_int_">backup</a></b>(int amount)</code>
<br />
Backs
up the input stream by amount steps.</td>
</tr>
<tr bgcolor="white" class="TableRowColor">
<td align="right" valign="top" width="1%">
<code> char</code></td>
<td><code><b><a href=
"../../../../org/w3c/flute/parser/CharStream.html#BeginToken__">BeginToken</a></b>()</code>
<br />
Returns
the next character that marks the beginning of the next token.</td>
</tr>
<tr bgcolor="white" class="TableRowColor">
<td align="right" valign="top" width="1%">
<code> void</code></td>
<td><code><b><a href=
"../../../../org/w3c/flute/parser/CharStream.html#Done__">Done</a></b>()</code>
<br />
The
lexer calls this function to indicate that it is done with the
stream and hence implementations can free any resources held by
this class.</td>
</tr>
<tr bgcolor="white" class="TableRowColor">
<td align="right" valign="top" width="1%">
<code> int</code></td>
<td><code><b><a href=
"../../../../org/w3c/flute/parser/CharStream.html#getBeginColumn__">
getBeginColumn</a></b>()</code> <br />
Returns
the column number of the first character for current token (being
matched after the last call to BeginTOken).</td>
</tr>
<tr bgcolor="white" class="TableRowColor">
<td align="right" valign="top" width="1%">
<code> int</code></td>
<td><code><b><a href=
"../../../../org/w3c/flute/parser/CharStream.html#getBeginLine__">getBeginLine</a></b>()</code>
<br />
Returns
the line number of the first character for current token (being
matched after the last call to BeginTOken).</td>
</tr>
<tr bgcolor="white" class="TableRowColor">
<td align="right" valign="top" width="1%">
<code> int</code></td>
<td><code><b><a href=
"../../../../org/w3c/flute/parser/CharStream.html#getEndColumn__">getEndColumn</a></b>()</code>
<br />
Returns
the column number of the last character for current token (being
matched after the last call to BeginTOken).</td>
</tr>
<tr bgcolor="white" class="TableRowColor">
<td align="right" valign="top" width="1%">
<code> int</code></td>
<td><code><b><a href=
"../../../../org/w3c/flute/parser/CharStream.html#getEndLine__">getEndLine</a></b>()</code>
<br />
Returns
the line number of the last character for current token (being
matched after the last call to BeginTOken).</td>
</tr>
<tr bgcolor="white" class="TableRowColor">
<td align="right" valign="top" width="1%">
<code> java.lang.String</code></td>
<td><code><b><a href=
"../../../../org/w3c/flute/parser/CharStream.html#GetImage__">GetImage</a></b>()</code>
<br />
Returns
a string made up of characters from the marked token beginning to
the current buffer position.</td>
</tr>
<tr bgcolor="white" class="TableRowColor">
<td align="right" valign="top" width="1%">
<code> char[]</code></td>
<td><code><b><a href=
"../../../../org/w3c/flute/parser/CharStream.html#GetSuffix_int_">GetSuffix</a></b>(int len)</code>
<br />
Returns
an array of characters that make up the suffix of length 'len' for
the currently matched token.</td>
</tr>
<tr bgcolor="white" class="TableRowColor">
<td align="right" valign="top" width="1%">
<code> char</code></td>
<td><code><b><a href=
"../../../../org/w3c/flute/parser/CharStream.html#readChar__">readChar</a></b>()</code>
<br />
Returns
the next character from the selected input.</td>
</tr>
</table>
<p><!-- ============ FIELD DETAIL =========== -->
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<!-- ============ METHOD DETAIL ========== -->
<a id="method_detail" name="method_detail"><!-- --></a></p>
<table border="1" cellpadding="3" cellspacing="0" width="100%">
<tr bgcolor="#CCCCFF" class="TableHeadingColor">
<td colspan="1"><b>Method Detail</b></td>
</tr>
</table>
<a id="backup_int_" name="backup_int_"><!-- --></a>
<h3>backup</h3>
<pre>
public void <b>backup</b>(int amount)
</pre>
<dl>
<dd>Backs up the input stream by amount steps. Lexer calls this
method if it had already read some characters, but could not use
them to match a (longer) token. So, they will be used again as the
prefix of the next token and it is the implemetation's
responsibility to do this right.</dd>
</dl>
<hr />
<a id="BeginToken__" name="BeginToken__"><!-- --></a>
<h3>BeginToken</h3>
<pre>
public char <b>BeginToken</b>()
throws java.io.IOException
</pre>
<dl>
<dd>Returns the next character that marks the beginning of the next
token. All characters must remain in the buffer between two
successive calls to this method to implement backup correctly.</dd>
</dl>
<hr />
<a id="Done__" name="Done__"><!-- --></a>
<h3>Done</h3>
<pre>
public void <b>Done</b>()
</pre>
<dl>
<dd>The lexer calls this function to indicate that it is done with
the stream and hence implementations can free any resources held by
this class. Again, the body of this function can be just empty and
it will not affect the lexer's operation.</dd>
</dl>
<hr />
<a id="getBeginColumn__" name="getBeginColumn__"><!-- --></a>
<h3>getBeginColumn</h3>
<pre>
public int <b>getBeginColumn</b>()
</pre>
<dl>
<dd>Returns the column number of the first character for current
token (being matched after the last call to BeginTOken).</dd>
</dl>
<hr />
<a id="getBeginLine__" name="getBeginLine__"><!-- --></a>
<h3>getBeginLine</h3>
<pre>
public int <b>getBeginLine</b>()
</pre>
<dl>
<dd>Returns the line number of the first character for current
token (being matched after the last call to BeginTOken).</dd>
</dl>
<hr />
<a id="getEndColumn__" name="getEndColumn__"><!-- --></a>
<h3>getEndColumn</h3>
<pre>
public int <b>getEndColumn</b>()
</pre>
<dl>
<dd>Returns the column number of the last character for current
token (being matched after the last call to BeginTOken).</dd>
</dl>
<hr />
<a id="getEndLine__" name="getEndLine__"><!-- --></a>
<h3>getEndLine</h3>
<pre>
public int <b>getEndLine</b>()
</pre>
<dl>
<dd>Returns the line number of the last character for current token
(being matched after the last call to BeginTOken).</dd>
</dl>
<hr />
<a id="GetImage__" name="GetImage__"><!-- --></a>
<h3>GetImage</h3>
<pre>
public java.lang.String <b>GetImage</b>()
</pre>
<dl>
<dd>Returns a string made up of characters from the marked token
beginning to the current buffer position. Implementations have the
choice of returning anything that they want to. For example, for
efficiency, one might decide to just return null, which is a valid
implementation.</dd>
</dl>
<hr />
<a id="GetSuffix_int_" name="GetSuffix_int_"><!-- --></a>
<h3>GetSuffix</h3>
<pre>
public char[] <b>GetSuffix</b>(int len)
</pre>
<dl>
<dd>Returns an array of characters that make up the suffix of
length 'len' for the currently matched token. This is used to build
up the matched string for use in actions in the case of MORE. A
simple and inefficient implementation of this is as follows : {
String t = GetImage(); return t.substring(t.length() - len,
t.length()).toCharArray(); }</dd>
</dl>
<hr />
<a id="readChar__" name="readChar__"><!-- --></a>
<h3>readChar</h3>
<pre>
public char <b>readChar</b>()
throws java.io.IOException
</pre>
<dl>
<dd>Returns the next character from the selected input. The method
of selecting the input is the responsibility of the class
implementing this interface. Can throw any
java.io.IOException.</dd>
</dl>
<!-- ========= END OF CLASS DATA ========= -->
<hr />
<!-- ========== START OF NAVBAR ========== -->
<a id="navbar_bottom" name="navbar_bottom"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan="2" bgcolor="#EEEEFF" class="NavBarCell1"><a id=
"navbar_bottom_firstrow" name="navbar_bottom_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
<tr align="center" valign="top">
<td bgcolor="#EEEEFF" class="NavBarCell1"><a href=
"../../../../index.html"><span class=
"NavBarFont1"><b>Overview</b></span></a> </td>
<td bgcolor="#EEEEFF" class="NavBarCell1"><a href=
"package-summary.html"><span class=
"NavBarFont1"><b>Package</b></span></a> </td>
<td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <span class=
"NavBarFont1Rev"><b>Class</b></span> </td>
<td bgcolor="#EEEEFF" class="NavBarCell1"><a href=
"package-tree.html"><span class=
"NavBarFont1"><b>Tree</b></span></a> </td>
<td bgcolor="#EEEEFF" class="NavBarCell1"><a href=
"../../../../index-all.html"><span class=
"NavBarFont1"><b>Index</b></span></a> </td>
<td bgcolor="#EEEEFF" class="NavBarCell1"><a href=
"../../../../help-doc.html"><span class=
"NavBarFont1"><b>Help</b></span></a> </td>
</tr>
</table>
</td>
<td align="right" valign="top" rowspan="3"></td>
</tr>
<tr>
<td bgcolor="white" class="NavBarCell2"> PREV CLASS
<a href=
"../../../../org/w3c/flute/parser/ParserConstants.html"><b>NEXT
CLASS</b></a></td>
<td bgcolor="white" class="NavBarCell2"></td>
</tr>
<tr>
<td valign="top" class="NavBarCell3">SUMMARY:
INNER | FIELD | CONSTR | <a
href="#method_summary">METHOD</a></td>
<td valign="top" class="NavBarCell3">DETAIL:
FIELD | CONSTR | <a href=
"#method_detail">METHOD</a></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->
<hr />
<p><small><a rel='Copyright' href=
'http://www.w3.org/Consortium/Legal/ipr-notice\#Copyright'>Copyright</a>
© 2002 <a href='http://www.w3.org/'><abbr title=
'World Wide Web Consortium'>W3C</abbr></a><sup>®</sup> (<a
href='http://www.lcs.mit.edu/'><abbr title=
'Massachusetts Institute of Technology'>MIT</abbr></a>, <a href=
'http://www.inria.fr/'><abbr lang='fr' xml:lang="fr" title=
'Institut National de Recherche en Informatique et Automatique'>INRIA</abbr></a>,
<a href='http://www.keio.ac.jp/'>Keio</a>), All Rights Reserved.
W3C <a href=
'http://www.w3.org/Consortium/Legal/ipr-notice\#Legal_Disclaimer'>liability</a>,
<a href=
'http://www.w3.org/Consortium/Legal/ipr-notice\#W3C_Trademarks'>trademark</a>,
<a rel='Copyright' href=
'http://www.w3.org/Consortium/Legal/copyright-documents'>document
use</a> and <a rel='Copyright' href=
'http://www.w3.org/Consortium/Legal/copyright-software'>software
licensing</a> rules apply. Your interactions with this site are in
accordance with our <a href=
'http://www.w3.org/Consortium/Legal/privacy-statement\#Public'>public</a>
and <a href=
'http://www.w3.org/Consortium/Legal/privacy-statement\#Members'>Member</a>
privacy statements.</small></p>
</body>
</html>
|