26 lines
622 B
Java
26 lines
622 B
Java
package serene.simple;
|
|
|
|
import java.io.IOException;
|
|
import java.io.PushbackReader;
|
|
|
|
|
|
public class Reader {
|
|
public static Node readNode(PushbackReader inputStream) throws IOException {
|
|
char c = (char) inputStream.read();
|
|
inputStream.unread(c);
|
|
|
|
if (c == "(") {
|
|
return readList(inputStream);
|
|
}
|
|
else if (Character.isDigit(c)) {
|
|
return readNumber(inputStream);
|
|
}
|
|
else if (c == ")") {
|
|
throw new IllegalArgumentException("Unmatch paranthesis.")
|
|
}
|
|
else {
|
|
return readSymbol(inputStream);
|
|
}
|
|
}
|
|
}
|