} else if (ch == '$') {
sp.pos++;
String param = sp.getId();
String val = getParam(param);
if (val == null) {
throw new ParseException("Missing param " + param + " while parsing function '" + sp.val + "'");
}
QParser subParser = subQuery(val, "func");
if (subParser instanceof FunctionQParser) {
((FunctionQParser)subParser).setParseMultipleSources(true);
}
Query subQuery = subParser.getQuery();
if (subQuery instanceof FunctionQuery) {
valueSource = ((FunctionQuery) subQuery).getValueSource();
} else {
valueSource = new QueryValueSource(subQuery, 0.0f);
}
/***
// dereference *simple* argument (i.e., can't currently be a function)
// In the future we could support full function dereferencing via a stack of ValueSource (or StringParser) objects
ch = val.length()==0 ? '\0' : val.charAt(0);
if (ch>='0' && ch<='9' || ch=='.' || ch=='+' || ch=='-') {
QueryParsing.StrParser sp = new QueryParsing.StrParser(val);
Number num = sp.getNumber();
if (num instanceof Long) {
valueSource = new LongConstValueSource(num.longValue());
} else if (num instanceof Double) {
valueSource = new DoubleConstValueSource(num.doubleValue());
} else {
// shouldn't happen
valueSource = new ConstValueSource(num.floatValue());
}
} else if (ch == '"' || ch == '\'') {
QueryParsing.StrParser sp = new QueryParsing.StrParser(val);
val = sp.getQuotedString();
valueSource = new LiteralValueSource(val);
} else {
if (val.length()==0) {
valueSource = new LiteralValueSource(val);
} else {
String id = val;
SchemaField f = req.getSchema().getField(id);
valueSource = f.getType().getValueSource(f, this);
}
}
***/
} else {
String id = sp.getId();
if (sp.opt("(")) {
// a function... look it up.
ValueSourceParser argParser = req.getCore().getValueSourceParser(id);
if (argParser==null) {
throw new ParseException("Unknown function " + id + " in FunctionQuery(" + sp + ")");
}
valueSource = argParser.parse(this);
sp.expect(")");
}
else {