Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial fixes towards enabling Rakudo-specific Match objects.
Most things work, but there are still a couple of issues with getting Match ~~ Positional to work (see src/core/Match.pm for details).
- Loading branch information
Showing
5 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
## $Id$ | ||
|
||
=head1 TITLE | ||
|
||
Cursor - Perl 6 cursor objects | ||
|
||
=head2 Methods | ||
|
||
=over 4 | ||
|
||
=cut | ||
|
||
.namespace [ 'Cursor' ] | ||
|
||
.sub 'onload' :anon :init :load | ||
.local pmc p6meta, cursorproto | ||
p6meta = get_hll_global ['Mu'], '$!P6META' | ||
cursorproto = p6meta.'new_class'('Cursor', 'parent'=>'parrot;Regex::Cursor Any') | ||
.end | ||
|
||
|
||
.sub 'new_match' :method | ||
$P0 = new ['Match'] | ||
.return ($P0) | ||
.end | ||
|
||
=back | ||
|
||
=cut | ||
|
||
# Local Variables: | ||
# mode: pir | ||
# fill-column: 100 | ||
# End: | ||
# vim: expandtab shiftwidth=4 ft=pir: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
class Match is Regex::Match is Cool does Associative { | ||
multi method postcircumfix:<{ }>($key) { | ||
Q:PIR { | ||
$P0 = find_lex 'self' | ||
$P1 = find_lex '$key' | ||
%r = $P0[$P1] | ||
unless null %r goto done | ||
%r = new ['Proxy'] | ||
setattribute %r, '$!base', $P0 | ||
setattribute %r, '$!key', $P1 | ||
done: | ||
} | ||
} | ||
|
||
# We shouldn't need to provide this -- we should be able to | ||
# simply write "does Positional" in the class declaration | ||
# and it would provide us the postcircumfix:<[ ]> methods | ||
# for free. But there seems to be a bug or problem in the | ||
# role composer that prevents us from having both "does Positional" | ||
# and "does Associative" in the class declaration, so we'll | ||
# provide the simple .[] for now. | ||
multi method postcircumfix:<[ ]>(Int $key) { | ||
Q:PIR { | ||
$P0 = find_lex 'self' | ||
$P1 = find_lex '$key' | ||
$I1 = $P1 | ||
%r = $P0[$I1] | ||
unless null %r goto done | ||
%r = new ['Proxy'] | ||
setattribute %r, '$!base', $P0 | ||
setattribute %r, '$!key', $P1 | ||
done: | ||
} | ||
} | ||
} |