Rule function() { Var<String> alias = new Var<String>(); return Sequence(OneOrMore(FirstOf(field(), AnyOf("#"))), push(match()), BRACKET_OPEN, push(new LinkedList()), Optional(functionOrFieldOrString(), ZeroOrMore(COMMA, functionOrFieldOrString())), BRACKET_CLOSE, Optional(alias(alias)), push(WikittyQueryFunction.create(pop(1).toString(), alias.get(), (List)pop()))); }
Rule containsAll() { Var<List<ConditionValue>> elems = new Var<List<ConditionValue>>(new LinkedList<ConditionValue>()); return Sequence(field(), push(match()), space(), EQUALS, space(), SQUARE_BRACKET_OPEN, space(), value(), elems.get().add((ConditionValue)pop()), space(), ZeroOrMore(COMMA, space(), value(), elems.get().add((ConditionValue)pop()), space()), SQUARE_BRACKET_CLOSE, push(new ContainsAll(toElement(pop().toString()), elems.get()))); } Rule containsOne() {
Rule stringFunction() { Var<String> alias = new Var<String>(); return Sequence(valueText(), Optional(alias(alias)), push(new FunctionValue(alias.get(), ((ConditionValueString)pop()).getValue() ))); }
Rule limit() { return Optional(space(), icLIMIT, FirstOf(EQUALS, space()), OneOrMore(AnyOf("1234567890")), push(((WikittyQuery)pop()).setLimit(toInt(match()))) ); }
Rule depth() { return Optional(space(), icDEPTH, FirstOf(EQUALS, space()), OneOrMore(AnyOf("1234567890")), push(((WikittyQuery)pop()).setWikittyFieldSearchDepth(toInt(match()))) ); }
Rule select() { return Sequence(icSELECT, space(), functionOrFieldList() /*, field(), push(match())*/, space(), FirstOf(Sequence(icWHERE, space(), term()), empty()), push(new Select(((WikittyQueryFunction)pop(1)), (Condition)pop()))); }
Rule and() { return Sequence(term(), ZeroOrMore( // when no AND or OR is used, AND is default // don't change order of FirstOf, this order is important FirstOf(Sequence(space(), icAND, space()), Sequence(space(), TestNot(icOR))), term(), push(new And((Condition)pop(1), (Condition)pop())))); }