Skip to content

Commit

Permalink
[pct-rx]: Move Match object creation into Cursor.MATCH()
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.parrot.org/parrot/branches/pct-rx@41618 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
pmichaud committed Oct 2, 2009
1 parent 5446d28 commit 702a9c0
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions compilers/pct/src/Regex/Cursor.pir
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,26 @@ grammars.

=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

Expand Down Expand Up @@ -111,6 +124,11 @@ Create and initialize a new cursor from C<self>.
.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
Expand Down Expand Up @@ -205,16 +223,11 @@ Generate a successful match at pos.
.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
Expand Down

0 comments on commit 702a9c0

Please sign in to comment.