Cope with extraneous whitespace in sexp reader

This commit is contained in:
Tony Garnock-Jones 2011-01-12 12:32:42 -05:00
parent 4df94ffe40
commit 074fd181c9
1 changed files with 31 additions and 25 deletions

View File

@ -81,6 +81,7 @@ public class SexpReader {
}
public Object _read(int c) throws IOException {
while (true) {
switch (c) {
case -1:
return null;
@ -103,8 +104,13 @@ public class SexpReader {
default:
if (Character.isDigit(c)) {
return new SexpBytes(_readSimpleString(c - '0'));
} else if (Character.isWhitespace(c)) {
// Skip harmless (?) whitespace
c = _input.read();
continue;
} else {
throw new SexpSyntaxError("Unexpected character");
throw new SexpSyntaxError("Unexpected character: " + c);
}
}
}
}