Improve parser error messages by removing some backtracking

Fixes #800. Includes a test (`test038` is already taken by another #806) and a little cleanup in the code.

The tests pass, the stdlib builds.