use of com.github.anba.es6draft.parser.ParserEOFException in project es6draft by anba.
the class Repl method read.
/**
* REPL: Read
*
* @param realm
* the realm instance
* @param line
* the current line
* @return the parsed script node or {@coden null} if the end of stream has been reached
*/
private com.github.anba.es6draft.ast.Script read(Realm realm, int[] line) {
StringBuilder sourceBuffer = new StringBuilder();
for (String prompt = PROMPT; ; prompt = "") {
String s = console.readLine(prompt);
if (s == null) {
return null;
}
sourceBuffer.append(s).append('\n');
String sourceCode = sourceBuffer.toString();
Source source = new Source(Paths.get(".").toAbsolutePath(), "typein", line[0]);
try {
com.github.anba.es6draft.ast.Script script = parse(realm, source, sourceCode);
line[0] += script.getEndLine() - script.getBeginLine();
return script;
} catch (ParserEOFException e) {
continue;
} catch (ParserException e) {
throw new ParserExceptionWithSource(e, source, sourceCode);
}
}
}
Aggregations