[pypy-svn] r75788 - in pypy/branch/rsre2/pypy/rlib/rsre: . test

arigo at codespeak.net arigo at codespeak.net
Fri Jul 2 19:52:45 CEST 2010


Author: arigo
Date: Fri Jul  2 19:52:44 2010
New Revision: 75788

Modified:
   pypy/branch/rsre2/pypy/rlib/rsre/rsre.py
   pypy/branch/rsre2/pypy/rlib/rsre/test/test_match.py
Log:
IN_IGNORE


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:52:44 2010
@@ -17,6 +17,7 @@
 OPCODE_GROUPREF_EXISTS    = 13
 OPCODE_GROUPREF_IGNORE    = 14
 OPCODE_IN                 = 15
+OPCODE_IN_IGNORE          = 16
 OPCODE_INFO               = 17
 OPCODE_JUMP               = 18
 OPCODE_LITERAL            = 19
@@ -181,6 +182,16 @@
             ppos += ctx.pat(ppos)
             ptr += 1
 
+        elif op == OPCODE_IN_IGNORE:
+            # match set member (or non_member), ignoring case
+            # <IN> <skip> <set>
+            if ptr >= ctx.end or not rsre_char.check_charset(ctx.pattern,
+                                                             ppos+1,
+                                                             ctx.lowstr(ptr)):
+                return False
+            ppos += ctx.pat(ppos)
+            ptr += 1
+
         elif op == OPCODE_INFO:
             # optimization info block
             # <INFO> <0=skip> <1=flags> <2=min> ...
@@ -368,6 +379,12 @@
                                                     ctx.str(ptr)):
             ptr += 1
 
+    elif op == OPCODE_IN_IGNORE:
+        # repeated set
+        while ptr < end and rsre_char.check_charset(ctx.pattern, ppos+2,
+                                                    ctx.lowstr(ptr)):
+            ptr += 1
+
     elif op == OPCODE_LITERAL:
         chr = ctx.pat(ppos+1)
         while ptr < end and ctx.str(ptr) == chr:

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:52:44 2010
@@ -123,3 +123,13 @@
         assert not rsre.match(r, "xxxXxxx")
         assert     rsre.match(r, "xxxxxxXx")
         assert     rsre.match(r, "xxxXxxxxx")
+
+    def test_in_ignore(self):
+        r, _ = get_code(r"(?i)[a-f]")
+        assert rsre.match(r, "b")
+        assert rsre.match(r, "C")
+        assert not rsre.match(r, "g")
+        r, _ = get_code(r"(?i)[a-f]+$")
+        assert rsre.match(r, "bCdEf")
+        assert not rsre.match(r, "g")
+        assert not rsre.match(r, "aaagaaa")



More information about the Pypy-commit mailing list