raku / atom-language Goto Github PK
View Code? Open in Web Editor NEWAtom/Github Raku Syntax Highlighting Support 🦋
License: Other
Atom/Github Raku Syntax Highlighting Support 🦋
License: Other
Describe what you see, what you want to see, and perhaps some linkage to docs, synopses, or irclog chatter.
Syntax Highlighting on lines with < is wrong
on the web page the characters after a "<" up to the next ">" are in a single "span" and have a "string" class
on https://docs.perl6.org/syntax/loop
(loop ( my $i = 0; $i++ < 3;) { $i * 2 }).say; #-> "(2 4 6)"
Providing a picture means that if the issue is fixed and linguist updates to include the fix (linguist uses this package to highlight Perl 6 on GitHub), your issue will remain historically viewable.
P.S.: Found this one in roast. At the end of that file even if I place extra quotes into comments the highlighting is still messed up. Not sure if that's simply a fail in my attempt of unbreaking it or if there's something else that's messing them up
sub circumfix:<x y> {} # this comment is good
sub circumfix:<w "> {} # this comment is not highlighted right
say 'hello " world'; # the `"` in the string fixes the messup
Describe what you see, what you want to see, and perhaps some linkage to docs, synopses, or irclog chatter.
.match(/^.* $subname/) # fine
.match(/^.* '/' $subname/) # nope
Providing a picture means that if the issue is fixed and linguist updates to include the fix (linguist uses this package to highlight Perl 6 on GitHub), your issue will remain historically viewable.
The sub part highlights as if it were the sub's name
multi sub mkdir(Int:D $mode, *@dirnames --> List)
multi sub mkdir($path, $mode = 0o777 --> Bool)
method mkdir(IO::Path:D: $mode = 0o777 --> Bool)
Taken from: MadcapJake/language-perl6fe#24
"@a[1] should highlight the subscript"
"$b.foo() should highlight the method call" # I think this does require the postcircumfix parens
Putting a +, -, or U+2212 minus on a factional number without whole part makes it not highlight as number
is-deeply pb( '.42', 10), .42, 'fractional without whole part';
is-deeply pb('+.42', 10), .42, 'fractional without whole part with +';
is-deeply pb('-.42', 10), -.42, 'fractional without whole part with -';
is-deeply pb('−.42', 10), -.42, 'fractional without whole part with U+2212';
Taken from MadcapJake/language-perl6fe#41
Compare the following:
say "Nick [{$<nick>}] Units [{$<units>}] Time [{$<time>}] Message [{$<message>}]";
my $got = string-to-secs("$<time> $<units>");
I'm on 1.13.3.
Seems to be caused by \\
in regex (seems to not be broken on GitHub... unsure why)
sub MAIN ( Str $app, Str :$w = 'lib,bin') {
my @watchlist = $w.split: /<!after \\> \,/;
s/\\\,/,/ for @watchlist;
say "Attempting to boot up the app";
my $p = bootup-app $app;
react {
whenever watch-recursive(@watchlist.grep: *.IO.e) -> $e {
say "Change detected [$e.path(), $e.event()]. Restarting app";
$p.kill;
$p = bootup-app $app;
}
}
}
I'm on v1.13.1
for <
$* $" $$ $; $& $` $' $, $. $\ $| $? $@ $]
$: $= $% $^ $~ @- @+ %- %+ %!
> {
throws-like "$_ = 1;", X::Syntax::Perl5Var, "Did $_ throw Perl5Var?";
}
# blah blah
Describe what you see, what you want to see, and perhaps some linkage to docs, synopses, or irclog chatter.
say "The capital of France is: %capitals<France>"
Providing a picture means that if the issue is fixed and linguist updates to include the fix (linguist uses this package to highlight Perl 6 on GitHub), your issue will remain historically viewable.
(Or create another repo in perl6 or add to Atom maybe.)
For example, add any chunks of configuration files or text to be be inserted. @samcv's .nav marker defs and the nav packag are some good ones to add here:
https://github.com/0tho/atom-nav-panel-plus
https://github.com/samcv/dot-files/blob/master/.nav-marker-rules
etc.
=head1 abecici
ethethe
my $s = sub ($a, $b) { $a + $b };
say $s.WHAT; # (Sub)
say $s(2, 5); # 7
sub postfix:<♥>($a){ say „I love $a!“ }
42♥;
# OUTPUT«I love 42!»
sub postcircumfix:<⸨ ⸩>(Positional $a, Whatever){ say $a[0], '…', $a[*-1] }
[1,2,3,4]⸨*⸩;
# OUTPUT«1…4»
constant term:<♥> = "♥"; # We don't want to quote "love", do we?
sub circumfix:<α ω>($a){ say „$a is the beginning and the end.“ };
α♥ω;
# OUTPUT«♥ is the beginning and the end.»
Taken from: MadcapJake/language-perl6fe#39
The closing bracket of the escape gets highlighted as closing bracket of the character class.
Example Code
/<[b]+[b\x[308]]>/
They work fine when they're on the same line, but when on separate lines they don't highlight.
=begin pod
approach is the use of Unicode properties. They are called in the form C<<
<:property> >>, where C<property>
I'm on v1.11.1
regex
keyword as part of a sub name breaks highlighting (see picture at end).
method quote:sym<s>($/) {
# We are emulating Str.subst/subst-mutate here, by calling match, assigning the result to
# a temporary variable etc.
# Build the regex.
my $rx_block := $*SUBST_LHS_BLOCK;
$rx_block.push(QAST::Stmts.new);
my %sig_info := hash(parameters => []);
###################################################
###################################################
###################################################
###################################################
#⟱⟱⟱⟱ glitch seems to start on the next line, right after word `regex`⟱⟱⟱⟱
###################################################
###################################################
my $rx_coderef := regex_coderef($/, $*W.stub_code_object('Regex'),
$<sibble><left>.ast, 'anon', '', %sig_info, $rx_block, :use_outer_match(1));
# Quote needs to be closure-i-fied.
my $infixish := $<sibble><infixish>;
my $right;
if !$infixish || $infixish.Str eq '=' {
$right := WANTED($<sibble><right>.ast,'quote:s///');
}
else {
$right := $infixish.ast;
$right.push(QAST::Op.new(
:op('assign'),
QAST::Op.new( :op('p6scalarfromdesc'), QAST::Op.new( :op('null') ) ),
QAST::Var.new( :name('$/'), :scope('lexical') )
));
$right.push(WANTED($<sibble><right>.ast,'quote:s'));
}
my $rep_block := $*SUBST_RHS_BLOCK;
$rep_block.push(QAST::Stmts.new($right, :node($<sibble><right>)));
$*W.cur_lexpad()[0].push($rep_block);
my $closure := block_closure(reference_to_code_object(
$*W.create_simple_code_object($rep_block, 'Code'),
$rep_block));
# self.match($rx_coderef, |%options);
my $past := QAST::Op.new( :node($/), :op('callmethod'), :name('match'),
WANTED(QAST::Var.new( :name('$_'), :scope('lexical') ),'s'),
$rx_coderef
);
self.handle_and_check_adverbs($/, %SUBST_ALLOWED_ADVERBS, 'substitution', $past);
if $/[0] {
$past.push(QAST::IVal.new(:named('samespace'), :value(1)));
}
my $samespace := +$/[0];
my $sigspace := $samespace;
my $samecase := 0;
my $samemark := 0;
my $global := 0;
for $<rx_adverbs>.ast {
if $_.named eq 'samecase' || $_.named eq 'ii' {
$samecase := 1;
}
elsif $_.named eq 'samemark' || $_.named eq 'mm' {
$samemark := 1;
}
elsif $_.named eq 'global' || $_.named eq 'g' {
$global := 1;
}
elsif $_.named eq 'samespace' || $_.named eq 'ss' {
$samespace := 1;
$sigspace := 1;
}
elsif $_.named eq 'sigspace' || $_.named eq 's' {
$sigspace := 1;
}
}
my $result := $past.unique('subst_result');
my $global_result := $past.unique('subst_global_result');
my $List := $*W.find_symbol(['List']);
my $apply_matches := QAST::Op.new( :op('callmethod'), :name('dispatch:<!>'),
QAST::Op.new( :op('callmethod'), :name('Str'),
WANTED(QAST::Var.new( :name('$_'), :scope('lexical') ),'s/apply') ),
QAST::SVal.new( :value('APPLY-MATCHES') ),
QAST::WVal.new( :value($*W.find_symbol(['Str'])) ),
QAST::Var.new( :name($result), :scope('local') ),
$closure,
QAST::Var.new( :name('$/'), :scope('lexical') ), # caller dollar slash
QAST::IVal.new( :value(1) ), # set dollar slash
QAST::IVal.new( :value($sigspace) ),
QAST::IVal.new( :value($samespace) ),
QAST::IVal.new( :value($samecase) ),
QAST::IVal.new( :value($samemark) ),
);
$past := QAST::Op.new( :op('locallifetime'), :node($/),
QAST::Stmt.new(
# my $result;
QAST::Var.new( :name($result), :scope('local'), :decl('var') ),
# $result := self.match(...
QAST::Op.new( :op('bind'),
QAST::Var.new( :name($result), :scope('local') ),
$past
),
QAST::Op.new( :op('p6store'),
QAST::Var.new( :name('$/'), :scope('lexical') ),
QAST::Var.new( :name($result), :scope('local') ),
),
# It matched something. Either a single item or a list of matches.
QAST::Op.new( :op('if'),
QAST::Op.new( :op('unless'),# :name('&infix:<||>'),
QAST::Op.new( :op('istype'),
QAST::Var.new( :name($result), :scope('local') ),
QAST::WVal.new( :value($*W.find_symbol(['Match'])) )
),
QAST::Op.new( :op('if'),
QAST::Op.new( :op('istype'),
QAST::Var.new( :name($result), :scope('local') ),
QAST::WVal.new( :value($*W.find_symbol(['Positional'])) )
),
QAST::Op.new( :op('callmethod'), :name('elems'),
QAST::Var.new( :name($result), :scope('local') )
)
)
),
QAST::Op.new( :op('call'), :name('&infix:<=>'),
WANTED(QAST::Var.new( :name($<sym> eq 's' ?? '$_' !! '$/'), :scope('lexical') ),'s/assign'),
$apply_matches
),
( $<sym> eq 'S'
?? QAST::Op.new( :op('p6store'),
QAST::Var.new( :name('$/'), :scope('lexical') ),
WANTED(QAST::Var.new( :name('$_'), :scope('lexical') ),'S'),
)
!! QAST::Stmt.new()
),
),
# It will return a list of matches when we match globally, and a single
# match otherwise.
$<sym> eq 's' ?? (
$global ??
QAST::Op.new( :op('p6store'),
QAST::Var.new( :name('$/'), :scope('lexical') ),
QAST::Stmts.new(
QAST::Op.new( :op('bind'),
QAST::Var.new( :name($global_result), :scope('local'), :decl('var') ),
QAST::Op.new( :op('callmethod'), :name('CREATE'),
QAST::WVal.new( :value($List) )
)
),
QAST::Op.new( :op('bindattr'),
QAST::Var.new( :name($global_result), :scope('local') ),
QAST::WVal.new( :value($List) ),
QAST::SVal.new( :value('$!reified') ),
QAST::Op.new( :op('getattr'),
QAST::Var.new( :name($result), :scope('local') ),
QAST::WVal.new( :value($List) ),
QAST::SVal.new( :value('$!reified') )
)
),
QAST::Var.new( :name($global_result), :scope('local') )
)
) !! QAST::Stmt.new()
) !! QAST::Stmt.new(),
# The result of this operation.
QAST::Var.new( :name('$/'), :scope('lexical') )
),
);
$past.annotate('is_S', $<sym> eq 'S');
make WANTED($past, 's///'); # never carp about s/// in sink context
}
Make keys and values differently colored for Pairs
Variables don't highlight correctly if they contain any non-ASCII characters. Pic attached. Screen shot using Atom editor with Perl 6 FE v1.13.1, One Dark theme.
$ΔxAB
$ABΔx
$S𝐼
@n⃗
Describe what you see, what you want to see, and perhaps some linkage to docs, synopses, or irclog chatter.
@array.max;
%hash{$key}:exists;
Providing a picture means that if the issue is fixed and linguist updates to include the fix (linguist uses this package to highlight Perl 6 on GitHub), your issue will remain historically viewable.
I'm using v1.9.5
method !blah
doesn't get highlighted. Making it public or making it a multi avoids the issue.
multi method stderr(Proc::Async:D: :$enc) {
self!wrap-decoder:
self!supply('stderr', $!stderr_supply, $!stderr_type, Chars).Supply,
$enc
}
method !wrap-decoder(Supply:D $bin-supply, $enc) {
Rakudo::Internals.BYTE_SUPPLY_DECODER($bin-supply, $enc // $!enc)
}
method !capture(\callbacks,\std,\the-supply) {
my $promise = Promise.new;
my $vow = $promise.vow;
my $ss = Rakudo::Internals::SupplySequencer.new(
on-data-ready => -> \data { the-supply.emit(data) },
on-completed => -> { the-supply.done(); $vow.keep(the-supply) },
on-error => -> \err { the-supply.quit(err); $vow.keep((the-supply,err)) });
nqp::bindkey(callbacks,
std ~ '_bytes' ,
-> Mu \seq, Mu \data, Mu \err { $ss.process(seq, data, err) });
$promise;
}
See above.
Supplier # not highlighted
Supply # highlighted
As the subject says, methods are sometimes highlighted as keywords. See these lines taken from https://docs.perl6.org/language/concurrency :
my $p2 = Promise.new;
$p2.break('oh no');
my $promise1 = Promise.in(5);
my $promise2 = $promise1.then(-> $v { say $v.status; 'Second Result' });
say $promise2.result;
my $promise = Promise.start({ die "Broken Promise" });
try $promise2.result;
Note how .break
and .start
are highlighted differently from .in
, .then
, and .result
-- and the same as try
. This is easier to see on docs.perl6.org than on GitHub due to stylesheet differences.
Causes problem with Fira Code ligatures and should make sure it is one token
==>
Providing a picture means that if the issue is fixed and linguist updates to include the fix (linguist uses this package to highlight Perl 6 on GitHub), your issue will remain historically viewable.
Describe what you see, what you want to see, and perhaps some linkage to docs, synopses, or irclog chatter.
/^./ # nope
/^ ./ # shows up fine
Providing a picture means that if the issue is fixed and linguist updates to include the fix (linguist uses this package to highlight Perl 6 on GitHub), your issue will remain historically viewable.
master
Taken from: MadcapJake/language-perl6fe#32
Issue Description
The :sym<> adverb is specially highlighted on tokens and rules when used inside regexes,
but it's highlighted as a normal name when used in the actions class. It would be useful to highlight it specially there as well:
Example Code
grammar Calculator {
token TOP { <calc-op> }
proto rule calc-op {*}
rule calc-op:sym<add> { <num> '+' <num> }
rule calc-op:sym<sub> { <num> '-' <num> }
token num { \d+ }
}
class Calculations {
method TOP ($/) { make $<calc-op>.made; }
method calc-op:sym<add> ($/) { make [+] $<num>; }
method calc-op:sym<sub> ($/) { make [-] $<num>; }
}
say Calculator.parse('2 + 3', actions => Calculations).made;
I'm on v1.9.7
Fully qualified method names not highlighted. I expected them to be highlighted same as normal methods (or fancier).
.List::perl
in the code below is not highlited.
augment class List {
multi method perl2(List:D:) {
self.List::perl;
self.perl;
}
}
Had this happen with multi sub I think. Same thing as before. Need to fix it and write some tests so this does not break.
proto method rename(|) { * }
Providing a picture means that if the issue is fixed and linguist updates to include the fix (linguist uses this package to highlight Perl 6 on GitHub), your issue will remain historically viewable.
rx/ "$var" /
I'm on v1.11.2
The regexes in S///
and s///
operators seem to be not highlighted, or (like the <before>
) highlighted differently.
Note that these operators can take adverbs (like S:g///
) and there are some other forms for them (I always forms for them (like say S{foo} = {} given "foobar";
or say S ♥foo♥bar♥ with "foobar"
)
/<before \s+>/;
S/<before \s+>//;
s/<before \s+>//;
/\s+\s+\s+\s+/;
S/\s+\s+\s+\s+//;
s/\s+\s+\s+\s+//;
<hello> #fine
<hello}> #doesn't work
=begin pod
C«test» # valid (but not working)
C<<test>> # also valid (working)
C<test> # valid (working)
It is fine that they are tagged as part of the class name, but we need to additionally tag the ::
themselves or they will end up being highlighted the same as the actual words in the name.
my class X::Str::Sprintf::Directives::BadType { ... };
Providing a picture means that if the issue is fixed and linguist updates to include the fix (linguist uses this package to highlight Perl 6 on GitHub), your issue will remain historically viewable.
See:
https://docs.perl6.org/language/quoting#Shell_quoting_with_interpolation:_qqx
say qqx{echo "hello $world"}; # hello there
method Rat(Real:D: Real $epsilon = 1e-6)
https://docs.perl6.org/type/Duration#(Real)_method_Rat
17:55Z samcv: too lazy to make an Issue, but noticed this chunk has messed up highlighting: https://github.com/rakudo/rakudo/blob/nom/src/Perl6/Grammar.nqp#L839-L857
Note that until Github updates their branch, keys don't highlight no matter where they are used on Github
NFKD_QC=>'NFKD_Quick_Check',Ext=>'Extender',NFKC_QC=>'NFKC_Quick_Check',
CE=>'Composition_Exclusion',Alpha=>'Alphabetic',stc=>'Simple_Titlecase_Mapping',
OAlpha=>'Other_Alphabetic',XIDC=>'XID_Continue',age=>'Age';
Describe what you see, what you want to see, and perhaps some linkage to docs, synopses, or irclog chatter.
«a b c» # no highlight
<a b c> # highlight
Providing a picture means that if the issue is fixed and linguist updates to include the fix (linguist uses this package to highlight Perl 6 on GitHub), your issue will remain historically viewable.
I'm on 1.13.8
The token with :sym<💬>
breaks highlights of code that follows it. I also notice that writing it as
token statement:sym<💬> {
<sym> <.ws> <EXPR>
}
instead of all on one line as token statement:sym<💬> { <sym> <.ws> <EXPR> }
avoids the issue.
EDIT: but I notice that even in multi-line version, putting a comment inside of it doesn't highlight the comment as the comment
proto token statement {*}
token statement:sym<EXPR> { <EXPR> }
token statement:sym<💬> { <sym> <.ws> <EXPR> }
token statement:sym<fuc> { <sym> }
proto token sign {*}
token sign:sym<−> { '−' }
token sign:sym<+> { '+'? }
proto token value {*}
token value:sym<string> { <?["']> <quote_EXPR: ':q'> }
token value:sym<integer> { <sign> $<num>=\d+ }
token value:sym<float> { <sign> $<num>=[\d+ '.' \d+] }
Putting spaces around / division operator breaks highlights
# This block is OK, because 1/4 ain't got spaces between the operator and the numbers
isa-ok(Rat.new(1,4), Rat, "Rat.new makes a Rat");
isa-ok(1/4, Rat, "/ makes a Rat");
isa-ok( 1.Int.Rat, Rat, "cast of Int makes a Rat");
isa-ok( 1.Num.Rat, Rat, "cast of Num makes a Rat");
# This one blows up because there are spaces between 1, /, and 4
isa-ok(Rat.new(1,4), Rat, "Rat.new makes a Rat");
isa-ok(1 / 4, Rat, "/ makes a Rat");
isa-ok( 1.Int.Rat, Rat, "cast of Int makes a Rat");
isa-ok( 1.Num.Rat, Rat, "cast of Num makes a Rat");
Describe what you see, what you want to see, and perhaps some linkage to docs, synopses, or irclog chatter.
Providing a picture means that if the issue is fixed and linguist updates to include the fix (linguist uses this package to highlight Perl 6 on GitHub), your issue will remain historically viewable.
I'm on v1.11.2
Opening regex capture marker breaks highlights until closing capture marker is seen, when used in a regex given to a method called with .foo()
form, even though everything's fine when .foo:
form call is used.
say 'foo'.subst( / 'fo' <( 'o' /, 'x');
say "Hi"; # Opps broken highlights now )> # fixed now
say 'foo'.subst: / 'fo' <( 'o' /, 'x';
# Doesn't happen with this method call form tho
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.