@Override public NodeValue exec(NodeValue v) { Node n = v.asNode(); if (!n.isBlank()) throw new ExprEvalException("bnode: not a blank node"); NodeValue nv = NodeValue.makeString(n.getBlankNodeId().getLabelString()); return nv; }
public static void evalPrint(Expr expr, Binding binding) { try { NodeValue r = eval(expr, binding); // System.out.println(r.asQuotedString()) ; Node n = r.asNode(); String s = FmtUtils.stringForNode(n); System.out.println(s); } catch (ExprEvalException ex) { System.out.println("Exception: " + ex.getMessage()); return; } catch (ExprBuildException ex) { System.err.println("Build exception: " + ex.getMessage()); return; } }
public static String joinList(List<Expr> args, String sep) { if (args == null) return "<<Null list>>"; if (args.size() == 0) return "<<Empty list>>"; StringBuilder s = new StringBuilder(); boolean first = true; for (Expr ex : args) { if (!first) s.append(sep); // Values are printed withquoting. if (ex instanceof NodeValue) { NodeValue nv = (NodeValue) ex; s.append(nv.asQuotedString()); } else s.append(ex.toString()); first = false; } return s.toString(); }
@Override public NodeValue exec(NodeValue v) { return NodeValue.makeDouble(1d / v.getDouble()); }
@Override protected NodeValue evalSpecial(Binding binding, FunctionEnv env) { return NodeValue.booleanReturn(checkAccess(binding)); }
@Override public NodeValue exec(NodeValue v) { return NodeValue.makeDouble(Math.atan(v.getDouble())); }
public static Expr nodeToExpr(Node n) { if (n.isVariable()) return new ExprVar(n); return NodeValue.makeNode(n); }
public static NodeValue parseNodeValue(String s) { Node n = NodeFactoryExtra.parseNode(s); NodeValue nv = NodeValue.makeNode(n); return nv; }