1. Georg Brandl
  2. pygments-main
  3. Issues
Issue #347 resolved

Trace mode for lexer development

thatch
created an issue

What do you think about a new option that enabled a super-verbose mode to pygmentize so you can see what is being matched and where the slowdowns are?

I have a patch at http://timhatch.com/ex/2008/07/pygments-debug-mode.diff which I personally use, but I'm thinking that it should at least take a trace-filename (in case I want to send to another tty).

Comments (10)

  1. gbrandl
    +    while opts.pop('-v', None) is not None:
    +        pygments.lexer.VERBOSITY = 3
    

    This was probably meant to be `VERBOSITY += 1`...

    What I'm not happy about is the lots of extra tests and time calls in the RegexLexer. Benchmarks showing that they're not doing any harm to lexing speed would be nice. (A first optimization would be to make VERBOSITY a local in that function.)

    Otherwise, it would perhaps be possible to always set VERBOSITY before importing lexer.py, and doing conditional method definitions in RegexLexer.

  2. Log in to comment