[pypy-svn] r34486 - pypy/dist/pypy/lang/automata

arigo at codespeak.net arigo at codespeak.net
Sat Nov 11 14:21:28 CET 2006


Author: arigo
Date: Sat Nov 11 14:21:27 2006
New Revision: 34486

Modified:
   pypy/dist/pypy/lang/automata/dfa.py
Log:
Slight rewrite of the main loop of the 2nd dfa recognizer.
Now the loops looks typical for the interpreter, and it
can use the global_merge_point hint as intended.


Modified: pypy/dist/pypy/lang/automata/dfa.py
==============================================================================
--- pypy/dist/pypy/lang/automata/dfa.py	(original)
+++ pypy/dist/pypy/lang/automata/dfa.py	Sat Nov 11 14:21:27 2006
@@ -111,14 +111,12 @@
     finals = hint(finals, deepfreeze=True)
     alltrans = hint(alltrans, deepfreeze=True)
 
-    indx = 0
     state = 0
-    while True:
+    indx = 0
+    while indx < len(s):
         hint(None, global_merge_point=True)
-        if indx >= len(s):
-            break
-        
         char = s[indx]
+        indx += 1
         char = hint(char, promote=True)
 
         statetrans = alltrans.get(state, None)
@@ -127,7 +125,6 @@
         hint(state, concrete=True)
         if state == -1:
             return False
-        indx += 1
         
     res = state in finals
     res = hint(res, concrete=True)



More information about the Pypy-commit mailing list