summaryrefslogtreecommitdiff
path: root/perly.y
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2017-12-06 00:09:42 +0000
committerZefram <zefram@fysh.org>2017-12-06 00:09:42 +0000
commitf68519ee3f12e5ba41a022ef88ce3d6c3901807f (patch)
treed28e0491a89f13c137a35d52c17fb0f6e37af773 /perly.y
parent84ac76a7475419f4ac6e5a6935522f7b7ebb0e2c (diff)
downloadperl-f68519ee3f12e5ba41a022ef88ce3d6c3901807f.tar.gz
add "whereis"
"whereis" is like "whereso" except that it performs an implicit smartmatch.
Diffstat (limited to 'perly.y')
-rw-r--r--perly.y16
1 files changed, 14 insertions, 2 deletions
diff --git a/perly.y b/perly.y
index 8191d82379..4ef8478fa0 100644
--- a/perly.y
+++ b/perly.y
@@ -379,7 +379,13 @@ barestmt: PLUGSTMT
parser->copline = (line_t)$1;
}
| WHERESO '(' remember mexpr ')' mblock
- { $$ = block_end($3, newWHERESOOP($4, op_scope($6))); }
+ {
+ OP *cond = $4;
+ if ($1)
+ cond = newBINOP(OP_SMARTMATCH, 0, newDEFSVOP(),
+ scalar(cond));
+ $$ = block_end($3, newWHERESOOP(cond, op_scope($6)));
+ }
| WHILE '(' remember texpr ')' mintro mblock cont
{
$$ = block_end($3,
@@ -532,7 +538,13 @@ sideff : error
{ $$ = newFOROP(0, NULL, $3, $1, NULL);
parser->copline = (line_t)$2; }
| expr WHERESO expr
- { $$ = newWHERESOOP($3, op_scope($1)); }
+ {
+ OP *cond = $3;
+ if ($2)
+ cond = newBINOP(OP_SMARTMATCH, 0, newDEFSVOP(),
+ scalar(cond));
+ $$ = newWHERESOOP(cond, op_scope($1));
+ }
;
/* else and elsif blocks */