public static void checkLength(int len, ItemList list, String msg) { if ( list.size() == len ) return ; if ( msg == null ) msg = "Wrong number of arguments: "+len+"/"+list.size()+" : "+list.shortString() ; else msg = msg+" : "+list.shortString() ; broken(list, msg) ; }
public static void checkLength(int len, ItemList list, String msg) { if ( list.size() == len ) return ; if ( msg == null ) msg = "Wrong number of arguments: "+len+"/"+list.size()+" : "+list.shortString() ; else msg = msg+" : "+list.shortString() ; broken(list, msg) ; }
public static void checkLengthAtLeast(int len, ItemList list, String msg) { if ( list.size()>= len ) return ; if ( msg == null ) msg = "Too few arguments: want > "+len+" :got : "+list.size()+" : "+list.shortString() ; else msg = msg+" : "+list.shortString() ; broken(list, msg) ; }
public static void checkLengthAtLeast(int len, ItemList list, String msg) { if ( list.size()>= len ) return ; if ( msg == null ) msg = "Too few arguments: want > "+len+" :got : "+list.size()+" : "+list.shortString() ; else msg = msg+" : "+list.shortString() ; broken(list, msg) ; }
public static void broken(ItemLocation location, String msg, ItemList list) { msg = msg(location, msg) ; System.err.println(msg+": "+list.shortString()) ; exception(msg) ; }
public static void broken(ItemLocation location, String msg, ItemList list) { msg = msg(location, msg) ; System.err.println(msg+": "+list.shortString()) ; exception(msg) ; }
public static void checkLength(int len1, int len2, ItemList list, String msg) { if ( list.size() >= len1 && list.size() <= len2 ) return ; if ( msg == null ) msg = "Wrong number of arguments: ("+len1+"-"+len2+")/"+list.size()+" : "+list.shortString() ; else msg = msg+" : "+list.shortString() ; broken(list, msg) ; }
public static void checkLength(int len1, int len2, ItemList list, String msg) { if ( list.size() >= len1 && list.size() <= len2 ) return ; if ( msg == null ) msg = "Wrong number of arguments: ("+len1+"-"+len2+")/"+list.size()+" : "+list.shortString() ; else msg = msg+" : "+list.shortString() ; broken(list, msg) ; }
@Override public Expr make(ItemList list) { BuilderLib.checkLength(1, list, "Broken syntax: "+list.shortString()) ; return new ExprAggregator(null, AggregatorFactory.createAggNull()) ; } };
public static void checkTag(ItemList list, String tag) { if ( list.size() == 0 ) broken(list, "Empty list") ; if ( ! list.get(0).isSymbolIgnoreCase(tag) ) broken(list, "List does not start ("+tag+ "...) : "+list.shortString()) ; }
public static void checkTag(ItemList list, String tag) { if ( list.size() == 0 ) broken(list, "Empty list") ; if ( ! list.get(0).isSymbolIgnoreCase(tag) ) broken(list, "List does not start ("+tag+ "...) : "+list.shortString()) ; }
public String shortString() { if ( isSymbol() ) return getSymbol(); if ( isNode() ) return FmtUtils.stringForNode(getNode()); return getList().shortString() ; } }
public String shortString() { if ( isSymbol() ) return getSymbol(); if ( isNode() ) return FmtUtils.stringForNode(getNode()); return getList().shortString() ; } }
@Override public final Expr make(ItemList list) { ItemList x = list.cdr(); // drop "sum" boolean distinct = startsWithDistinct(x) ; if ( distinct ) x = x.cdr(); BuilderLib.checkLength(1, x, "Broken syntax: "+list.shortString()) ; // (sum ?var) Expr expr = buildExpr(x.get(0)) ; return make(distinct, expr) ; }
public final Expr make(ItemList list) { ItemList x = list.cdr(); // drop "sum" boolean distinct = startsWithDistinct(x) ; if ( distinct ) x = x.cdr(); BuilderLib.checkLength(1, x, "Broken syntax: "+list.shortString()) ; // (sum ?var) Expr expr = buildExpr(x.get(0)) ; return make(distinct, expr) ; }
public Expr make(final ItemList list) { ItemList x = list.cdr(); // drop "count" boolean distinct = startsWithDistinct(x) ; if ( distinct ) x = x.cdr(); BuilderLib.checkLength(0, 1, x, "Broken syntax: "+list.shortString()) ; Aggregator agg = null ; if ( x.size() == 0 ) agg = AggregatorFactory.createCount(distinct) ; else { Expr expr = BuilderExpr.buildExpr(x.get(0)) ; agg = AggregatorFactory.createCountExpr(distinct, expr) ; } return new ExprAggregator((Var)null, agg) ; } };
@Override public Expr make(final ItemList list) { ItemList x = list.cdr(); // drop "count" boolean distinct = startsWithDistinct(x) ; if ( distinct ) x = x.cdr(); BuilderLib.checkLength(0, 1, x, "Broken syntax: "+list.shortString()) ; Aggregator agg = null ; if ( x.size() == 0 ) agg = AggregatorFactory.createCount(distinct) ; else { Expr expr = BuilderExpr.buildExpr(x.get(0)) ; agg = AggregatorFactory.createCountExpr(distinct, expr) ; } return new ExprAggregator(null, agg) ; } };
return ; throwException("Inconsistent: "+list.shortString(), list) ;
public Expr make(final ItemList list) { ItemList x = list.cdr(); // drop "group_concat" boolean distinct = startsWithDistinct(x) ; if ( distinct ) x = x.cdr(); // Complex syntax: // (groupConcat (separator "string) expr ) if ( x.size() == 0 ) BuilderLib.broken(list, "Broken syntax: "+list.shortString()) ; String separator = null ; if ( x.get(0).isTagged(Tags.tagSeparator)) { ItemList y = x.get(0).getList() ; BuilderLib.checkLength(2, y, "Broken syntax: "+list) ; Node n = y.get(1).getNode() ; if ( ! n.isLiteral() || n.getLiteralDatatype() != null ) BuilderLib.broken(y, "Need string for separator: "+y) ; separator = n.getLiteralLexicalForm() ; x = x.cdr(); } Expr expr = buildExpr(x.get(0)) ; Aggregator agg = AggregatorFactory.createGroupConcat(distinct, expr, separator) ; return new ExprAggregator((Var)null, agg) ; } };
@Override public Expr make(final ItemList list) { ItemList x = list.cdr(); // drop "group_concat" boolean distinct = startsWithDistinct(x) ; if ( distinct ) x = x.cdr(); // Complex syntax: // (groupConcat (separator "string) expr ) if ( x.size() == 0 ) BuilderLib.broken(list, "Broken syntax: "+list.shortString()) ; String separator = null ; if ( x.get(0).isTagged(Tags.tagSeparator)) { // What about ORDERED BY ItemList y = x.get(0).getList() ; BuilderLib.checkLength(2, y, "Broken syntax: "+list) ; Node n = y.get(1).getNode() ; if ( ! n.isLiteral() || n.getLiteralDatatype() != null ) BuilderLib.broken(y, "Need string for separator: "+y) ; separator = n.getLiteralLexicalForm() ; x = x.cdr(); } Expr expr = buildExpr(x.get(0)) ; Aggregator agg = AggregatorFactory.createGroupConcat(distinct, expr, separator, null) ; return new ExprAggregator(null, agg) ; } };