Re: perldelta584
[p5sagit/p5-mst-13.2.git] / perly.y
diff --git a/perly.y b/perly.y
index d87c873..9224537 100644 (file)
--- a/perly.y
+++ b/perly.y
@@ -40,7 +40,7 @@
 %token COLONATTR
 
 %type <ival> prog decl format startsub startanonsub startformsub
-%type <ival> progstart remember mremember '&'
+%type <ival> progstart remember mremember '&' savescope
 %type <opval> block mblock lineseq line loop cond else
 %type <opval> expr term subscripted scalar ary hsh arylen star amper sideff
 %type <opval> argexpr nexpr texpr iexpr mexpr mnexpr mtexpr miexpr
@@ -116,16 +116,20 @@ mremember:        /* NULL */      /* start a partial lexical scope */
                        { $$ = block_start(FALSE); }
        ;
 
+savescope:     /* NULL */      /* remember stack pos in case of error */
+               { $$ = PL_savestack_ix; }
+
 /* A collection of "lines" in the program */
 lineseq        :       /* NULL */
                        { $$ = Nullop; }
        |       lineseq decl
                        { $$ = $1; }
-       |       lineseq line
-                       {   $$ = append_list(OP_LINESEQ,
-                               (LISTOP*)$1, (LISTOP*)$2);
+       |       lineseq savescope line
+                       {   LEAVE_SCOPE($2);
+                           $$ = append_list(OP_LINESEQ,
+                               (LISTOP*)$1, (LISTOP*)$3);
                            PL_pad_reset_pending = TRUE;
-                           if ($1 && $2) PL_hints |= HINT_BLOCK_SCOPE; }
+                           if ($1 && $3) PL_hints |= HINT_BLOCK_SCOPE; }
        ;
 
 /* A "line" in the program */
@@ -644,7 +648,7 @@ term        :       termbinop
                        { $$ = newUNOP(OP_NOT, 0, scalar($2)); }
        |       UNIOP                                /* Unary op, $_ implied */
                        { $$ = newOP($1, 0); }
-       |       UNIOP block                          /* eval { foo }, I *think* */
+       |       UNIOP block                          /* eval { foo } */
                        { $$ = newUNOP($1, 0, $2); }
        |       UNIOP term                           /* Unary op */
                        { $$ = newUNOP($1, 0, $2); }
@@ -662,9 +666,9 @@ term        :       termbinop
                        { $$ = newOP($1, OPf_SPECIAL); }
        |       FUNC1 '(' expr ')'                   /* not($foo) */
                        { $$ = newUNOP($1, 0, $3); }
-       |       PMFUNC '(' term ')'                  /* split (/foo/) */
+       |       PMFUNC '(' term ')'                  /* /foo/ */
                        { $$ = pmruntime($1, $3, Nullop); }
-       |       PMFUNC '(' term ',' term ')'         /* split (/foo/,$bar) */
+       |       PMFUNC '(' term ',' term ')'         /* s/foo/bar/ (or tr) */
                        { $$ = pmruntime($1, $3, $5); }
        |       WORD
        |       listop