public Rule Query() {
return FirstOf(
Sequence(Db(), Separator(), Collection()),
JsonObject()
);
}
public Rule Db() {
return String("db");
}
@SuppressWarnings("InfiniteRecursion")
public Rule Collection() {
return FirstOf(TestNot(Operation()), Sequence(Separator(), Collection()));
}
public Rule Operation() {
return FirstOf(
Find(),
FindOne()
);
}
public Rule Find() {
return Sequence(
String("find"),
String("("),
JsonObject(),
String(")")
);
}
public Rule Separator() {
return Sequence(ZeroOrMore(WhiteSpace()), '.', ZeroOrMore(WhiteSpace()));
}
public Rule WhiteSpace() {
return OneOrMore(AnyOf(" \t\r\f\n"));
}