use of com.twosigma.beakerx.symjamma.output.MarkdownNotebookOutput in project symja_android_library by axkr.
the class SymjaMMACodeRunner method interpreter.
public Object interpreter(ExprEvaluator fEvaluator, OutputFormFactory fOutputFactory, final String inputExpression) {
IExpr result;
final StringWriter buf = new StringWriter();
try {
String trimmedInput = inputExpression.trim();
if (trimmedInput.length() >= 4 && trimmedInput.charAt(0) == '/') {
Object meta = symjammaEvaluator.metaCommand(this, trimmedInput);
if (meta != null) {
return meta;
}
}
if (symjammaEvaluator.fSeconds <= 0) {
result = fEvaluator.eval(inputExpression);
} else {
result = fEvaluator.evaluateWithTimeout(inputExpression, symjammaEvaluator.fSeconds, TimeUnit.SECONDS, true, new EvalControlledCallable(fEvaluator.getEvalEngine()));
}
if (result != null) {
if (result.equals(S.Null)) {
return "Null";
} else {
return result;
}
}
} catch (final Exception e) {
LOGGER.error("SymjaMMACodeRunner.interpreter() failed", e);
}
return new MarkdownNotebookOutput(buf.toString());
}
Aggregations