Validate and normalise query in separate phase

This commit moves query normalisation (add implicit $and and so
on) and validation to a step preceeding the SQL query and
post-hoc matching step. Previously, both the SQL querying and
post-hoc matching step carried out these functions themselves.

The query is now validated prior to starting the query process,
thereby bailing earlier for invalid code and allowing the SQL and
match code to be simplified as they can assume both valid and
normalised code.

The phase is implemented in the CDTQQueryValidator class.

Fixes #30