diff options
author | Ruslan Zakirov <ruz@bestpractical.com> | 2013-02-27 19:39:39 +0400 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2013-09-13 01:25:34 -0700 |
commit | 5cae3edb76796fced1e703fcf4357364c5ddd9b7 (patch) | |
tree | faa8797522872430c4bca7c56c0177c6d69cce87 /perly.y | |
parent | 408dc2ec1c7e0bb6d22bd96e6ffe02473c573470 (diff) | |
download | perl-5cae3edb76796fced1e703fcf4357364c5ddd9b7.tar.gz |
key/value hash slice operation
kvhslice operator that implements %h{1,2,3,4} syntax which
returns list of key value pairs rather than just values
(regular slices).
Diffstat (limited to 'perly.y')
-rw-r--r-- | perly.y | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -1215,6 +1215,17 @@ term : termbinop TOKEN_GETMAD($4,$$,';'); TOKEN_GETMAD($5,$$,'}'); } + | hsh '{' expr ';' '}' /* %hash{@keys} */ + { $$ = op_prepend_elem(OP_KVHSLICE, + newOP(OP_PUSHMARK, 0), + newLISTOP(OP_KVHSLICE, 0, + list($3), + ref($1, OP_KVHSLICE))); + PL_parser->expect = XOPERATOR; + TOKEN_GETMAD($2,$$,'{'); + TOKEN_GETMAD($4,$$,';'); + TOKEN_GETMAD($5,$$,'}'); + } | THING %prec '(' { $$ = $1; } | amper /* &foo; */ |