Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Support $$foo, @$foo and %$foo as equivalents for $($foo), @($foo) an…
…d %($foo).
  • Loading branch information
jnthn committed Oct 2, 2011
1 parent 3515e47 commit 1f1df92
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/Perl6/Actions.pm
Expand Up @@ -946,6 +946,12 @@ class Perl6::Actions is HLL::Actions {
$key, $value
)
}

method desigilname($/) {
if $<variable> {
make PAST::Op.new( :pasttype('callmethod'), $<variable>.ast );
}
}

method variable($/) {
my $past;
Expand All @@ -964,6 +970,12 @@ class Perl6::Actions is HLL::Actions {
elsif $<infixish> {
$past := PAST::Op.new( :pirop('find_sub_not_null__Ps'), '&infix:<' ~ $<infixish>.Str ~ '>' );
}
elsif $<desigilname><variable> {
$past := $<desigilname>.ast;
$past.name(~$<sigil> eq '@' ?? 'list' !!
~$<sigil> eq '%' ?? 'hash' !!
'item');
}
else {
if $<desigilname> && $<desigilname><longname> && self.is_indirect_lookup($<desigilname><longname>) {
if $*IN_DECL {
Expand Down
6 changes: 4 additions & 2 deletions src/Perl6/Grammar.pm
Expand Up @@ -1043,10 +1043,12 @@ grammar Perl6::Grammar is HLL::Grammar {
<.obs('$? variable as child error', '$!')>
}


token desigilname {
[
# | <?before '$' > <variable>
| <?before '$' >
[ <?{ $*IN_DECL }> <.panic: "Cannot declare an indirect variable name"> ]?
<variable>
| <?before <[\@\%\&]> <sigil>* \w > <.panic: "Invalid hard reference syntax">
| <longname>
]
}
Expand Down

0 comments on commit 1f1df92

Please sign in to comment.