Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl6
- multi sub infix:<eqv>(Match:D $a, Match:D $b) {
- return $a.to eqv $b.to &&
- $a.from eqv $b.from &&
- $a.orig eqv $b.orig &&
- $a.made eqv $b.made &&
- $a.list eqv $b.list &&
- $a.hash eqv $b.hash;
- }
- my $string = 'aaaaaaaa' ;
- my regex xxx { $<t1> = aa $<t2> = a a } ;
- my regex yyy { ($<t1> = [aa] ) ($<t2> = a) a } ;
- my regex zzz { ($<t1> = [aa] ) ($<t2> = a) a } ;
- my $m1 = $string ~~ m:g/<xxx>/;
- my $m2 = $string ~~ m:g/<yyy>/;
- my $m3 = $string ~~ m:g/<yyy>/;
- my $m4 = $string ~~ m:g/<zzz>/;
- my $ml1 = $string ~~ my regex y1 { ($<t1> = [aa] ) ($<t2> = a) a };
- my $ml2 = $string ~~ my regex y2 { ($<t1> = [aa] ) ($<t2> = a) a };
- my $ml3 = $string ~~ &yyy;
- my $ml4 = $string ~~ &zzz;
- my $t1 = $m1 eqv $m1;
- my $t2 = $m1 eqv $m2;
- my $t3 = $m2 eqv $m1;
- my $t4 = $m2 eqv $m2;
- my $t5 = $m3 eqv $m2;
- my $t6 = $m4 eqv $m2;
- my $t_lex_1 = $ml1 eqv $ml2;
- my $t_lex_2 = $ml3 eqv $ml4;
- my $t_im1 = ('aaa' ~~ /a(..)/) eqv ('aaa' ~~ /a../);
- my $t_im2 = ('a' ~~ /(.)/) eqv ('ab' ~~ /(.)/);
- say "$t1 / $t2 / $t3 / $t4 / $t5 / $t6";
- say "$t_lex_1 / $t_lex_2";
- say "$t_im1 / $t_im2";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement