X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=perly.y;h=922453797904a0862f6ef1540b58a5182b940b0d;hb=dc9da78b70f004446f5a9327eea553687ad8c180;hp=d87c8733630711313aea9ecfbac495354287a01a;hpb=0de566d74fdaf0a49123989fe8d4ad06603c6608;p=p5sagit%2Fp5-mst-13.2.git diff --git a/perly.y b/perly.y index d87c873..9224537 100644 --- a/perly.y +++ b/perly.y @@ -40,7 +40,7 @@ %token COLONATTR %type prog decl format startsub startanonsub startformsub -%type progstart remember mremember '&' +%type progstart remember mremember '&' savescope %type block mblock lineseq line loop cond else %type expr term subscripted scalar ary hsh arylen star amper sideff %type 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