summaryrefslogtreecommitdiff
path: root/perly.y
diff options
context:
space:
mode:
authorRuslan Zakirov <ruz@bestpractical.com>2013-02-27 19:39:39 +0400
committerFather Chrysostomos <sprout@cpan.org>2013-09-13 01:25:34 -0700
commit5cae3edb76796fced1e703fcf4357364c5ddd9b7 (patch)
treefaa8797522872430c4bca7c56c0177c6d69cce87 /perly.y
parent408dc2ec1c7e0bb6d22bd96e6ffe02473c573470 (diff)
downloadperl-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.y11
1 files changed, 11 insertions, 0 deletions
diff --git a/perly.y b/perly.y
index 0f98f59079..cf11a9918d 100644
--- a/perly.y
+++ b/perly.y
@@ -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; */