Add parse error messages

Those messages are very primitives but still much more helpful than just "parse error". In particular, they work well when a token has been omitted (e.g. missing `then` or `[]` was used instead of `of`).

Since implementing this had such a bad impact on performance, I also attached two performance patches to help balance it out.

(Oh, I just realized I accidentally mixed up a line in two commits… that's what I get for manually splitting a set of changes in multiple commits after the facts.)