summaryrefslogtreecommitdiffstats
path: root/Lib/sre_parse.py
diff options
context:
space:
mode:
authorFredrik Lundh <fredrik@pythonware.com>2000-06-30 10:41:31 (GMT)
committerFredrik Lundh <fredrik@pythonware.com>2000-06-30 10:41:31 (GMT)
commit43b3b49b5ab486295baef3a35cd8e836f735c065 (patch)
tree3ca960c788dafde87799443f2087dc661dc52d48 /Lib/sre_parse.py
parenta4657f736c34e4bb1802b40246028c5bec545fe6 (diff)
downloadcpython-43b3b49b5ab486295baef3a35cd8e836f735c065.zip
cpython-43b3b49b5ab486295baef3a35cd8e836f735c065.tar.gz
cpython-43b3b49b5ab486295baef3a35cd8e836f735c065.tar.bz2
- fixed lookahead assertions (#10, #11, #12)
- untabified sre_constants.py
Diffstat (limited to 'Lib/sre_parse.py')
-rw-r--r--Lib/sre_parse.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py
index a6f3082..d3dbe00 100644
--- a/Lib/sre_parse.py
+++ b/Lib/sre_parse.py
@@ -470,6 +470,25 @@ def _parse(source, state, flags=0):
if source.next is None or source.next == ")":
break
source.get()
+ elif source.next in ("=", "!"):
+ # lookahead assertions
+ char = source.get()
+ b = []
+ while 1:
+ p = _parse(source, state, flags)
+ if source.next == ")":
+ if b:
+ b.append(p)
+ p = _branch(state, b)
+ if char == "=":
+ subpattern.append((ASSERT, p))
+ else:
+ subpattern.append((ASSERT_NOT, p))
+ break
+ elif source.match("|"):
+ b.append(p)
+ else:
+ raise error, "pattern not properly closed"
else:
# flags
while FLAGS.has_key(source.next):