WIP Continued the factorization of code for highlighting.

I also added some debugging code (could be improved, or even deleted later), that permitted me to quickly fix an infinite loop in the Key rule. A wrong loop termination condition.