summaryrefslogtreecommitdiffstats
path: root/Lib/sre_compile.py
diff options
context:
space:
mode:
authorFredrik Lundh <fredrik@pythonware.com>2000-07-03 21:31:48 (GMT)
committerFredrik Lundh <fredrik@pythonware.com>2000-07-03 21:31:48 (GMT)
commit72b82ba16dea929b3fa9db5208b2353e8449c2d5 (patch)
treecbb66296997943c1a5849404401a4840a00a8ec5 /Lib/sre_compile.py
parent6f013982366154ce570f69b6117dbcc6b1d5d89a (diff)
downloadcpython-72b82ba16dea929b3fa9db5208b2353e8449c2d5.zip
cpython-72b82ba16dea929b3fa9db5208b2353e8449c2d5.tar.gz
cpython-72b82ba16dea929b3fa9db5208b2353e8449c2d5.tar.bz2
- fixed grouping error bug
- changed "group" operator to "groupref"
Diffstat (limited to 'Lib/sre_compile.py')
-rw-r--r--Lib/sre_compile.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py
index 701b267..828b170 100644
--- a/Lib/sre_compile.py
+++ b/Lib/sre_compile.py
@@ -148,18 +148,25 @@ def _compile(code, pattern, flags):
skip = len(code); emit(0)
emit(av[0])
emit(av[1])
+ mark = MAXCODE
+ if av[2][0][0] == SUBPATTERN:
+ # repeated subpattern
+ gid, foo = av[2][0][1]
+ if gid:
+ mark = (gid-1)*2
+ emit(mark)
_compile(code, av[2], flags)
emit(OPCODES[SUCCESS])
code[skip] = len(code) - skip
elif op is SUBPATTERN:
- group = av[0]
- if group:
+ gid = av[0]
+ if gid:
emit(OPCODES[MARK])
- emit((group-1)*2)
+ emit((gid-1)*2)
_compile(code, av[1], flags)
- if group:
+ if gid:
emit(OPCODES[MARK])
- emit((group-1)*2+1)
+ emit((gid-1)*2+1)
elif op in (SUCCESS, FAILURE):
emit(OPCODES[op])
elif op in (ASSERT, ASSERT_NOT):
@@ -207,7 +214,7 @@ def _compile(code, pattern, flags):
emit(CHCODES[CH_UNICODE[av]])
else:
emit(CHCODES[av])
- elif op is GROUP:
+ elif op is GROUPREF:
if flags & SRE_FLAG_IGNORECASE:
emit(OPCODES[OP_IGNORE[op]])
else: