Get out of the infinite loop by allowing to scan backwards when the current token is a comment.

This fixes issue #9002.