Path tmpFile = FileCommands.newTempFile("aterm");
FileCommands.writeToFile(tmpFile, toplevelDecl.toString());
log.log("next toplevel declaration parsed: " + tmpFile, Log.PARSE);
return new IncrementalParseResult(toplevelDecl, rest);
} catch (Exception e) {
// if (!recovery)
// throw new SGLRException(driver.getParser(), "parsing failed", e);
String msg = e.getClass().getName() + " " + e.getLocalizedMessage() != null ? e.getLocalizedMessage() : e.toString();
if (!(e instanceof StrategoException) && !(e instanceof ParseException) && (!(e instanceof SGLRException) || (e instanceof FilterException)))
e.printStackTrace();
else
log.logErr(msg, Log.DETAIL);
if (!treeBuilder.isInitialized()) {
SGLR parser = driver.getParser();
if (parser == null && (e instanceof SGLRException))
parser = ((SGLRException) e).getParser();
if (parser == null)
return new IncrementalParseResult(ATermCommands.factory.makeString(input), "");
treeBuilder.initializeTable(parser.getParseTable(), 0, 0, 0);
treeBuilder.initializeInput(input, null);
}
else if (treeBuilder.getTokenizer().getStartOffset() > start) {
IToken token = treeBuilder.getTokenizer().getTokenAtOffset(start);
((RetractableTokenizer) treeBuilder.getTokenizer()).retractTo(token.getIndex());
treeBuilder.setOffset(start);
}
IToken right = treeBuilder.getTokenizer().makeToken(start + input.length() - 1, IToken.TK_STRING, true);
IToken left = treeBuilder.getTokenizer().getTokenAtOffset(start);
treeBuilder.getTokenizer().makeToken(treeBuilder.getTokenizer().getStartOffset() - 1, IToken.TK_EOF, true);
IStrategoTerm term = ATermCommands.factory.makeString(input);
ImploderAttachment.putImploderAttachment(term, false, "String", left, right);
if (!lookahead)
driver.setErrorMessage(term, msg);
return new IncrementalParseResult(term, "");
} finally {
log.endTask();
}
}