Kaydet (Commit) 019bcb59 authored tarafından Fredrik Lundh's avatar Fredrik Lundh

- changed sre.Scanner to use lastindex instead of index.

üst c2301730
...@@ -165,7 +165,7 @@ class Scanner: ...@@ -165,7 +165,7 @@ class Scanner:
p = [] p = []
for phrase, action in lexicon: for phrase, action in lexicon:
p.append("(?:%s)(?P#%d)" % (phrase, len(p))) p.append("(?:%s)(?P#%d)" % (phrase, len(p)))
self.scanner = sre.compile("|".join(p)) self.scanner = _compile("|".join(p))
def scan(self, string): def scan(self, string):
result = [] result = []
append = result.append append = result.append
...@@ -178,7 +178,7 @@ class Scanner: ...@@ -178,7 +178,7 @@ class Scanner:
j = m.end() j = m.end()
if i == j: if i == j:
break break
action = self.lexicon[m.index][1] action = self.lexicon[m.lastindex][1]
if callable(action): if callable(action):
self.match = match self.match = match
action = action(self, m.group()) action = action(self, m.group())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment