first run at rewriting parser, passes all current tests