[pypy-svn] r34024 - in pypy/dist/pypy: jit/timeshifter/test lang/automata
rxe at codespeak.net
rxe at codespeak.net
Wed Nov 1 15:01:37 CET 2006
Author: rxe
Date: Wed Nov 1 15:01:33 2006
New Revision: 34024
Modified:
pypy/dist/pypy/jit/timeshifter/test/test_portal.py
pypy/dist/pypy/lang/automata/dfa.py
Log:
fix up final states (thanks samuele)
Modified: pypy/dist/pypy/jit/timeshifter/test/test_portal.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/test/test_portal.py (original)
+++ pypy/dist/pypy/jit/timeshifter/test/test_portal.py Wed Nov 1 15:01:33 2006
@@ -7,8 +7,6 @@
from pypy.objspace.flow.model import checkgraph, summary
from pypy.rlib.objectmodel import hint
-from pypy.rlib.objectmodel import hint
-
import py.test
class TestPortal(object):
@@ -121,11 +119,10 @@
self.check_insns(int_floordiv=1, int_mul=0)
def test_dfa_compile(self):
- py.test.skip("we've gone yellow")
from pypy.lang.automata.dfa import getautomaton, convertdfa, recognizetable
+ a = getautomaton()
+ dfatable, final_states = convertdfa(a)
def main(gets):
- a = getautomaton()
- dfatable, final_states = convertdfa(a)
s = ["aaaaaaaaaab", "aaaa"][gets]
return recognizetable(dfatable, s, final_states)
Modified: pypy/dist/pypy/lang/automata/dfa.py
==============================================================================
--- pypy/dist/pypy/lang/automata/dfa.py (original)
+++ pypy/dist/pypy/lang/automata/dfa.py Wed Nov 1 15:01:33 2006
@@ -59,7 +59,7 @@
def convertdfa(automaton):
""" converts the dfa transitions into a table, represented as a big string.
this is just to make the code more amenable to current state of the JIT. Returns
- a two tuple of dfa as table, and final states"""
+ a two tuple of dfa as table, and final states"""
size = automaton.num_states * 256
dfatable = [chr(255)] * size
@@ -83,10 +83,18 @@
if state == 255:
break
indx += 1
- state = hint(state, variable=True)
# more strange code for now - check final state?
- for fs in finalstates:
- if state == ord(fs):
- return 1
- return 0
+ res = 0
+ indx = 0
+ while True:
+ if indx >= len(finalstates):
+ break
+ fs = ord(finalstates[indx])
+ fs = hint(fs, concrete=True)
+ if state == fs:
+ res = 1
+ break
+ indx += 1
+ res = hint(res, variable=True)
+ return res
More information about the Pypy-commit
mailing list