X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=perly.y;h=a61a6b30fb3c604fbe9e28ffe475e960a7b317a0;hb=c8937c7ebe545f1bf57f394227d99d1f8f445ef6;hp=0616692470ab9521045189e15ec104f54795d1b0;hpb=6fa4d285bff5644bebb95aff09143322042282cc;p=p5sagit%2Fp5-mst-13.2.git diff --git a/perly.y b/perly.y index 0616692..a61a6b3 100644 --- a/perly.y +++ b/perly.y @@ -73,6 +73,7 @@ %token WORD METHOD FUNCMETH THING PMFUNC PRIVATEREF %token FUNC0SUB UNIOPSUB LSTOPSUB +%token PLUGEXPR PLUGSTMT %token LABEL %token FORMAT SUB ANONSUB PACKAGE USE %token WHILE UNTIL IF UNLESS ELSE ELSIF CONTINUE FOR @@ -157,7 +158,7 @@ remember: /* NULL */ /* start a full lexical scope */ ; mydefsv: /* NULL */ /* lexicalize $_ */ - { $$ = (I32) allocmy("$_"); } + { $$ = (I32) Perl_allocmy(aTHX_ STR_WITH_LEN("$_"), 0); } ; progstart: @@ -241,6 +242,8 @@ line : label cond } }) } + | label PLUGSTMT + { $$ = newSTATEOP(0, PVAL($1), $2); } ; /* An expression which may have a side-effect */ @@ -329,7 +332,7 @@ cont : /* NULL */ /* Loops: while, until, for, and a bare block */ loop : label WHILE '(' remember texpr ')' mintro mblock cont { OP *innerop; - PL_parser->copline = (line_t)$2; + PL_parser->copline = (line_t)IVAL($2); $$ = block_end($4, newSTATEOP(0, PVAL($1), innerop = newWHILEOP(0, 1, (LOOP*)(OP*)NULL, @@ -342,7 +345,7 @@ loop : label WHILE '(' remember texpr ')' mintro mblock cont | label UNTIL '(' remember iexpr ')' mintro mblock cont { OP *innerop; - PL_parser->copline = (line_t)$2; + PL_parser->copline = (line_t)IVAL($2); $$ = block_end($4, newSTATEOP(0, PVAL($1), innerop = newWHILEOP(0, 1, (LOOP*)(OP*)NULL, @@ -424,7 +427,7 @@ loop : label WHILE '(' remember texpr ')' mintro mblock cont /* Switch blocks */ switch : label GIVEN '(' remember mydefsv mexpr ')' mblock - { PL_parser->copline = (line_t) $2; + { PL_parser->copline = (line_t) IVAL($2); $$ = block_end($4, newSTATEOP(0, PVAL($1), newGIVENOP($6, scope($8), @@ -508,7 +511,9 @@ peg : PEG ; format : FORMAT startformsub formname block - { SvREFCNT_inc_simple_void(PL_compcv); + { + CV *fmtcv = PL_compcv; + SvREFCNT_inc_simple_void(PL_compcv); #ifdef MAD $$ = newFORM($2, $3, $4); prepend_madprops($1->tk_mad, $$, 'F'); @@ -518,6 +523,10 @@ format : FORMAT startformsub formname block newFORM($2, $3, $4); $$ = (OP*)NULL; #endif + if (CvOUTSIDE(fmtcv) && !CvUNIQUE(CvOUTSIDE(fmtcv))) { + SvREFCNT_inc_simple_void(fmtcv); + pad_add_anon((SV*)fmtcv, OP_NULL); + } } ; @@ -635,20 +644,18 @@ subbody : block { $$ = $1; } package : PACKAGE WORD WORD ';' { -/* Since no one seem to understand or use the MAD stuff, but Larry implies - * it shouldn't be removed, it's just commented out, and someone who - * understands it can come along later and fix it up. #ifdef MAD - (yyval.opval) = package((ps[(2) - (3)].val.opval)); - token_getmad((ps[(1) - (3)].val.i_tkval),(yyval.opval),'o'); - token_getmad((ps[(3) - (3)].val.i_tkval),(yyval.opval),';'); + $$ = package($3); + token_getmad($1,$$,'o'); + if ($2) + package_version($2); + token_getmad($4,$$,';'); #else -*/ package($3); - if ($2) { - package_version($2); - } + if ($2) + package_version($2); $$ = (OP*)NULL; +#endif } ; @@ -1246,6 +1253,7 @@ term : termbinop newSVOP(OP_CONST, 0, newSVpvs("Unimplemented"))); TOKEN_GETMAD($1,$$,'X'); } + | PLUGEXPR ; /* "my" declarations, with optional attributes */