This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Allow my \$a
[perl5.git] / perly.y
diff --git a/perly.y b/perly.y
index e7cea35..489291a 100644 (file)
--- 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); }
        ;