util: Fix two corner-cases in boolean term quoting function

Previously, make_boolean_term did not quote empty boolean terms or
boolean terms that started with '('.  These cases are incompatible
with Xapian: empty terms cannot be omitted, and boolean terms that
start with '(' trigger an alternate term quoting syntax.

Fix this by quoting empty terms and terms that contain '('.
test: Add broken test for Emacs boolean term escaping

The current term escaper gets most of these right, but fails to escape
things containing Unicode "fancy quotes" or things containing
non-whitespace control characters.
emacs: Use whitelist instead of blacklist for term escaping

Previously, the term escaper used a blacklist of characters that
needed escaping.  This blacklist turned out to be somewhat incomplete;
for example, it did not contain non-whitespace ASCII control
characters or Unicode "fancy quotes", both of which do require the
term to be escaped.

Switch to a whitelist of characters that are definitely safe to leave
unquoted.  This fixes the broken test introduced by the previous
patch.
Query parser PEG and parser generator

This is the initial hacked together PEG and parser generator.  It's
quite simple, but could be simpler.  There's also too much code in the
generic parser generator that's specific to user actions.  Despite
this, backtracking causes leaks from user-action side effects.
Attempt at separating action execution from parsing

This is an aborted attempt at recording an action tree at parse time
and only running actions post-parse to avoid problems with
backtracking user actions.  Maintaining this action tree is actually
really hairy and breaks a lot of simplifying assumptions that kept the
parser generator simple.  While the benefits are nice theoretically,
it seems like overkill in a grammar with no non-trivial backtracking.

This also comments the grammar.
Eschew action tree for user-provided state type with save/restore

This puts more a little burden on the user-provided code for the
benefit of greatly simplifying the generic parser code.  Since I am
writing both, it's a net win.

As a result, all productions return bool now, which eliminates all of
the code related to type handling and propagation.
Make parsing expressions inspectable objects

The grammar can now be traversed generically.  This also enables some
additional code reuse, so most of the operator implementations are a
little simpler.
Generate parsing functions via direct traversal of PExpr tree

This is simpler than the previous demand-driven queue of functions and
makes it easy to generate nice functions names based on rule names.
Declare a parser entry point and external interface
Take multiple arguments to Grammar.__call__ and simplify uses
Some grammar corrections and clarifications

I'm starting to think that PEG's backtrack-happy style is less suited
to this grammar (perhaps many grammars) than a predictive parser would
be.  PEG also makes error handling quite tricky.
Aborted attempt at switching to four-value predictive parsing combinators

For all but the 'frag' rule, we only need one literal of lookahead to
parse the query grammar; everywhere else the PEG backtracking is
wasteful.  Furthermore, in PEG, several of the rules require explicit
negative lookaheads to force ordered choice branches to be exclusive.
Given these things, I figured a predictive formalism might work
better, so this patch converts the generator to a Partridge and Wright
four-value predictive combinator parser style (like Haskell's Parsec).
It also adds the beginnings of error reporting, since that's one of
the purported benefits of four-value parsers.

While this does slightly simplify the grammar (and would also
eliminate the user backtracking support for this particular grammar,
though I didn't do that), it significantly complicates both the
descriptions and implementations of the parser operators, since they
now have to deal with 4^n possible result combinations, rather than
2^n.
Revert "Aborted attempt at switching to four-value predictive parsing combinators"

This reverts commit fa0bcb97b96f366b0822f9ce2d3d85e46dfbff83.

Going back to a PEG to try explicit cuts and right-most error
reporting as suggested in Bryan Ford's master's thesis.
Implement explicit cut support

Cuts were designed to control space use, but they're also a useful
grammar abstraction to commit to a particular grammar branch without
the confusing composition properties of LL(1) predictive parser
combinators like four-value parsers like Partridge and Wright parsers
or Haskell's Parsec.
Rename ZeroPlus/OnePlus to Many/Many1

Inspired by Parsec.
Basic rightmost error reporting support
Compound -> group
Integrate parser generator into lib build; some cleanup
qparser fixes for test
test: Query parser testing framework and basic tests.

The query parser test is implemented as a separate binary that calls
directly in to the lexer, parser, and generator to make it easy to
isolate test failures.