Source

pypy / pypy / interpreter / pyparser / automata.py

Diff from to

File pypy/interpreter/pyparser/automata.py

-#! /usr/bin/env python
 # ______________________________________________________________________
 """Module automata
 
     # ____________________________________________________________
     def recognize (self, inVec, pos = 0): # greedy = True
         crntState = self.start
+        lastAccept = False
         i = pos
-        lastAccept = False
-        for item in inVec[pos:]:
+        for i in range(pos, len(inVec)):
+            item = inVec[i]
             # arcMap, accept = self.states[crntState]
             arcMap = self.states[crntState]
             accept = self.accepts[crntState]
             else:
                 return -1
             lastAccept = accept
-            i += 1
         # if self.states[crntState][1]:
         if self.accepts[crntState]:
+            return i + 1
+        elif lastAccept:
             return i
-        elif lastAccept:
-            return i - 1
         else:
             return -1