Framework for better lexical error messages.

Requires a one-line change to the generated tokeniser to take effect.