-
-
Notifications
You must be signed in to change notification settings - Fork 532
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add language rules for Perl6 and its cousin Not Quite Perl (#274)
* Add Perl6 rule Signed-off-by: Alek Ratzloff <alekratz@gmail.com> * Add Not Quite Perl rule Signed-off-by: Alek Ratzloff <alekratz@gmail.com> * Add Perl6 test Signed-off-by: Alek Ratzloff <alekratz@gmail.com> * Fix Perl6 test, oops Signed-off-by: Alek Ratzloff <alekratz@gmail.com> * Add Not Quite Perl test Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
- Loading branch information
1 parent
9d8e28a
commit 21f6fc0
Showing
3 changed files
with
67 additions
and
0 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,24 @@ | ||
# 24 lines 15 code 7 comments 2 blanks | ||
=begin | ||
Regex methods and functions | ||
=end | ||
|
||
=begin item match | ||
Match C<$text> against C<$regex>. If the C<$global> flag is | ||
given, then return an array of all non-overlapping matches. | ||
=end item | ||
|
||
sub match ($text, $regex, :$global?) { | ||
my $match := $text ~~ $regex; | ||
if $global { | ||
my @matches; | ||
while $match { | ||
nqp::push(@matches, $match); | ||
$match := $match.parse($text, :rule($regex), :c($match.to)); | ||
} | ||
@matches; | ||
} | ||
else { | ||
$match; | ||
} | ||
} |
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,11 @@ | ||
# 11 lines 5 code 4 comments 2 blanks | ||
|
||
=begin pod | ||
Defines a fun infix operator. | ||
This was stolen from http://tpm2016.zoffix.com/#/14 | ||
=end pod | ||
sub infix:<¯\(°_o)/¯> { | ||
($^a, $^b).pick | ||
} | ||
|
||
say 'Coke' ¯\(°_o)/¯ 'Pepsi'; |