summaryrefslogtreecommitdiffstats
path: root/Lib/sre_parse.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/sre_parse.py')
-rw-r--r--Lib/sre_parse.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py
index d78737f..07ab782 100644
--- a/Lib/sre_parse.py
+++ b/Lib/sre_parse.py
@@ -482,9 +482,15 @@ def _parse(source, state):
if source.next is None or source.next == ")":
break
source.get()
- elif source.next in ("=", "!"):
+ elif source.next in ("=", "!", "<"):
# lookahead assertions
char = source.get()
+ dir = 1
+ if char == "<":
+ if source.next not in ("=", "!"):
+ raise error, "syntax error"
+ dir = -1 # lookbehind
+ char = source.get()
b = []
while 1:
p = _parse(source, state)
@@ -493,9 +499,9 @@ def _parse(source, state):
b.append(p)
p = _branch(state, b)
if char == "=":
- subpattern.append((ASSERT, p))
+ subpattern.append((ASSERT, (dir, p)))
else:
- subpattern.append((ASSERT_NOT, p))
+ subpattern.append((ASSERT_NOT, (dir, p)))
break
elif source.match("|"):
b.append(p)