diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2010-09-24 15:07:13 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2010-09-24 15:07:13 +0000 |
commit | 6a200b5cffd015c92893c51dd9f24ea861480b4d (patch) | |
tree | 2a683165d8d7277646395e2458d754213d8ff7dc /gnu/usr.bin/perl/perly.y | |
parent | b514202b410a11d5f4a03be7f2e67ca623ff1ab7 (diff) |
merge in perl 5.12.2 plus local changes
Diffstat (limited to 'gnu/usr.bin/perl/perly.y')
-rw-r--r-- | gnu/usr.bin/perl/perly.y | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/gnu/usr.bin/perl/perly.y b/gnu/usr.bin/perl/perly.y index 6b8b4e317a1..a61a6b30fb3 100644 --- a/gnu/usr.bin/perl/perly.y +++ b/gnu/usr.bin/perl/perly.y @@ -73,11 +73,12 @@ %token <opval> WORD METHOD FUNCMETH THING PMFUNC PRIVATEREF %token <opval> FUNC0SUB UNIOPSUB LSTOPSUB +%token <opval> PLUGEXPR PLUGSTMT %token <p_tkval> LABEL %token <i_tkval> FORMAT SUB ANONSUB PACKAGE USE %token <i_tkval> WHILE UNTIL IF UNLESS ELSE ELSIF CONTINUE FOR %token <i_tkval> GIVEN WHEN DEFAULT -%token <i_tkval> LOOPEX DOTDOT +%token <i_tkval> LOOPEX DOTDOT YADAYADA %token <i_tkval> FUNC0 FUNC1 FUNC UNIOP LSTOP %token <i_tkval> RELOP EQOP MULOP ADDOP %token <i_tkval> DOLSHARP DO HASHBRACK NOAMP @@ -111,7 +112,7 @@ %left <i_tkval> ',' %right <i_tkval> ASSIGNOP %right <i_tkval> '?' ':' -%nonassoc DOTDOT +%nonassoc DOTDOT YADAYADA %left <i_tkval> OROR DORDOR %left <i_tkval> ANDAND %left <i_tkval> BITOROP @@ -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 */ @@ -269,6 +272,8 @@ sideff : error (OP*)NULL, $3, $1, (OP*)NULL); TOKEN_GETMAD($2,((LISTOP*)$$)->op_first->op_sibling,'w'); } + | expr WHEN expr + { $$ = newWHENOP($3, scope($1)); } ; /* else and elsif blocks */ @@ -327,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, @@ -340,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, @@ -422,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), @@ -506,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'); @@ -516,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); + } } ; @@ -631,14 +642,18 @@ subbody : block { $$ = $1; } } ; -package : PACKAGE WORD ';' +package : PACKAGE WORD WORD ';' { #ifdef MAD - $$ = package($2); + $$ = package($3); token_getmad($1,$$,'o'); - token_getmad($3,$$,';'); + if ($2) + package_version($2); + token_getmad($4,$$,';'); #else - package($2); + package($3); + if ($2) + package_version($2); $$ = (OP*)NULL; #endif } @@ -654,7 +669,7 @@ use : USE startsub token_getmad($7,$$,';'); if (PL_parser->rsfp_filters && AvFILLp(PL_parser->rsfp_filters) >= 0) - append_madprops(newMADPROP('!', MAD_PV, "", 0), $$, 0); + append_madprops(newMADPROP('!', MAD_NULL, NULL, 0), $$, 0); #else utilize(IVAL($1), $2, $4, $5, $6); $$ = (OP*)NULL; @@ -1232,6 +1247,13 @@ term : termbinop } | WORD | listop + | YADAYADA + { + $$ = newLISTOP(OP_DIE, 0, newOP(OP_PUSHMARK, 0), + newSVOP(OP_CONST, 0, newSVpvs("Unimplemented"))); + TOKEN_GETMAD($1,$$,'X'); + } + | PLUGEXPR ; /* "my" declarations, with optional attributes */ |