Rule space() { return ZeroOrMore(AnyOf(" \t\f")); }
Rule functionOrFieldList() { return Sequence(push(new LinkedList()), functionOrFieldOrString(), ZeroOrMore(COMMA, functionOrFieldOrString()), push(WikittyQueryFunction.createFusionIfNeeded((List)pop()))); } Rule functionOrFieldOrString() {
Rule containsOne() { Var<List<ConditionValue>> elems = new Var<List<ConditionValue>>(new LinkedList<ConditionValue>()); return Sequence(field(), push(match()), space(), EQUALS, space(), CURLY_BRACKET_OPEN, space(), value(), elems.get().add((ConditionValue)pop()), space(), ZeroOrMore(COMMA, space(), value(), elems.get().add((ConditionValue)pop()), space()), CURLY_BRACKET_CLOSE, push(new ContainsOne(toElement(pop().toString()), elems.get()))); } Rule select() {
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 StringLiteralSimple() { return Sequence( LITERAL_OPEN_SIMPLE, ZeroOrMore( FirstOf( EscapeSimple(), Sequence(TestNot(AnyOf("\r\n\\"+LITERAL_CLOSE_SIMPLE)), ANY) ) ).suppressSubnodes(), LITERAL_CLOSE_SIMPLE ); }
Rule StringLiteralDouble() { return Sequence( LITERAL_OPEN_DOUBLE, ZeroOrMore( FirstOf( EscapeDouble(), Sequence(TestNot(AnyOf("\r\n\\"+LITERAL_CLOSE_DOUBLE)), ANY) ) ).suppressSubnodes(), LITERAL_CLOSE_DOUBLE ); }
Rule or() { return Sequence(and(), ZeroOrMore(space(), icOR, space(), and(), push(new Or((Condition)pop(1), (Condition)pop())))); }
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 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())))); }