summaryrefslogtreecommitdiff
path: root/perly.y
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2016-05-20 22:28:31 -0700
committerFather Chrysostomos <sprout@cpan.org>2016-07-17 11:24:06 -0700
commite118fea3ba754e973a9016295ef418b1aacb88b1 (patch)
treee9d8748b2870f675953fb88e2a11d44b04594065 /perly.y
parentbec88f1bea9be699db294f4c38b20fef00a7f605 (diff)
downloadperl-e118fea3ba754e973a9016295ef418b1aacb88b1.tar.gz
Allow my \$a
This applies to ‘my’, ‘our’, ‘state’ and ‘local’, and both to single variable and lists of variables, in all their variations: my \$a # equivalent to \my $a my \($a,$b) # equivalent to \my($a, $b) my (\($a,$b)) # same my (\$a, $b) # equivalent to (\my $a, $b)
Diffstat (limited to 'perly.y')
-rw-r--r--perly.y18
1 files changed, 13 insertions, 5 deletions
diff --git a/perly.y b/perly.y
index e7cea356d4..489291a016 100644
--- a/perly.y
+++ b/perly.y
@@ -418,18 +418,18 @@ barestmt: PLUGSTMT
op_lvalue($2, OP_ENTERLOOP), $5, $7, $8));
parser->copline = (line_t)$1;
}
- | FOR REFGEN MY remember my_var
- { parser->in_my = 0; $<opval>$ = my($5); }
+ | FOR my_refgen remember my_var
+ { parser->in_my = 0; $<opval>$ = my($4); }
'(' mexpr ')' mblock cont
{
$$ = block_end(
- $4,
+ $3,
newFOROP(0,
op_lvalue(
newUNOP(OP_REFGEN, 0,
- $<opval>6),
+ $<opval>5),
OP_ENTERLOOP),
- $8, $10, $11)
+ $7, $9, $10)
);
parser->copline = (line_t)$1;
}
@@ -886,6 +886,8 @@ term : termbinop
{ $$ = newCONDOP(0, $1, $3, $5); }
| REFGEN term /* \$x, \@y, \%z */
{ $$ = newUNOP(OP_REFGEN, 0, $2); }
+ | MY REFGEN term
+ { $$ = newUNOP(OP_REFGEN, 0, localize($3,1)); }
| myattrterm %prec UNIOP
{ $$ = $1; }
| LOCAL term %prec UNIOP
@@ -1041,6 +1043,8 @@ myattrterm: MY myterm myattrlist
{ $$ = my_attrs($2,$3); }
| MY myterm
{ $$ = localize($2,1); }
+ | MY REFGEN myterm myattrlist
+ { $$ = newUNOP(OP_REFGEN, 0, my_attrs($3,$4)); }
;
/* Things that can be "my"'d */
@@ -1091,6 +1095,10 @@ refgen_topic: my_var
| amper
;
+my_refgen: MY REFGEN
+ | REFGEN MY
+ ;
+
amper : '&' indirob
{ $$ = newCVREF($1,$2); }
;