Regexp parser and generator

skip at pobox.com skip at pobox.com
Tue Nov 4 14:56:18 EST 2008


    George> Is there any package that parses regular expressions and returns
    George> an AST ?

Maybe not directly, but this might provide a starting point for building
such a beast:

    >>> import re
    >>> re.compile("[ab]", 128)
    in
      literal 97
      literal 98
    <_sre.SRE_Pattern object at 0x47b7a0>
    >>> re.compile("ab*c[xyz]", 128)
    literal 97
    max_repeat 0 65535
      literal 98
    literal 99
    in
      literal 120
      literal 121
      literal 122
    <_sre.SRE_Pattern object at 0x371f90>

Skip



More information about the Python-list mailing list