[pypy-svn] r75785 - in pypy/branch/rsre2/pypy/rlib/rsre: . test
arigo at codespeak.net
arigo at codespeak.net
Fri Jul 2 19:27:11 CEST 2010
Author: arigo
Date: Fri Jul 2 19:27:10 2010
New Revision: 75785
Modified:
pypy/branch/rsre2/pypy/rlib/rsre/rsre.py
pypy/branch/rsre2/pypy/rlib/rsre/test/test_match.py
Log:
Progress.
Modified: pypy/branch/rsre2/pypy/rlib/rsre/rsre.py
==============================================================================
--- pypy/branch/rsre2/pypy/rlib/rsre/rsre.py (original)
+++ pypy/branch/rsre2/pypy/rlib/rsre/rsre.py Fri Jul 2 19:27:10 2010
@@ -123,13 +123,17 @@
ppos += ctx.pat(ppos)
return False
- elif op == OPCODE_CATEGORY:
- # match at given category (a single char)
- # <CATEGORY> <code>
- xxx #if (ptr >= end || !sre_category(pattern[0], ptr[0]))
- # return 0;
- #pattern++;
- #ptr++;
+ #elif op == OPCODE_CATEGORY:
+ # seems to be never produced
+
+ elif op == OPCODE_IN:
+ # match set member (or non_member)
+ # <IN> <skip> <set>
+ if (ptr >= ctx.end
+ or not check_charset(ctx.pattern, ppos+1, ctx.str(ptr))):
+ return False
+ ppos += ctx.pat(ppos)
+ ptr += 1
elif op == OPCODE_INFO:
# optimization info block
Modified: pypy/branch/rsre2/pypy/rlib/rsre/test/test_match.py
==============================================================================
--- pypy/branch/rsre2/pypy/rlib/rsre/test/test_match.py (original)
+++ pypy/branch/rsre2/pypy/rlib/rsre/test/test_match.py Fri Jul 2 19:27:10 2010
@@ -6,6 +6,7 @@
class GotIt(Exception):
pass
def my_compile(pattern, flags, code, *args):
+ print code
raise GotIt(code)
saved = _sre.compile
try:
@@ -14,6 +15,8 @@
re.compile(regexp)
except GotIt, e:
pass
+ else:
+ raise ValueError("did not reach _sre.compile()!")
finally:
_sre.compile = saved
return e.args[0], re.compile(regexp)
@@ -88,9 +91,13 @@
assert not rsre.match(r, "abcd")
assert not rsre.match(r, "ab")
+ def test_repeated_set(self):
+ r, _ = get_code(r"[a0x]+f")
+ assert rsre.match(r, "a0af")
+ assert not rsre.match(r, "a0yaf")
+
def test_category(self):
- r, _ = get_code(r"ab\dcd")
- assert rsre.match(r, "ab0cd")
- assert rsre.match(r, "ab9cd")
- assert not rsre.match(r, "abXcd")
- assert not rsre.match(r, "ab+cd")
+ r, _ = get_code(r"[\sx]")
+ assert rsre.match(r, "x")
+ assert rsre.match(r, " ")
+ assert not rsre.match(r, "n")
More information about the Pypy-commit
mailing list