Skip to content

Commit

Permalink
On MoarVM deprecate four Unicode 1 names with "\c[…]"
Browse files Browse the repository at this point in the history
This is in preparation for changes to MoarVM in which case only
canonical Alias Names will work for \c. For now we will deprecate and
allow them to still work, but warn the user and recommend alternatives
which are canonical Alias Names.
  • Loading branch information
samcv committed Jan 13, 2017
1 parent f10b09e commit e7c1d51
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/Perl6/Actions.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -9138,6 +9138,49 @@ class Perl6::Actions is HLL::Actions does STDActions {
}

class Perl6::QActions is HLL::Actions does STDActions {
# This overrides NQP during the deprecation period for Unicode 1 names not covered by Alias Names
method charname($/) {
#?if !moar
my $codepoint := $<integer>
?? $<integer>.made
!! nqp::codepointfromname(~$/);
$/.CURSOR.panic("Unrecognized character name $/") if $codepoint < 0;
make nqp::chr($codepoint);
#?endif
#?if moar
my $codepoint := $<integer>
?? nqp::chr($<integer>.made)
!! nqp::getstrfromname(~$/);
$codepoint := self.charname-notfound($/) if $codepoint eq '';
make $codepoint;
#?endif
}
method charname-notfound($/) {
my @worry-text := ( "LINE FEED, NEW LINE, END OF LINE, LF, NL or EOL",
"FORM FEED or FF",
"CARRIAGE RETURN or CR",
"NEXT LINE or NEL" );
my $text := "Deprecated character name %s in lookup of Unicode character by name.\n" ~
"Unicode 1 names are deprecated.\nPlease use %s";
if ~$/ eq "LINE FEED (LF)" {
$/.CURSOR.worry(nqp::sprintf($text, (~$/, @worry-text[0]) ) );
return nqp::chr(nqp::codepointfromname("LINE FEED"));
}
if ~$/ eq "FORM FEED (FF)" {
$/.CURSOR.worry(nqp::sprintf($text, (~$/, @worry-text[1]) ) );
return nqp::chr(nqp::codepointfromname("FORM FEED"));
}
if ~$/ eq "CARRIAGE RETURN (CR)" {
$/.CURSOR.worry(nqp::sprintf($text, (~$/, @worry-text[2]) ) );
return nqp::chr(nqp::codepointfromname("CARRIAGE RETURN"));
}
if ~$/ eq "NEXT LINE (NEL)" {
$/.CURSOR.worry(nqp::sprintf($text, (~$/, @worry-text[3]) ) );
return nqp::chr(nqp::codepointfromname("NEXT LINE"));
}

$/.CURSOR.panic("Unrecognized character name $/");
}
method nibbler($/) {
my @asts;
my $lastlit := '';
Expand Down

0 comments on commit e7c1d51

Please sign in to comment.