Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: named_pod_vars
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 39 lines (36 sloc) 1.257 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
my class Regex {
    multi method ACCEPTS(Regex:D \$self: Mu \$topic) {
        my $match = $self(Cursor."!cursor_init"($topic, :c(0))).MATCH;
        pir::find_caller_lex__Ps('$/') = $match;
        Cursor!Cursor::set_last_match($match) if $match;
        $match
    }

    multi method ACCEPTS(Regex:D \$self: @a) {
        my $dollar_slash := pir::find_caller_lex__Ps('$/');
        for @a {
            $dollar_slash = $self(Cursor.'!cursor_init'($_, :c(0))).MATCH;
            if $dollar_slash {
                Cursor!Cursor::set_last_match($dollar_slash);
                return $dollar_slash;
            }
        }
        Nil;
    }
    multi method ACCEPTS(Regex:D \$self: %h) {
        my $dollar_slash := pir::find_caller_lex__Ps('$/');
        for %h.keys {
            $dollar_slash = $self(Cursor.'!cursor_init'($_, :c(0))).MATCH;
            if $dollar_slash {
                Cursor!Cursor::set_last_match($dollar_slash);
                return $dollar_slash;
            }
        }
        Nil;
    }

    multi method Bool(Regex:D:) {
        my $match = pir::find_caller_lex__pS('$_').match(self);
        pir::find_caller_lex__Ps('$/') = $match;
        Cursor!Cursor::set_last_match($match) if $match;
        $match.Bool()
    }
}
Something went wrong with that request. Please try again.