diff options
author | Fredrik Lundh <fredrik@pythonware.com> | 2000-07-23 21:46:17 (GMT) |
---|---|---|
committer | Fredrik Lundh <fredrik@pythonware.com> | 2000-07-23 21:46:17 (GMT) |
commit | 8a3ebf8ca87a7d2989148d7c218974ab4235ca5d (patch) | |
tree | 1694bf24acdb9defbf770ad34e1181b84bf17428 /Lib/sre_compile.py | |
parent | 4f1b2081e9dde910048ef679f5afe252023a4031 (diff) | |
download | cpython-8a3ebf8ca87a7d2989148d7c218974ab4235ca5d.zip cpython-8a3ebf8ca87a7d2989148d7c218974ab4235ca5d.tar.gz cpython-8a3ebf8ca87a7d2989148d7c218974ab4235ca5d.tar.bz2 |
-- SRE 0.9.6 sync. this includes:
+ added "regs" attribute
+ fixed "pos" and "endpos" attributes
+ reset "lastindex" and "lastgroup" in scanner methods
+ removed (?P#id) syntax; the "lastindex" and "lastgroup"
attributes are now always set
+ removed string module dependencies in sre_parse
+ better debugging support in sre_parse
+ various tweaks to build under 1.5.2
Diffstat (limited to 'Lib/sre_compile.py')
-rw-r--r-- | Lib/sre_compile.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py index d8d01ea..ef26e1c 100644 --- a/Lib/sre_compile.py +++ b/Lib/sre_compile.py @@ -197,10 +197,11 @@ def _compile(code, pattern, flags): else: emit(ATCODES[av]) elif op is BRANCH: - emit(OPCODES[op]) tail = [] for av in av[1]: + emit(OPCODES[op]) skip = len(code); emit(0) + emit(MAXCODE) # save mark _compile(code, av, flags) emit(OPCODES[JUMP]) tail.append(len(code)); emit(0) @@ -286,11 +287,18 @@ def _compile_info(code, pattern, flags): emit(OPCODES[FAILURE]) code[skip] = len(code) - skip +STRING_TYPES = [type("")] + +try: + STRING_TYPES.append(type(unicode(""))) +except NameError: + pass + def compile(p, flags=0): # internal: convert pattern list to internal format # compile, as necessary - if type(p) in (type(""), type(u"")): + if type(p) in STRING_TYPES: import sre_parse pattern = p p = sre_parse.parse(p, flags) @@ -308,6 +316,8 @@ def compile(p, flags=0): code.append(OPCODES[SUCCESS]) + # print code + # FIXME: <fl> get rid of this limitation! assert p.pattern.groups <= 100,\ "sorry, but this version only supports 100 named groups" |