I have a grammar (a basic language) that have ^ as an operator. The generated code for the operators on the pygments code include this symbol unescaped, and the generated highlighter is locking at 100% cpu usage because of this. Escaping the symbol solves the lock.
Other symbols are being correctly escaped, it appears that is only ^ that is not being escaped.