Get PathFilter working by hooking it up to the JS regex rewriter. Refs bug 1030313.

You should now be able to fire up test_basic and run path queries, complete with globs.

* All of test_basic passes except test_structural_and, which awaits a working `function:` filter.
* We introduce a new exception BadQuery, which filters can use to complain about user errors that keep the query from running. In a later commit, we'll catch this and display it instead of 500ing.