This section of the pyparsing wiki is open to public edits and contributions.

  • Here is a SQL parser that generates graphviz commands to graphically display tables and show foreign key links.
  • Here is a regex inverter that parses simple regular expressions, and creates a generator structure to generate strings that match the regex. Here are the test cases this inverter can handle:
[A-E]
[A-D]*
[A-D]{3}
X[A-C]{3}Y
X[A-C]{3}\(
X\d
foobar\d\d
foobar{2}
fooba[rz]{2}
(foobar){2}
([01]\d)|(2[0-5])
([01]\d\d)|(2[0-4]\d)|(25[0-5])
[A-C]{1,2}
[A-C]{0,3}
[A-C]\s[A-C]\s[A-C]
[A-C]\s?[A-C][A-C]
[A-C]\s([A-C][A-C])
[A-C]\s([A-C][A-C])?
[A-C]{2}\d{2}

To use this inverter, import the invert method, and call it as a generator, as in:
for s in invert("[A-Z]{3}\d{3}"):
 print s



Marek Kubica suggested a factory class to help manage setWhitespace calls without having to modify the global whitespace characters defined in the ParserElement class using setDefaultWhitespace. This suggestion evolved into the following wrapper class:
class SetWhitespace(object):
    def __init__(self, whitespacechars):
        self.whitespacechars = whitespacechars
 
    def __call__(self,pyparsing_expr):
        pyparsing_expr.setWhitespace(self.whitespacechars)
        return pyparsing_expr
 
 
noNLskipping = SetWhitespace(' \t\r')
word = noNLskipping(Word(alphas))

Any comments? Should I just add this to pyparsing?



pyparsing_helper is a new GUI for troubleshooting your pyparsing grammars.

http://pypi.python.org/pypi/pyparsing_helper

You can easy_install it with
easy_install pyparsing_helper

Similarly, reinteract is a general-purpose GUI interactive Python session that can be used to tweak pyparsing grammars in development, and is a more sophisticated tool overall.