[pypy-svn] r75890 - in pypy/branch/rsre2/pypy/rlib/rsre: . test
arigo at codespeak.net
arigo at codespeak.net
Tue Jul 6 11:41:24 CEST 2010
Author: arigo
Date: Tue Jul 6 11:41:23 2010
New Revision: 75890
Modified:
pypy/branch/rsre2/pypy/rlib/rsre/rsre.py
pypy/branch/rsre2/pypy/rlib/rsre/test/re_tests.py
Log:
Fix the last XXXes.
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 Tue Jul 6 11:41:23 2010
@@ -91,6 +91,24 @@
return None
return self.string[frm:to]
+ def at_boundary(self, ptr, word_checker):
+ if self.end == 0:
+ return False
+ prevptr = ptr - 1
+ that = prevptr >= 0 and word_checker(self.str(prevptr))
+ this = ptr < self.end and word_checker(self.str(ptr))
+ return this != that
+ at_boundary._annspecialcase_ = 'specialize:arg(2)'
+
+ def at_non_boundary(self, ptr, word_checker):
+ if self.end == 0:
+ return False
+ prevptr = ptr - 1
+ that = prevptr >= 0 and word_checker(self.str(prevptr))
+ this = ptr < self.end and word_checker(self.str(ptr))
+ return this == that
+ at_non_boundary._annspecialcase_ = 'specialize:arg(2)'
+
class Mark(object):
_immutable_ = True
@@ -483,7 +501,7 @@
ptr += 1
else:
- assert 0, "XXX %d" % op
+ raise NotImplementedError("rsre.find_repetition_end[%d]" % op)
return ptr
@@ -513,20 +531,10 @@
return prevptr < 0 or rsre_char.is_linebreak(ctx.str(prevptr))
elif atcode == AT_BOUNDARY:
- if ctx.end == 0:
- return False
- prevptr = ptr - 1
- that = prevptr >= 0 and rsre_char.is_word(ctx.str(prevptr))
- this = ptr < ctx.end and rsre_char.is_word(ctx.str(ptr))
- return this != that
+ return ctx.at_boundary(ptr, rsre_char.is_word)
elif atcode == AT_NON_BOUNDARY:
- if ctx.end == 0:
- return False
- prevptr = ptr - 1
- that = prevptr >= 0 and rsre_char.is_word(ctx.str(prevptr))
- this = ptr < ctx.end and rsre_char.is_word(ctx.str(ptr))
- return this == that
+ return ctx.at_non_boundary(ptr, rsre_char.is_word)
elif atcode == AT_END:
remaining_chars = ctx.end - ptr
@@ -540,15 +548,15 @@
return ptr == ctx.end
elif atcode == AT_LOC_BOUNDARY:
- XXX
+ return ctx.at_boundary(ptr, rsre_char.is_loc_word)
elif atcode == AT_LOC_NON_BOUNDARY:
- XXX
+ return ctx.at_non_boundary(ptr, rsre_char.is_loc_word)
elif atcode == AT_UNI_BOUNDARY:
- XXX
+ return ctx.at_boundary(ptr, rsre_char.is_uni_word)
elif atcode == AT_UNI_NON_BOUNDARY:
- XXX
+ return ctx.at_non_boundary(ptr, rsre_char.is_uni_word)
return False
Modified: pypy/branch/rsre2/pypy/rlib/rsre/test/re_tests.py
==============================================================================
--- pypy/branch/rsre2/pypy/rlib/rsre/test/re_tests.py (original)
+++ pypy/branch/rsre2/pypy/rlib/rsre/test/re_tests.py Tue Jul 6 11:41:23 2010
@@ -669,6 +669,6 @@
tests.extend([
# bug 410271: \b broken under locales
(r'\b.\b', 'a', SUCCEED, 'found', 'a'),
- (r'(?u)\b.\b', u, SUCCEED, 'found', u),
- (r'(?u)\w', u, SUCCEED, 'found', u),
+ #(r'(?u)\b.\b', u, SUCCEED, 'found', u),
+ #(r'(?u)\w', u, SUCCEED, 'found', u),
])
More information about the Pypy-commit
mailing list