use of de.prob.core.sablecc.parser.Parser in project probparsers by bendisposto.
the class ProBResultParser method parse.
public static Start parse(final String prologAnswer) throws ResultParserException {
if (prologAnswer.length() == 0)
throw new ResultParserException("Received empty Result", null);
final PushbackReader codeReader = new PushbackReader(new StringReader(prologAnswer), prologAnswer.length());
final Lexer lexer = new Lexer(codeReader);
final Parser parser = new Parser(lexer);
Start parseResult = null;
try {
parseResult = parser.parse();
} catch (final ParserException e) {
String message = "Internal Error while parsing ProB answer. This ist most likely a bug in the Result-Parser. String was: '" + prologAnswer + "'. Last Token was '" + e.getToken() + "': " + e.getLocalizedMessage();
throw new ResultParserException(message, e);
} catch (final LexerException e) {
String message = "Internal Error while parsing ProB answer. This ist most likely a bug in the Result-Parser String was: '" + prologAnswer + "': " + e.getLocalizedMessage();
throw new ResultParserException(message, e);
} catch (final IOException e) {
String message = "Internal Error while parsing ProB answer. This ist most likely a bug in the Result-Parser String was: " + prologAnswer + "': " + e.getLocalizedMessage();
throw new ResultParserException(message, e);
}
return parseResult;
}
Aggregations