Previously, if the last character was `'` parsing would fail: from `abc'`
it would produce the literal `'''abc''''`, which has one too many
unescaped single quote at the end.
This also fixes the issue for solo `'''`, where before it would produce
`''''\\'''''`, again with one too many single quote at the end.
I added tests for both cases.