diff options
author | Zefram <zefram@fysh.org> | 2010-04-19 20:37:25 +0100 |
---|---|---|
committer | David Golden <dagolden@cpan.org> | 2010-05-20 18:56:11 -0400 |
commit | 4e4da3acc11d96d134ed1dc0effd641e7bedb0ca (patch) | |
tree | ce3ff5f214a7e854b3065056f8cb48208ba47e30 /perly.y | |
parent | 39f3f7f442aed93239540238d19a15f6020da747 (diff) | |
download | perl-4e4da3acc11d96d134ed1dc0effd641e7bedb0ca.tar.gz |
support "package Foo { ... }"
Package block syntax limits the scope of the package declaration to the
attached block. It's cleaner than requiring the declaration to come
inside the block.
Diffstat (limited to 'perly.y')
-rw-r--r-- | perly.y | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -92,7 +92,7 @@ %type <opval> decl format subrout mysubrout package use peg -%type <opval> block mblock lineseq line loop cond else +%type <opval> block package_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 miexpr %type <opval> listexpr listexprcom indirob listop method @@ -242,6 +242,12 @@ line : label cond } }) } + | package_block + { $$ = newSTATEOP(0, NULL, + newWHILEOP(0, 1, (LOOP*)(OP*)NULL, + NOLINE, (OP*)NULL, $1, + (OP*)NULL, 0)); + TOKEN_GETMAD($1,((LISTOP*)$$)->op_first,'L'); } | label PLUGSTMT { $$ = newSTATEOP(0, PVAL($1), $2); } ; @@ -659,6 +665,21 @@ package : PACKAGE WORD WORD ';' } ; +package_block: PACKAGE WORD WORD '{' remember + { + package($3); + if ($2) + package_version($2); + } + lineseq '}' + { if (PL_parser->copline > (line_t)IVAL($4)) + PL_parser->copline = (line_t)IVAL($4); + $$ = block_end($5, $7); + TOKEN_GETMAD($4,$$,'{'); + TOKEN_GETMAD($8,$$,'}'); + } + ; + use : USE startsub { CvSPECIAL_on(PL_compcv); /* It's a BEGIN {} */ } WORD WORD listexpr ';' |