Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
create new match objects and arrays in separate methods that can easi…
…ly be overridden from HLLs
  • Loading branch information
moritz committed Apr 23, 2010
1 parent d823fc2 commit 8712c4a
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions src/Regex/Cursor.pir
Expand Up @@ -38,6 +38,34 @@ grammars.

=over 4

=item new_match()

A method that creates an empty Match object, by default of type
C<Regex::Match>. This method can be overridden for generating HLL-specific
Match objects.

=cut

.sub 'new_match' :method
.local pmc match
match = new ['Regex';'Match']
.return (match)
.end

=item new_array()

A method that creates an empty array object, by default of type
C<ResizablePMCArray>. This method can be overridden for generating HLL-specific
arrays for usage within Match objects.

=cut

.sub 'new_array' :method
.local pmc arr
arr = new ['ResizablePMCArray']
.return (arr)
.end

=item MATCH()

Return this cursor's current Match object, generating a new one
Expand All @@ -55,7 +83,7 @@ for the Cursor if one hasn't been created yet.

# First, create a Match object and bind it
match_make:
match = new ['Regex';'Match']
match = self.'new_match'()
setattribute self, '$!match', match
setattribute match, '$!cursor', self
.local pmc target, from, to
Expand All @@ -78,7 +106,7 @@ for the Cursor if one hasn't been created yet.
.local pmc arr
.local int keyint
subname = shift caparray_it
arr = new ['ResizablePMCArray']
arr = self.'new_array'()
caphash[subname] = arr
keyint = is_cclass .CCLASS_NUMERIC, subname, 0
if keyint goto caparray_int
Expand Down

0 comments on commit 8712c4a

Please sign in to comment.