Discussion:
[Pyparsing] global setDebug feature
Mike Stump
2016-12-31 21:02:56 UTC
Permalink
Sometimes it is annoying to try and figure out which elements need a setDebug() to figure out what went wrong.

It would be nice to do:

ParserElement.setDefaultDebug(True)
...
ParserElement.setDefaultDebug(False)

just like you can do:

ParserElement.setDefaultWhitespaceChars()

Then, I could just put this at the top before parser construction, and there isn't anything I would miss (or, at least, nothing in my source). Pre-built things would still not have debug set, like lineEnd for example; but that's ok.

This more closely matches the feature of yacc/bison debugging, which will spray a ton of detail. Handy when just turn on all debugging, find and fix the issue, then turn it off. Easy to do with a one line change in a larger grammar.
p***@austin.rr.com
2017-01-02 13:03:06 UTC
Permalink
Interesting idea, but it *will* spew just a ton of logging! In fact, it will be mostly gibberish unless you have used setName() throughout your code to give meaningful labels to your grammar expressions. But I'll add it to my "to-do" list for the next release.

-- Paul

Loading...