Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Support the short type-casting syntax from S13.
  • Loading branch information
jnthn committed Mar 1, 2012
1 parent 59c1c35 commit 3eded7b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
19 changes: 16 additions & 3 deletions src/Perl6/Actions.pm
Expand Up @@ -1836,7 +1836,20 @@ class Perl6::Actions is HLL::Actions {
$past[1] := wrap_return_handler($past[1]);
}
}
$past.name($<longname> ?? $<longname>.Str !! '<anon>');

my $name;
if $<longname> {
$name := $<longname>.Str;
}
elsif $<sigil> {
if $<sigil> eq '@' { $name := 'postcircumfix:<[ ]>' }
elsif $<sigil> eq '%' { $name := 'postcircumfix:<{ }>' }
elsif $<sigil> eq '&' { $name := 'postcircumfix:<( )>' }
else {
$/.CURSOR.panic("Cannot use " ~ $<sigil> ~ " sigil as a method name");
}
}
$past.name($name ?? $name !! '<anon>');
$past.nsentry('');

# Do the various tasks to trun the block into a method code object.
Expand All @@ -1862,8 +1875,8 @@ class Perl6::Actions is HLL::Actions {
}

# Install method.
if $<longname> {
install_method($/, $<longname>.Str, $*SCOPE, $code, $outer,
if $name {
install_method($/, $name, $*SCOPE, $code, $outer,
:private($<specials> && ~$<specials> eq '!'));
}
elsif $*MULTINESS {
Expand Down
13 changes: 10 additions & 3 deletions src/Perl6/Grammar.pm
Expand Up @@ -1527,9 +1527,16 @@ grammar Perl6::Grammar is HLL::Grammar {
[
<.newpad>
[
| $<specials>=[<[ ! ^ ]>?]<longname> [ '(' <multisig> ')' ]? <trait>*
| [ '(' <multisig> ')' ]? <trait>*
| <?>
| $<specials>=[<[ ! ^ ]>?]<longname> [ '(' <multisig> ')' ]? <trait>*
| '(' <multisig> ')' <trait>*
| <sigil>'.':!s
[
| '(' ~ ')' <multisig>
| '[' ~ ']' <multisig>
| '{' ~ '}' <multisig>
]:s
<trait>*
| <?>
]
{ $*IN_DECL := ''; }
[
Expand Down

0 comments on commit 3eded7b

Please sign in to comment.