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

rxe at codespeak.net rxe at codespeak.net
Fri Nov 3 18:49:46 CET 2006


Author: rxe
Date: Fri Nov  3 18:49:45 2006
New Revision: 34138

Modified:
   pypy/dist/pypy/lang/automata/dfa.py
Log:
some updates for recognizer - arre, rxe

Modified: pypy/dist/pypy/lang/automata/dfa.py
==============================================================================
--- pypy/dist/pypy/lang/automata/dfa.py	(original)
+++ pypy/dist/pypy/lang/automata/dfa.py	Fri Nov  3 18:49:45 2006
@@ -103,18 +103,23 @@
     " a less simple recognizer "
     trans = hint(trans, deepfreeze=True)
     finals = hint(finals, deepfreeze=True)
-    
-    state = 0
-    try:
-        hint(None, global_mp_to_follow=True)
-        for char in s:
-            char = hint(char, promote=True)
-            state = trans[state, char]
-            hint(state, concrete=True)
 
-    except KeyError:
-        return False
+    indx = 0
+    state = 0
+    while True:
+        hint(None, global_merge_point=True)
+        if indx >= len(s):
+            break
+        
+        char = s[indx]
+        char = hint(char, promote=True)
 
+        state = trans.get((state, char), -1)
+        if state == -1:
+            return False
+        hint(state, concrete=True)
+        indx += 1
+        
     res = state in finals
     res = hint(res, variable=True)
     return res



More information about the Pypy-commit mailing list