Author: pmichaud
Date: Tue May  3 16:05:28 2005
New Revision: 7967

Modified:
   trunk/compilers/pge/PGE/Exp.pir
   trunk/compilers/pge/PGE/Match.pir
   trunk/lib/Parrot/Test/PGE.pm
   trunk/t/p6rules/capture.t
Log:
Fixed bugs in ^^, $$ anchors.  Updated test harness,
Corrected tests.


Modified: trunk/compilers/pge/PGE/Exp.pir
==============================================================================
--- trunk/compilers/pge/PGE/Exp.pir     (original)
+++ trunk/compilers/pge/PGE/Exp.pir     Tue May  3 16:05:28 2005
@@ -499,13 +499,13 @@
     emit(code, "if pos == 0 goto %s", next)
     unless token == '^^' goto end
     emit(code, "$I0 = pos - 1")
-    emit(code, "$I0 = is_newline target, $I0")
-    emit(code, "if $I0 goto %s", next)
+    emit(code, "$I1 = is_newline target, $I0")
+    emit(code, "if $I1 goto %s", next)
     goto end
   eos:
     emit(code, "if pos == lastpos goto %s", next)
     unless token == '$$' goto end
-    emit(code, "$I0 = is_newline target, $I0")
+    emit(code, "$I0 = is_newline target, pos")
     emit(code, "if $I0 goto %s", next)
   end:
     emit(code, "goto fail")

Modified: trunk/compilers/pge/PGE/Match.pir
==============================================================================
--- trunk/compilers/pge/PGE/Match.pir   (original)
+++ trunk/compilers/pge/PGE/Match.pir   Tue May  3 16:05:28 2005
@@ -189,25 +189,30 @@
    
 .sub "dump" method
     .param string prefix
+    .param string b1
+    .param string b2
     .local pmc capt
     .local int spi, spc
     .local string prefix1, prefix2
     .local int matchidx
+    unless argcS < 3 goto start
+    b2 = "]"
+    unless argcS < 2 goto start
+    b1 = "["
+  start:
     print prefix
-    print ": "
+    print ":"
     $I0 = self
-    print $I0
     unless $I0 goto subpats
-    print " ["
+    print " <"
+    print self
+    print " @ "
     $I0 = self."from"()
     print $I0
-    print ".."
-    $I0 = self."to"()
-    print $I0
-    print "] �"
-    print self
-    print "�"
+    print "> "
   subpats:
+    $I0 = self
+    print $I0
     print "\n"
     capt = getattribute self, "PGE::Match\x0@:capt"
     isnull capt, subrules
@@ -215,10 +220,10 @@
     spc = elements capt
   subpats_1:
     unless spi < spc goto subrules
-    prefix1 = concat prefix, "["
+    prefix1 = concat prefix, b1
     $S0 = spi
     concat prefix1, $S0
-    concat prefix1, "]"
+    concat prefix1, b2
     $P0 = capt[spi]
     $I0 = 0
     $I1 = elements $P0
@@ -226,16 +231,16 @@
     $P1 = getprop "isarray", $P0
     if $P1 goto subpats_2
     $P1 = $P0[-1]
-    $P1."dump"(prefix1)
+    $P1."dump"(prefix1, b1, b2)
     goto subpats_3
   subpats_2:
     unless $I0 < $I1 goto subpats_3
     $P1 = $P0[$I0]
-    prefix2 = concat prefix1, "["
+    prefix2 = concat prefix1, b1
     $S0 = $I0
     concat prefix2, $S0
-    concat prefix2, "]"
-    $P1."dump"(prefix2)
+    concat prefix2, b2
+    $P1."dump"(prefix2, b1, b2)
     inc $I0
     goto subpats_2
   subpats_3:

Modified: trunk/lib/Parrot/Test/PGE.pm
==============================================================================
--- trunk/lib/Parrot/Test/PGE.pm        (original)
+++ trunk/lib/Parrot/Test/PGE.pm        Tue May  3 16:05:28 2005
@@ -94,7 +94,7 @@
     if ($captures) { 
         $captures = qq(
             print "\\n"
-            match."_print"()\n); 
+            match."dump"("mob"," ","")\n); 
     }
     else {
         $captures = "";
@@ -109,9 +109,11 @@
             .local string pattern
             .local pmc rulesub
             .local pmc match
+            .local pmc code
+            .local pmc exp
             target = "$target"
             pattern = "$pattern"
-            rulesub = p6rule_compile(pattern)
+            (rulesub, code, exp) = p6rule_compile(pattern)
             match = rulesub(target)
             unless match goto match_fail
           match_success:

Modified: trunk/t/p6rules/capture.t
==============================================================================
--- trunk/t/p6rules/capture.t   (original)
+++ trunk/t/p6rules/capture.t   Tue May  3 16:05:28 2005
@@ -2,23 +2,24 @@
 use Parrot::Test::PGE;
 
 p6rule_is  ('zzzabcdefzzz', '(a.)..(..)', 'basic match');
-p6rule_like('zzzabcdefzzz', '(a.)..(..)', qr/0: <abcdef @ 3>/, 'basic $0');
-p6rule_like('zzzabcdefzzz', '(a.)..(..)', qr/1: <ab @ 3>/, 'basic $1');
-p6rule_like('zzzabcdefzzz', '(a.)..(..)', qr/2: <ef @ 7>/, 'basic $2');
+p6rule_like('zzzabcdefzzz', '(a.)..(..)', qr/mob: <abcdef @ 3>/, 'basic $0');
+p6rule_like('zzzabcdefzzz', '(a.)..(..)', qr/mob 0: <ab @ 3>/, 'basic $1');
+p6rule_like('zzzabcdefzzz', '(a.)..(..)', qr/mob 1: <ef @ 7>/, 'basic $2');
 
 p6rule_is  ('abcd', '(a(b(c))(d))', 'nested match');
-p6rule_like('abcd', '(a(b(c))(d))', qr/0: <abcd @ 0>/, 'nested match');
-p6rule_like('abcd', '(a(b(c))(d))', qr/1: <abcd @ 0>/, 'nested match');
-p6rule_like('abcd', '(a(b(c))(d))', qr/2: <bc @ 1>/, 'nested match');
-p6rule_like('abcd', '(a(b(c))(d))', qr/3: <c @ 2>/, 'nested match');
-p6rule_like('abcd', '(a(b(c))(d))', qr/4: <d @ 3>/, 'nested match');
+p6rule_like('abcd', '(a(b(c))(d))', qr/mob: <abcd @ 0>/, 'nested match');
+p6rule_like('abcd', '(a(b(c))(d))', qr/mob 0: <abcd @ 0>/, 'nested match');
+p6rule_like('abcd', '(a(b(c))(d))', qr/mob 0 0: <bc @ 1>/, 'nested match');
+p6rule_like('abcd', '(a(b(c))(d))', qr/mob 0 0 0: <c @ 2>/, 'nested match');
+p6rule_like('abcd', '(a(b(c))(d))', qr/mob 0 1: <d @ 3>/, 'nested match');
 
-p6rule_is  ('bookkeeper', '(((.)$3)+)', 'backreference');
-p6rule_like('bookkeeper', '(((.)$3)+)', 
-            qr/0: <ookkee @ 1>/, 'backref $0');
-p6rule_like('bookkeeper', '(((.)$3)+)', 
-            qr/1: <ookkee @ 1>/, 'backref $1');
-p6rule_like('bookkeeper', '(((.)$3)+)', 
-            qr/2: <oo @ 1> <kk @ 3> <ee @ 5>/, 'backref $2');
-p6rule_like('bookkeeper', '(((.)$3)+)', 
-            qr/3: <o @ 1> <k @ 3> <e @ 5>/, 'backref $2');
+# backreferences not implemented yet
+#p6rule_is  ('bookkeeper', '(((.)$3)+)', 'backreference');
+#p6rule_like('bookkeeper', '(((.)$3)+)', 
+#            qr/0: <ookkee @ 1>/, 'backref $0');
+#p6rule_like('bookkeeper', '(((.)$3)+)', 
+#            qr/1: <ookkee @ 1>/, 'backref $1');
+#p6rule_like('bookkeeper', '(((.)$3)+)', 
+#            qr/2: <oo @ 1> <kk @ 3> <ee @ 5>/, 'backref $2');
+#p6rule_like('bookkeeper', '(((.)$3)+)', 
+#            qr/3: <o @ 1> <k @ 3> <e @ 5>/, 'backref $2');

Reply via email to