Made a minor grammar fix, and reworked location steps slightly so expressions like
$doc[pred] work (assuming $doc is bound to a node-set obviously).
Everytime I find a problem in the grammar, which actually isn't very often at all, I give thanks to the pragmatic programming Gods that I used Spirit rather than rolling my own parser. In this case, I'd transcribed
FilterExpr ::= PrimaryExpr | FilterExpr Predicate
after eliminiating right-recursion as
FilterExpr = PrimaryExpr >> *(Predicate >> PrimaryExpr);
FilterExpr = PrimaryExpr >> *Predicate;.
Time to fix - about 30 seconds. Time to fix if I'd hand-rolled - don't even want to think about it :)