summaryrefslogtreecommitdiff
path: root/Cython/Plex
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2015-07-25 21:13:58 +0200
committerStefan Behnel <stefan_ml@behnel.de>2015-07-25 21:13:58 +0200
commit9498ab6527fa1a0a10b0f048f336353c297a6c8d (patch)
treeb6426368245b52768da3761d3b400cce72581953 /Cython/Plex
parent9c7d4b130a7f5cf1247fe3651a374f82b7b9d368 (diff)
downloadcython-9498ab6527fa1a0a10b0f048f336353c297a6c8d.tar.gz
replace xrange() by range() to make it work in Py2/Py3
Diffstat (limited to 'Cython/Plex')
-rw-r--r--Cython/Plex/Regexps.py10
-rw-r--r--Cython/Plex/Traditional.py2
2 files changed, 4 insertions, 8 deletions
diff --git a/Cython/Plex/Regexps.py b/Cython/Plex/Regexps.py
index 56b3f9c48..41816c939 100644
--- a/Cython/Plex/Regexps.py
+++ b/Cython/Plex/Regexps.py
@@ -87,9 +87,7 @@ def CodeRanges(code_list):
Given a list of codes as returned by chars_to_ranges, return
an RE which will match a character in any of the ranges.
"""
- re_list = []
- for i in xrange(0, len(code_list), 2):
- re_list.append(CodeRange(code_list[i], code_list[i + 1]))
+ re_list = [CodeRange(code_list[i], code_list[i + 1]) for i in range(0, len(code_list), 2)]
return Alt(*re_list)
@@ -307,8 +305,7 @@ class Seq(RE):
def __init__(self, *re_list):
nullable = 1
- for i in xrange(len(re_list)):
- re = re_list[i]
+ for i, re in enumerate(re_list):
self.check_re(i, re)
nullable = nullable and re.nullable
self.re_list = re_list
@@ -332,12 +329,11 @@ class Seq(RE):
else:
s1 = initial_state
n = len(re_list)
- for i in xrange(n):
+ for i, re in enumerate(re_list):
if i < n - 1:
s2 = m.new_state()
else:
s2 = final_state
- re = re_list[i]
re.build_machine(m, s1, s2, match_bol, nocase)
s1 = s2
match_bol = re.match_nl or (match_bol and re.nullable)
diff --git a/Cython/Plex/Traditional.py b/Cython/Plex/Traditional.py
index 2738d1118..ec7252dae 100644
--- a/Cython/Plex/Traditional.py
+++ b/Cython/Plex/Traditional.py
@@ -104,7 +104,7 @@ class REParser(object):
if self.c == '-' and self.lookahead(1) != ']':
self.next()
c2 = self.get()
- for a in xrange(ord(c1), ord(c2) + 1):
+ for a in range(ord(c1), ord(c2) + 1):
char_list.append(chr(a))
else:
char_list.append(c1)