diff options
author | Gustavo Niemeyer <gustavo@niemeyer.net> | 2003-10-17 22:13:16 +0000 |
---|---|---|
committer | Gustavo Niemeyer <gustavo@niemeyer.net> | 2003-10-17 22:13:16 +0000 |
commit | ad3fc44ccb40f2ad33c0d09f5a2dfbd4feb442eb (patch) | |
tree | 929ea71dea18a5ee0c5c862bbb39d37b693209ad /Lib/sre_compile.py | |
parent | 41e2809febd6e09a34adf21beb6d2ae2360fdc46 (diff) | |
download | cpython-git-ad3fc44ccb40f2ad33c0d09f5a2dfbd4feb442eb.tar.gz |
Implemented non-recursive SRE matching.
Diffstat (limited to 'Lib/sre_compile.py')
-rw-r--r-- | Lib/sre_compile.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py index 8a26a0f43d..ee0882debf 100644 --- a/Lib/sre_compile.py +++ b/Lib/sre_compile.py @@ -145,6 +145,19 @@ def _compile(code, pattern, flags): else: emit(OPCODES[op]) emit(av-1) + elif op is GROUPREF_EXISTS: + emit(OPCODES[op]) + emit((av[0]-1)*2) + skipyes = len(code); emit(0) + _compile(code, av[1], flags) + if av[2]: + emit(OPCODES[JUMP]) + skipno = len(code); emit(0) + code[skipyes] = len(code) - skipyes + 1 + _compile(code, av[2], flags) + code[skipno] = len(code) - skipno + else: + code[skipyes] = len(code) - skipyes + 1 else: raise ValueError, ("unsupported operand type", op) |