protected E_Call(String sym, ExprList args) { super(sym, args) ; if (args.size() == 0) { identExpr = null; } else { identExpr = args.get(0); argExprs = args.getList().subList(1,args.size()) ; } }
@Override public Expr getArg(int i) { i = i-1 ; if ( i >= args.size() ) return null ; return args.get(i) ; }
protected E_OneOfBase(String name, ExprList args) { super(name, args) ; this.expr = args.get(0) ; this.possibleValues = args.tail(1) ; }
protected E_OneOfBase(String name, ExprList args) { super(name, args) ; this.expr = args.get(0) ; this.possibleValues = args.tail(1) ; }
@Override public Expr getArg(int i) { i = i-1 ; if ( i >= args.size() ) return null ; return args.get(i) ; }
@Override protected Expr copy(ExprList newArgs) { if ( newArgs.size() == 0 ) return new E_BNode() ; else return new E_BNode(newArgs.get(0)) ; } }
@Override protected Expr copy(ExprList newArgs) { if ( newArgs.size() == 0 ) return new E_BNode() ; else return new E_BNode(newArgs.get(0)) ; } }
public NodeValue exec(Binding binding, ExprList args, String uri, FunctionEnv env) { if ( myArgs != args ) throw new ARQInternalErrorException("matches: Arguments have changed since checking") ; Expr expr = args.get(0) ; E_Regex regexEval = regex ; if ( regexEval == null ) { Expr e1 = args.get(1) ; Expr e2 = null ; if ( args.size() == 3 ) e2 = args.get(2) ; String pattern = e1.eval(binding, env).getString() ; String flags = (e2==null)?null : e2.eval(binding, env).getString() ; regexEval = new E_Regex(expr, pattern, flags) ; // Cache if the pattern is fixed and the flags are fixed or non-existant if ( e1 instanceof NodeValue && ( e2 == null || e2 instanceof NodeValue ) ) regex = regexEval ; } NodeValue nv = regexEval.eval(binding, env) ; return nv ; }
private static void outputTail(IndentedWriter out, ExprList exprs, SerializationContext sCxt) { for ( int i = 0 ; i < exprs.size() ; i++ ) { out.print(" ") ; output(out, exprs.get(i), sCxt) ; } out.print(")") ; }
@Override public NodeValue exec(Binding binding, ExprList args, String uri, FunctionEnv env) { if ( myArgs != args ) throw new ARQInternalErrorException("matches: Arguments have changed since checking") ; Expr expr = args.get(0) ; E_Regex regexEval = regex ; if ( regexEval == null ) { Expr e1 = args.get(1) ; Expr e2 = null ; if ( args.size() == 3 ) e2 = args.get(2) ; String pattern = e1.eval(binding, env).getString() ; String flags = (e2==null)?null : e2.eval(binding, env).getString() ; regexEval = new E_Regex(expr, pattern, flags) ; // Cache if the pattern is fixed and the flags are fixed or non-existant if ( e1 instanceof NodeValue && ( e2 == null || e2 instanceof NodeValue ) ) regex = regexEval ; } NodeValue nv = regexEval.eval(binding, env) ; return nv ; }
private static void outputTail(IndentedWriter out, ExprList exprs, SerializationContext sCxt) { for ( int i = 0 ; i < exprs.size() ; i++ ) { out.print(" ") ; output(out, exprs.get(i), sCxt) ; } out.print(")") ; }
/** Processes unevaluated arguments */ @Override public NodeValue exec(Binding binding, ExprList args, String uri, FunctionEnv env) { if ( args == null ) // The contract on the function interface is that this should not happen. throw new ARQInternalErrorException("function eval: Null args list") ; if ( args.size() != 1 ) throw new ARQInternalErrorException("function eval: Arg list not of size 1") ; Expr ex = args.get(0) ; try { NodeValue v = ex.eval(binding, env) ; return v ; } catch (ExprEvalException evalEx) { return NodeValue.FALSE ; } }
/** * Builds the expression substituting the arguments given into the base expression to yield the actual expression to evaluate * @throws ExprBuildException Thrown if an expression cannot be generated */ @Override public void build(String uri, ExprList args) { //Substitutes the arguments into the base expression to give the actual expression to evaluate if (uri == null || !uri.equals(this.getUri())) throw new ExprBuildException("Incorrect URI passed to build() call, expected <" + this.getUri() + "> but got <" + uri + ">"); if (this.getArgList().size() != args.size()) throw new ExprBuildException("Incorrect number of arguments for user defined <" + this.getUri() + "> function"); Map<String, Expr> substitutions = new HashMap<String, Expr>(); for (int i = 0; i < this.getArgList().size(); i++) { substitutions.put(this.getArgList().get(i).getVarName(), args.get(i)); } this.actualExpr = ExprTransformer.transform(new ExprTransformSubstitute(substitutions), this.getBaseExpr()); }
/** Processes unevaluated arguments */ public NodeValue exec(Binding binding, ExprList args, String uri, FunctionEnv env) { if ( args == null ) // The contract on the function interface is that this should not happen. throw new ARQInternalErrorException("function eval: Null args list") ; if ( args.size() != 1 ) throw new ARQInternalErrorException("function eval: Arg list not of size 1") ; Expr ex = args.get(0) ; try { NodeValue v = ex.eval(binding, env) ; return v ; } catch (ExprEvalException evalEx) { return NodeValue.FALSE ; } }
public static void output(IndentedWriter out, ExprList exprs, boolean withTag, boolean unlist, SerializationContext sCxt) { if ( exprs.size() == 0 ) { out.print("()") ; return ; } if ( exprs.size() == 1 && unlist ) { output(out, exprs.get(0), sCxt) ; return ; } if ( withTag ) out.print("(exprlist ") ; else out.print("(") ; for ( int i = 0 ; i < exprs.size() ; i++ ) { if ( i != 0 ) out.print(" ") ; output(out, exprs.get(i), sCxt) ; } out.print(")") ; }