A complete reworking of the parser

still very much a work-in-progress.