X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/5d051ee03641d21c898bf366fb1caee7baf7e646..ef269bf5f55cf5087c6190ddbf34459c60a69622:/perly.y diff --git a/perly.y b/perly.y index b3be67d..6eb4b23 100644 --- a/perly.y +++ b/perly.y @@ -31,7 +31,7 @@ /* Make the parser re-entrant. */ -%pure_parser +%pure-parser %start grammar @@ -47,7 +47,7 @@ %token '{' '}' '[' ']' '-' '+' '@' '%' '&' '=' '.' -%token WORD METHOD FUNCMETH THING PMFUNC PRIVATEREF QWLIST +%token BAREWORD METHOD FUNCMETH THING PMFUNC PRIVATEREF QWLIST %token FUNC0OP FUNC0SUB UNIOPSUB LSTOPSUB %token PLUGEXPR PLUGSTMT %token LABEL @@ -69,7 +69,7 @@ %type stmtseq fullstmt labfullstmt barestmt block mblock else %type expr term subscripted scalar ary hsh arylen star amper sideff %type sliceme kvslice gelem -%type listexpr nexpr texpr iexpr mexpr mnexpr miexpr +%type listexpr nexpr texpr iexpr mexpr mnexpr %type optlistexpr optexpr optrepl indirob listop method %type formname subname proto optsubbody cont my_scalar my_var %type refgen_topic formblock @@ -336,7 +336,7 @@ barestmt: PLUGSTMT intro_my(); parser->parsed_sub = 1; } - | PACKAGE WORD WORD ';' + | PACKAGE BAREWORD BAREWORD ';' { package($3); if ($2) @@ -345,7 +345,7 @@ barestmt: PLUGSTMT } | USE startsub { CvSPECIAL_on(PL_compcv); /* It's a BEGIN {} */ } - WORD WORD optlistexpr ';' + BAREWORD BAREWORD optlistexpr ';' { SvREFCNT_inc_simple_void(PL_compcv); utilize($1, $2, $4, $5, $6); @@ -358,10 +358,10 @@ barestmt: PLUGSTMT newCONDOP(0, $4, op_scope($6), $7)); parser->copline = (line_t)$1; } - | UNLESS '(' remember miexpr ')' mblock else + | UNLESS '(' remember mexpr ')' mblock else { $$ = block_end($3, - newCONDOP(0, $4, op_scope($6), $7)); + newCONDOP(0, $4, $7, op_scope($6))); parser->copline = (line_t)$1; } | GIVEN '(' remember mexpr ')' mblock @@ -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; $$ = my($5); } + | FOR my_refgen remember my_var + { parser->in_my = 0; $$ = my($4); } '(' mexpr ')' mblock cont { $$ = block_end( - $4, + $3, newFOROP(0, op_lvalue( newUNOP(OP_REFGEN, 0, - $6), + $5), OP_ENTERLOOP), - $8, $10, $11) + $7, $9, $10) ); parser->copline = (line_t)$1; } @@ -453,7 +453,7 @@ barestmt: PLUGSTMT $$ = newWHILEOP(0, 1, (LOOP*)(OP*)NULL, (OP*)NULL, $1, $2, 0); } - | PACKAGE WORD WORD '{' remember + | PACKAGE BAREWORD BAREWORD '{' remember { package($3); if ($2) { @@ -581,11 +581,7 @@ mnexpr : nexpr { $$ = $1; intro_my(); } ; -miexpr : iexpr - { $$ = $1; intro_my(); } - ; - -formname: WORD { $$ = $1; } +formname: BAREWORD { $$ = $1; } | /* NULL */ { $$ = (OP*)NULL; } ; @@ -606,7 +602,7 @@ startformsub: /* NULL */ /* start a format subroutine scope */ ; /* Name of a subroutine - must be a bareword, could be special */ -subname : WORD +subname : BAREWORD | PRIVATEREF ; @@ -890,10 +886,12 @@ 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 - { $$ = localize($2,$1); } + { $$ = localize($2,0); } | '(' expr ')' { $$ = sawparens($2); } | QWLIST @@ -1030,7 +1028,7 @@ term : termbinop } '(' listexpr optrepl ')' { $$ = pmruntime($1, $4, $5, 1, $2); } - | WORD + | BAREWORD | listop | YADAYADA { @@ -1044,7 +1042,9 @@ term : termbinop myattrterm: MY myterm myattrlist { $$ = my_attrs($2,$3); } | MY myterm - { $$ = localize($2,$1); } + { $$ = localize($2,1); } + | MY REFGEN myterm myattrlist + { $$ = newUNOP(OP_REFGEN, 0, my_attrs($3,$4)); } ; /* Things that can be "my"'d */ @@ -1095,6 +1095,10 @@ refgen_topic: my_var | amper ; +my_refgen: MY REFGEN + | REFGEN MY + ; + amper : '&' indirob { $$ = newCVREF($1,$2); } ; @@ -1141,7 +1145,7 @@ gelem : star ; /* Indirect objects */ -indirob : WORD +indirob : BAREWORD { $$ = scalar($1); } | scalar %prec PREC_LOW { $$ = scalar($1); }