Rewrite ParseTreeMapWriter to generate better SourceMap entries.

We were missing the endings of trees. Fixes #766.