Skip to content

Commit

Permalink
Add language rules for Perl6 and its cousin Not Quite Perl (#274)
Browse files Browse the repository at this point in the history
* 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
alekratz authored and Aaronepower committed Oct 15, 2018
1 parent 9d8e28a commit 21f6fc0
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
32 changes: 32 additions & 0 deletions languages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,38 @@
"pm"
]
},
"Perl6":{
"line_comment":[
"#"
],
"multi_line":[
["=begin", "=end"]
],
"quotes":[
["\\\"", "\\\""],
["'", "'"]
],
"extensions":[
"pl6",
"pm6"
]
},
"NotQuitePerl":{
"name": "Not Quite Perl",
"line_comment":[
"#"
],
"multi_line":[
["=begin", "=end"]
],
"quotes":[
["\\\"", "\\\""],
["'", "'"]
],
"extensions":[
"nqp"
]
},
"Php":{
"name":"PHP",
"line_comment":[
Expand Down
24 changes: 24 additions & 0 deletions tests/data/nqp.nqp
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;
}
}
11 changes: 11 additions & 0 deletions tests/data/perl6.pl6
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';

0 comments on commit 21f6fc0

Please sign in to comment.