Skip to content

Commit 7136120

Browse files
committed
Avoid throwing IOExceptions
1 parent 5d73393 commit 7136120

File tree

7 files changed

+416
-261
lines changed

7 files changed

+416
-261
lines changed

examples/GUIParsing/TokenMgrVersion/src/main/java/CharCollector.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public class CharCollector implements CharStream {
4747

4848
protected boolean trackLineColumn = true;
4949
protected int tabSize = 1;
50+
private char nextChar;
5051

5152
/** Puts a character into the buffer. Called by the GUI. */
5253
public final synchronized void put(char c) {
@@ -207,4 +208,41 @@ public int getTabSize() {
207208
public void setTabSize(int i) {
208209
tabSize = i;
209210
}
211+
212+
/**
213+
* Returns next character.
214+
*
215+
* @return next character in the input
216+
*/
217+
public char getNextChar() {
218+
return nextChar;
219+
}
220+
221+
/**
222+
* Checks next character.
223+
*
224+
* @return whether next character is available
225+
*/
226+
public boolean hasNextChar() {
227+
try {
228+
nextChar = readChar();
229+
return true;
230+
} catch (java.io.IOException ex) {
231+
return false;
232+
}
233+
}
234+
235+
/**
236+
* Checks next character and marks new token.
237+
*
238+
* @return whether next character is available
239+
*/
240+
public boolean hasNextToken() {
241+
try {
242+
nextChar = BeginToken();
243+
return true;
244+
} catch (java.io.IOException ex) {
245+
return false;
246+
}
247+
}
210248
}

0 commit comments

Comments
 (0)