[svn:parrot] r41618 - branches/pct-rx/compilers/pct/src/Regex

pmichaud at svn.parrot.org pmichaud at svn.parrot.org
Fri Oct 2 15:52:27 UTC 2009


Author: pmichaud
Date: Fri Oct  2 15:52:27 2009
New Revision: 41618
URL: https://trac.parrot.org/parrot/changeset/41618

Log:
[pct-rx]:  Move Match object creation into Cursor.MATCH()

Modified:
   branches/pct-rx/compilers/pct/src/Regex/Cursor.pir

Modified: branches/pct-rx/compilers/pct/src/Regex/Cursor.pir
==============================================================================
--- branches/pct-rx/compilers/pct/src/Regex/Cursor.pir	Fri Oct  2 15:51:33 2009	(r41617)
+++ branches/pct-rx/compilers/pct/src/Regex/Cursor.pir	Fri Oct  2 15:52:27 2009	(r41618)
@@ -31,13 +31,26 @@
 
 =item MATCH()
 
-Return this cursor's current Match object.
+Return this cursor's current Match object.  If it doesn't have one,
+create one.
 
 =cut
 
 .sub 'MATCH' :method
     .local pmc match
     match = getattribute self, '$!match'
+    unless null match goto have_match
+    match = new ['Regex';'Match']
+    setattribute self, '$!match', match
+
+    $P0 = getattribute self, '$!target'
+    setattribute match, '$!target', $P0
+    $P0 = getattribute self, '$!from'
+    setattribute match, '$!from', $P0
+    $P0 = box -1
+    setattribute match, '$!to', $P0
+
+  have_match:
     .return (match)
 .end
 
@@ -111,6 +124,11 @@
 .end
 
 
+=item !cursor_bind(subcur, names :slurpy)
+
+Bind C<subcur>'s match object as submatches of the current cursor
+under C<names>.
+
 =item !mark_push(rep, pos, mark)
 
 Push a new backtracking point onto the cursor with the given
@@ -205,16 +223,11 @@
     .param int has_name        :opt_flag
 
     .local pmc match
-    match = new ['Regex';'Match']
-    setattribute self, '$!match', match
+    match = self.'MATCH'()
 
     $P0 = box pos
-    setattribute self, '$!pos', $P0
     setattribute match, '$!to', $P0
-    $P0 = getattribute self, '$!from'
-    setattribute match, '$!from', $P0
-    $P0 = getattribute self, '$!target'
-    setattribute match, '$!target', $P0
+    setattribute self, '$!pos', $P0
 
     .local pmc action
     unless has_name goto action_done


More information about the parrot-commits mailing list