mirror of
https://github.com/KevinMidboe/linguist.git
synced 2026-01-01 15:06:16 +00:00
Merge branch 'pr/750' into perl_6
Conflicts: lib/linguist/samples.json
This commit is contained in:
@@ -1206,16 +1206,30 @@ Perl:
|
|||||||
primary_extension: .pl
|
primary_extension: .pl
|
||||||
extensions:
|
extensions:
|
||||||
- .PL
|
- .PL
|
||||||
- .nqp
|
|
||||||
- .perl
|
- .perl
|
||||||
- .ph
|
- .ph
|
||||||
- .plx
|
- .plx
|
||||||
- .pm6
|
- .pm
|
||||||
- .pod
|
- .pod
|
||||||
- .psgi
|
- .psgi
|
||||||
interpreters:
|
interpreters:
|
||||||
- perl
|
- perl
|
||||||
|
|
||||||
|
Perl6:
|
||||||
|
type: programming
|
||||||
|
color: "#0298c3"
|
||||||
|
primary_extension: .p6
|
||||||
|
extensions:
|
||||||
|
- .6pl
|
||||||
|
- .6pm
|
||||||
|
- .nqp
|
||||||
|
- .p6l
|
||||||
|
- .p6m
|
||||||
|
- .pl
|
||||||
|
- .pl6
|
||||||
|
- .pm
|
||||||
|
- .pm6
|
||||||
|
|
||||||
Pike:
|
Pike:
|
||||||
type: programming
|
type: programming
|
||||||
color: "#066ab2"
|
color: "#066ab2"
|
||||||
|
|||||||
@@ -291,6 +291,10 @@
|
|||||||
".script!",
|
".script!",
|
||||||
".t"
|
".t"
|
||||||
],
|
],
|
||||||
|
"Perl6": [
|
||||||
|
".p6",
|
||||||
|
".pm6"
|
||||||
|
],
|
||||||
"PHP": [
|
"PHP": [
|
||||||
".module",
|
".module",
|
||||||
".php",
|
".php",
|
||||||
@@ -508,8 +512,8 @@
|
|||||||
".gemrc"
|
".gemrc"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"tokens_total": 432361,
|
"tokens_total": 432733,
|
||||||
"languages_total": 502,
|
"languages_total": 505,
|
||||||
"tokens": {
|
"tokens": {
|
||||||
"ABAP": {
|
"ABAP": {
|
||||||
"*/**": 1,
|
"*/**": 1,
|
||||||
@@ -36838,6 +36842,131 @@
|
|||||||
"reference.": 1,
|
"reference.": 1,
|
||||||
"AUTHOR": 1
|
"AUTHOR": 1
|
||||||
},
|
},
|
||||||
|
"Perl6": {
|
||||||
|
"token": 6,
|
||||||
|
"pod_formatting_code": 1,
|
||||||
|
"{": 29,
|
||||||
|
"<code>": 1,
|
||||||
|
"<[A..Z]>": 1,
|
||||||
|
"*POD_IN_FORMATTINGCODE": 1,
|
||||||
|
"}": 27,
|
||||||
|
"<content>": 1,
|
||||||
|
"[": 1,
|
||||||
|
"<!before>": 1,
|
||||||
|
"#": 13,
|
||||||
|
"N*": 1,
|
||||||
|
"role": 10,
|
||||||
|
"q": 5,
|
||||||
|
"stopper": 2,
|
||||||
|
"MAIN": 1,
|
||||||
|
"quote": 1,
|
||||||
|
")": 19,
|
||||||
|
"backslash": 3,
|
||||||
|
"sym": 3,
|
||||||
|
"<\\\\>": 1,
|
||||||
|
"<text=.sym>": 1,
|
||||||
|
"<stopper>": 1,
|
||||||
|
"<text=.stopper>": 1,
|
||||||
|
"<miscq>": 1,
|
||||||
|
".": 1,
|
||||||
|
"method": 2,
|
||||||
|
"tweak_q": 1,
|
||||||
|
"(": 16,
|
||||||
|
"v": 2,
|
||||||
|
"self.panic": 2,
|
||||||
|
"tweak_qq": 1,
|
||||||
|
"qq": 5,
|
||||||
|
"does": 7,
|
||||||
|
"b1": 1,
|
||||||
|
"c1": 1,
|
||||||
|
"s1": 1,
|
||||||
|
"a1": 1,
|
||||||
|
"h1": 1,
|
||||||
|
"f1": 1,
|
||||||
|
"Too": 2,
|
||||||
|
"late": 2,
|
||||||
|
"for": 2,
|
||||||
|
"SHEBANG#!perl": 1,
|
||||||
|
"use": 1,
|
||||||
|
"v6": 1,
|
||||||
|
";": 19,
|
||||||
|
"my": 10,
|
||||||
|
"string": 7,
|
||||||
|
"if": 1,
|
||||||
|
"eq": 1,
|
||||||
|
"say": 10,
|
||||||
|
"regex": 2,
|
||||||
|
"http": 1,
|
||||||
|
"-": 3,
|
||||||
|
"verb": 1,
|
||||||
|
"|": 9,
|
||||||
|
"multi": 2,
|
||||||
|
"line": 5,
|
||||||
|
"comment": 2,
|
||||||
|
"I": 1,
|
||||||
|
"there": 1,
|
||||||
|
"m": 2,
|
||||||
|
"even": 1,
|
||||||
|
"specialer": 1,
|
||||||
|
"nesting": 1,
|
||||||
|
"work": 1,
|
||||||
|
"<": 3,
|
||||||
|
"trying": 1,
|
||||||
|
"mixed": 1,
|
||||||
|
"delimiters": 1,
|
||||||
|
"<Hooray,>": 1,
|
||||||
|
"arbitrary": 2,
|
||||||
|
"delimiter": 2,
|
||||||
|
"Hooray": 1,
|
||||||
|
"<now>": 1,
|
||||||
|
"with": 9,
|
||||||
|
"whitespace": 1,
|
||||||
|
"<<": 1,
|
||||||
|
"more": 1,
|
||||||
|
"strings": 1,
|
||||||
|
"%": 1,
|
||||||
|
"hash": 1,
|
||||||
|
"Hash.new": 1,
|
||||||
|
"begin": 1,
|
||||||
|
"pod": 1,
|
||||||
|
"Here": 1,
|
||||||
|
"t": 2,
|
||||||
|
"highlighted": 1,
|
||||||
|
"table": 1,
|
||||||
|
"Of": 1,
|
||||||
|
"things": 1,
|
||||||
|
"A": 3,
|
||||||
|
"single": 3,
|
||||||
|
"declarator": 7,
|
||||||
|
"a": 8,
|
||||||
|
"keyword": 7,
|
||||||
|
"like": 7,
|
||||||
|
"Another": 2,
|
||||||
|
"block": 2,
|
||||||
|
"brace": 1,
|
||||||
|
"More": 2,
|
||||||
|
"blocks": 2,
|
||||||
|
"don": 2,
|
||||||
|
"x": 2,
|
||||||
|
"foo": 3,
|
||||||
|
"Rob": 1,
|
||||||
|
"food": 1,
|
||||||
|
"match": 1,
|
||||||
|
"sub": 1,
|
||||||
|
"something": 1,
|
||||||
|
"Str": 1,
|
||||||
|
"D": 1,
|
||||||
|
"value": 1,
|
||||||
|
"...": 1,
|
||||||
|
"s": 1,
|
||||||
|
"some": 2,
|
||||||
|
"stuff": 1,
|
||||||
|
"chars": 1,
|
||||||
|
"/": 1,
|
||||||
|
"<foo>": 1,
|
||||||
|
"<bar>": 1,
|
||||||
|
"roleq": 1
|
||||||
|
},
|
||||||
"PHP": {
|
"PHP": {
|
||||||
"<": 11,
|
"<": 11,
|
||||||
"php": 12,
|
"php": 12,
|
||||||
@@ -46053,6 +46182,7 @@
|
|||||||
"Parrot Internal Representation": 5,
|
"Parrot Internal Representation": 5,
|
||||||
"Pascal": 30,
|
"Pascal": 30,
|
||||||
"Perl": 17497,
|
"Perl": 17497,
|
||||||
|
"Perl6": 372,
|
||||||
"PHP": 20724,
|
"PHP": 20724,
|
||||||
"Pod": 658,
|
"Pod": 658,
|
||||||
"PogoScript": 250,
|
"PogoScript": 250,
|
||||||
@@ -46188,6 +46318,7 @@
|
|||||||
"Parrot Internal Representation": 1,
|
"Parrot Internal Representation": 1,
|
||||||
"Pascal": 1,
|
"Pascal": 1,
|
||||||
"Perl": 14,
|
"Perl": 14,
|
||||||
|
"Perl6": 3,
|
||||||
"PHP": 9,
|
"PHP": 9,
|
||||||
"Pod": 1,
|
"Pod": 1,
|
||||||
"PogoScript": 1,
|
"PogoScript": 1,
|
||||||
@@ -46236,5 +46367,5 @@
|
|||||||
"Xtend": 2,
|
"Xtend": 2,
|
||||||
"YAML": 1
|
"YAML": 1
|
||||||
},
|
},
|
||||||
"md5": "e99dcf02f4e88803ef16d428e96fff9a"
|
"md5": "e37c904444acb66720269bef954d910e"
|
||||||
}
|
}
|
||||||
23
samples/Perl6/RoleQ.pm6
Normal file
23
samples/Perl6/RoleQ.pm6
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
role q {
|
||||||
|
token stopper { \' }
|
||||||
|
|
||||||
|
token escape:sym<\\> { <sym> <item=.backslash> }
|
||||||
|
|
||||||
|
token backslash:sym<qq> { <?before 'q'> <quote=.LANG('MAIN','quote')> }
|
||||||
|
token backslash:sym<\\> { <text=.sym> }
|
||||||
|
token backslash:sym<stopper> { <text=.stopper> }
|
||||||
|
|
||||||
|
token backslash:sym<miscq> { {} . }
|
||||||
|
|
||||||
|
method tweak_q($v) { self.panic("Too late for :q") }
|
||||||
|
method tweak_qq($v) { self.panic("Too late for :qq") }
|
||||||
|
}
|
||||||
|
|
||||||
|
role qq does b1 does c1 does s1 does a1 does h1 does f1 {
|
||||||
|
token stopper { \" }
|
||||||
|
token backslash:sym<unrec> { {} (\w) { self.throw_unrecog_backslash_seq: $/[0].Str } }
|
||||||
|
token backslash:sym<misc> { \W }
|
||||||
|
|
||||||
|
method tweak_q($v) { self.panic("Too late for :q") }
|
||||||
|
method tweak_qq($v) { self.panic("Too late for :qq") }
|
||||||
|
}
|
||||||
22
samples/Perl6/grammar-test.p6
Normal file
22
samples/Perl6/grammar-test.p6
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
token pod_formatting_code {
|
||||||
|
$<code>=<[A..Z]>
|
||||||
|
'<' { $*POD_IN_FORMATTINGCODE := 1 }
|
||||||
|
$<content>=[ <!before '>'> <pod_string_character> ]+
|
||||||
|
'>' { $*POD_IN_FORMATTINGCODE := 0 }
|
||||||
|
}
|
||||||
|
|
||||||
|
token pod_string {
|
||||||
|
<pod_string_character>+
|
||||||
|
}
|
||||||
|
|
||||||
|
token something:sym«<» {
|
||||||
|
<!>
|
||||||
|
}
|
||||||
|
|
||||||
|
token name {
|
||||||
|
<!>
|
||||||
|
}
|
||||||
|
|
||||||
|
token comment:sym<#> {
|
||||||
|
'#' {} \N*
|
||||||
|
}
|
||||||
252
samples/Perl6/test.p6
Normal file
252
samples/Perl6/test.p6
Normal file
@@ -0,0 +1,252 @@
|
|||||||
|
#!/usr/bin/env perl6
|
||||||
|
|
||||||
|
use v6;
|
||||||
|
|
||||||
|
my $string = 'I look like a # comment!';
|
||||||
|
|
||||||
|
if $string eq 'foo' {
|
||||||
|
say 'hello';
|
||||||
|
}
|
||||||
|
|
||||||
|
regex http-verb {
|
||||||
|
'GET'
|
||||||
|
| 'POST'
|
||||||
|
| 'PUT'
|
||||||
|
| 'DELETE'
|
||||||
|
| 'TRACE'
|
||||||
|
| 'OPTIONS'
|
||||||
|
| 'HEAD'
|
||||||
|
}
|
||||||
|
|
||||||
|
# a sample comment
|
||||||
|
|
||||||
|
say 'Hello from Perl 6!'
|
||||||
|
|
||||||
|
|
||||||
|
#`{
|
||||||
|
multi-line comment!
|
||||||
|
}
|
||||||
|
|
||||||
|
say 'here';
|
||||||
|
|
||||||
|
#`(
|
||||||
|
multi-line comment!
|
||||||
|
)
|
||||||
|
|
||||||
|
say 'here';
|
||||||
|
|
||||||
|
#`{{{
|
||||||
|
I'm a special comment!
|
||||||
|
}}}
|
||||||
|
|
||||||
|
say 'there';
|
||||||
|
|
||||||
|
#`{{
|
||||||
|
I'm { even } specialer!
|
||||||
|
}}
|
||||||
|
|
||||||
|
say 'there';
|
||||||
|
|
||||||
|
#`{{
|
||||||
|
does {{nesting}} work?
|
||||||
|
}}
|
||||||
|
|
||||||
|
#`«<
|
||||||
|
trying mixed delimiters
|
||||||
|
»
|
||||||
|
|
||||||
|
my $string = qq<Hooray, arbitrary delimiter!>;
|
||||||
|
my $string = qq«Hooray, arbitrary delimiter!»;
|
||||||
|
my $string = q <now with whitespace!>;
|
||||||
|
my $string = qq<<more strings>>;
|
||||||
|
|
||||||
|
my %hash := Hash.new;
|
||||||
|
|
||||||
|
=begin pod
|
||||||
|
|
||||||
|
Here's some POD! Wooo
|
||||||
|
|
||||||
|
=end pod
|
||||||
|
|
||||||
|
=for Testing
|
||||||
|
This is POD (see? role isn't highlighted)
|
||||||
|
|
||||||
|
say('this is not!');
|
||||||
|
|
||||||
|
=table
|
||||||
|
Of role things
|
||||||
|
|
||||||
|
say('not in your table');
|
||||||
|
#= A single line declarator "block" (with a keyword like role)
|
||||||
|
#| Another single line declarator "block" (with a keyword like role)
|
||||||
|
#={
|
||||||
|
A declarator block (with a keyword like role)
|
||||||
|
}
|
||||||
|
#|{
|
||||||
|
Another declarator block (with a keyword like role)
|
||||||
|
}
|
||||||
|
#= { A single line declarator "block" with a brace (with a keyword like role)
|
||||||
|
#=«
|
||||||
|
More declarator blocks! (with a keyword like role)
|
||||||
|
»
|
||||||
|
#|«
|
||||||
|
More declarator blocks! (with a keyword like role)
|
||||||
|
»
|
||||||
|
|
||||||
|
say 'Moar code!';
|
||||||
|
|
||||||
|
my $don't = 16;
|
||||||
|
|
||||||
|
sub don't($x) {
|
||||||
|
!$x
|
||||||
|
}
|
||||||
|
|
||||||
|
say don't 'foo';
|
||||||
|
|
||||||
|
my %hash = (
|
||||||
|
:foo(1),
|
||||||
|
);
|
||||||
|
|
||||||
|
say %hash<foo>;
|
||||||
|
say %hash<<foo>>;
|
||||||
|
say %hash«foo»;
|
||||||
|
|
||||||
|
say %*hash<foo>;
|
||||||
|
say %*hash<<foo>>;
|
||||||
|
say %*hash«foo»;
|
||||||
|
|
||||||
|
say $<todo>;
|
||||||
|
say $<todo>;
|
||||||
|
|
||||||
|
for (@A Z @B) -> $a, $b {
|
||||||
|
say $a + $b;
|
||||||
|
}
|
||||||
|
|
||||||
|
Q:PIR {
|
||||||
|
.loadlib "somelib"
|
||||||
|
}
|
||||||
|
|
||||||
|
my $longstring = q/
|
||||||
|
lots
|
||||||
|
of
|
||||||
|
text
|
||||||
|
/;
|
||||||
|
|
||||||
|
my $heredoc = q:to/END_SQL/;
|
||||||
|
SELECT * FROM Users
|
||||||
|
WHERE first_name = 'Rob'
|
||||||
|
END_SQL
|
||||||
|
my $hello;
|
||||||
|
|
||||||
|
# Fun with regexen
|
||||||
|
|
||||||
|
if 'food' ~~ /foo/ {
|
||||||
|
say 'match!'
|
||||||
|
}
|
||||||
|
|
||||||
|
my $re = /foo/;
|
||||||
|
my $re2 = m/ foo /;
|
||||||
|
my $re3 = m:i/ FOO /;
|
||||||
|
|
||||||
|
call-a-sub(/ foo /);
|
||||||
|
call-a-sub(/ foo \/ bar /);
|
||||||
|
|
||||||
|
my $re4 = rx/something | something-else/;
|
||||||
|
my $result = ms/regexy stuff/;
|
||||||
|
my $sub0 = s/regexy stuff/more stuff/;
|
||||||
|
my $sub = ss/regexy stuff/more stuff/;
|
||||||
|
my $trans = tr/regexy stuff/more stuff/;
|
||||||
|
|
||||||
|
my @values = <a b c d>;
|
||||||
|
call-sub(<a b c d>);
|
||||||
|
call-sub <a b c d>;
|
||||||
|
|
||||||
|
my $result = $a < $b;
|
||||||
|
|
||||||
|
for <a b c d> -> $letter {
|
||||||
|
say $letter;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub test-sub {
|
||||||
|
say @_;
|
||||||
|
say $!;
|
||||||
|
say $/;
|
||||||
|
say $0;
|
||||||
|
say $1;
|
||||||
|
say @*ARGS;
|
||||||
|
say $*ARGFILES;
|
||||||
|
say &?BLOCK;
|
||||||
|
say ::?CLASS;
|
||||||
|
say $?CLASS;
|
||||||
|
say @=COMMENT;
|
||||||
|
say %?CONFIG;
|
||||||
|
say $*CWD;
|
||||||
|
say $=data;
|
||||||
|
say %?DEEPMAGIC;
|
||||||
|
say $?DISTRO;
|
||||||
|
say $*DISTRO;
|
||||||
|
say $*EGID;
|
||||||
|
say %*ENV;
|
||||||
|
say $*ERR;
|
||||||
|
say $*EUID;
|
||||||
|
say $*EXECUTABLE_NAME;
|
||||||
|
say $?FILE;
|
||||||
|
say $?GRAMMAR;
|
||||||
|
say $*GID;
|
||||||
|
say $*IN;
|
||||||
|
say @*INC;
|
||||||
|
say %?LANG;
|
||||||
|
say $*LANG;
|
||||||
|
say $?LINE;
|
||||||
|
say %*META-ARGS;
|
||||||
|
say $?MODULE;
|
||||||
|
say %*OPTS;
|
||||||
|
say %*OPT;
|
||||||
|
say $?KERNEL;
|
||||||
|
say $*KERNEL;
|
||||||
|
say $*OUT;
|
||||||
|
say $?PACKAGE;
|
||||||
|
say $?PERL;
|
||||||
|
say $*PERL;
|
||||||
|
say $*PID;
|
||||||
|
say %=pod;
|
||||||
|
say $*PROGRAM_NAME;
|
||||||
|
say %*PROTOCOLS;
|
||||||
|
say ::?ROLE;
|
||||||
|
say $?ROLE;
|
||||||
|
say &?ROUTINE;
|
||||||
|
say $?SCOPE;
|
||||||
|
say $*TZ;
|
||||||
|
say $*UID;
|
||||||
|
say $?USAGE;
|
||||||
|
say $?VM;
|
||||||
|
say $?XVM;
|
||||||
|
}
|
||||||
|
|
||||||
|
say <a b c>;
|
||||||
|
|
||||||
|
my $perl5_re = m:P5/ fo{2} /;
|
||||||
|
my $re5 = rx«something | something-else»;
|
||||||
|
|
||||||
|
my $M := %*COMPILING<%?OPTIONS><M>;
|
||||||
|
|
||||||
|
say $M;
|
||||||
|
|
||||||
|
sub regex-name { ... }
|
||||||
|
my $pair = role-name => 'foo';
|
||||||
|
$pair = rolesque => 'foo';
|
||||||
|
|
||||||
|
my sub something(Str:D $value) { ... }
|
||||||
|
|
||||||
|
my $s = q«<
|
||||||
|
some
|
||||||
|
string
|
||||||
|
stuff
|
||||||
|
»;
|
||||||
|
|
||||||
|
my $regex = m«< some chars »;
|
||||||
|
# after
|
||||||
|
|
||||||
|
say $/<foo><bar>;
|
||||||
|
|
||||||
|
roleq;
|
||||||
Reference in New Issue
Block a user