summaryrefslogtreecommitdiff
path: root/perly.y
diff options
context:
space:
mode:
authorRuslan Zakirov <ruz@bestpractical.com>2013-03-02 16:57:41 +0400
committerFather Chrysostomos <sprout@cpan.org>2013-09-13 01:25:34 -0700
commit6dd3e0f2449b60948d1ae2a8377afcea1fb88000 (patch)
tree7bb1d7d0fa55961d739a7b240953b5805d0fb866 /perly.y
parentace8699dea8a8f004662f49f5587ba134fee9da1 (diff)
downloadperl-6dd3e0f2449b60948d1ae2a8377afcea1fb88000.tar.gz
index/value array slice operation
kvaslice operator that imlements %a[0,2,4] syntax which result in list of index/value pairs. Implemented in consistency with "key/value hash slice" operator.
Diffstat (limited to 'perly.y')
-rw-r--r--perly.y9
1 files changed, 9 insertions, 0 deletions
diff --git a/perly.y b/perly.y
index cf11a9918d..accc95dc34 100644
--- a/perly.y
+++ b/perly.y
@@ -1204,6 +1204,15 @@ term : termbinop
TOKEN_GETMAD($2,$$,'[');
TOKEN_GETMAD($4,$$,']');
}
+ | hsh '[' expr ']' /* array key/value slice */
+ { $$ = op_prepend_elem(OP_KVASLICE,
+ newOP(OP_PUSHMARK, 0),
+ newLISTOP(OP_KVASLICE, 0,
+ list($3),
+ ref(oopsAV($1), OP_KVASLICE)));
+ TOKEN_GETMAD($2,$$,'[');
+ TOKEN_GETMAD($4,$$,']');
+ }
| ary '{' expr ';' '}' /* @hash{@keys} */
{ $$ = op_prepend_elem(OP_HSLICE,
newOP(OP_PUSHMARK, 0),