chr = super.read();
It uses the read()
method that is inherited
from the parent class BufferedReader
to read a single character from the input stream.
Here is the transducer (scanner) with some pieces missing.
The nextToken()
method is called by the
application program each time it needs another token.
We will fill it in later.
import java.io.*; class WebScanner { MyPushbackReader in; String token; // The current token int ich; // input character as int char ch; // current input character WebScanner ( Reader rdr ) { in = new _____________( rdr ); } private boolean isWhiteSpace( char ch ) { if ( ch == ____ || ch == ____ || ch == ____ || ch == ____ ) return true; else return false; } String nextToken() throws IOException { . . . . . } }
The application supplies the WebScanner
constructor with
a Reader
(usually a FileReader
).
The application should not need to bother with details like pushing
back characters, so it is up to WebScanner
to construct
a MyPushbackReader
.
The isWhiteSpace()
method returns true or false
depending on whether the character is white space or not.
The method is used by the scanner.
(The static method Character.isWhiteSpace()
does the same thing).
Fill in the blue blanks.