summaryrefslogtreecommitdiffstats
path: root/Lib/sre.py
diff options
context:
space:
mode:
authorFredrik Lundh <fredrik@pythonware.com>2000-08-01 18:20:07 (GMT)
committerFredrik Lundh <fredrik@pythonware.com>2000-08-01 18:20:07 (GMT)
commit29c4ba9ada44d62988c62c85c8046985f10a1c85 (patch)
tree89f38c5859e98069d05491dcd977e338477fd2d2 /Lib/sre.py
parent19c6afb42b12c3a50900b4157c8398e01acad91f (diff)
downloadcpython-29c4ba9ada44d62988c62c85c8046985f10a1c85.zip
cpython-29c4ba9ada44d62988c62c85c8046985f10a1c85.tar.gz
cpython-29c4ba9ada44d62988c62c85c8046985f10a1c85.tar.bz2
SRE 0.9.8: passes the entire test suite
-- reverted REPEAT operator to use "repeat context" strategy (from 0.8.X), but done right this time. -- got rid of backtracking stack; use nested SRE_MATCH calls instead (should probably put it back again in 0.9.9 ;-) -- properly reset state in scanner mode -- don't use aggressive inlining by default
Diffstat (limited to 'Lib/sre.py')
-rw-r--r--Lib/sre.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/Lib/sre.py b/Lib/sre.py
index 6dd1df9..3e125a7 100644
--- a/Lib/sre.py
+++ b/Lib/sre.py
@@ -5,8 +5,12 @@
#
# Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved.
#
+# This version of the SRE library can be redistributed under CNRI's
+# Python 1.6 license. For any other use, please contact Secret Labs
+# AB (info@pythonware.com).
+#
# Portions of this engine have been developed in cooperation with
-# CNRI. Hewlett-Packard provided funding for 2.0 integration and
+# CNRI. Hewlett-Packard provided funding for 1.6 integration and
# other compatibility work.
#
@@ -24,7 +28,7 @@ M = MULTILINE = sre_compile.SRE_FLAG_MULTILINE
S = DOTALL = sre_compile.SRE_FLAG_DOTALL
X = VERBOSE = sre_compile.SRE_FLAG_VERBOSE
-# sre extensions (may or may not be in 2.0 final)
+# sre extensions (may or may not be in 1.6/2.0 final)
T = TEMPLATE = sre_compile.SRE_FLAG_TEMPLATE
U = UNICODE = sre_compile.SRE_FLAG_UNICODE
@@ -168,15 +172,14 @@ copy_reg.pickle(type(_compile("")), _pickle, _compile)
class Scanner:
def __init__(self, lexicon):
- from sre_constants import BRANCH, SUBPATTERN, INDEX
+ from sre_constants import BRANCH, SUBPATTERN
self.lexicon = lexicon
# combine phrases into a compound pattern
p = []
s = sre_parse.Pattern()
for phrase, action in lexicon:
p.append(sre_parse.SubPattern(s, [
- (SUBPATTERN, (None, sre_parse.parse(phrase))),
- (INDEX, len(p))
+ (SUBPATTERN, (len(p), sre_parse.parse(phrase))),
]))
p = sre_parse.SubPattern(s, [(BRANCH, (None, p))])
s.groups = len(p)