DRY and generally reduce code in scanPunctuator function.

Performance impact is negligible.