diff options
author | Father Chrysostomos <sprout@cpan.org> | 2013-09-16 09:44:34 -0700 |
---|---|---|
committer | Ricardo Signes <rjbs@cpan.org> | 2013-10-05 14:20:10 -0400 |
commit | cc624add4b00fb447b7fbbd045a9980d27c180e2 (patch) | |
tree | b715bb016205c8a2a44bc08f2ba1e721f6bae6af /pod/perllexwarn.pod | |
parent | 158beccad252a25c107551be283bdc27e2729d29 (diff) | |
download | perl-cc624add4b00fb447b7fbbd045a9980d27c180e2.tar.gz |
Allow ->@ ->$ interpolation under postderef_qq feature
This turned out to be tricky. Normally @ at the beginning of the
interpolated code signals to the lexer to emit ‘join($",’ immediately.
With "$_->@*" we would have to retract the $ _ -> tokens upon encoun-
tering @*, which we obviously cannot do.
Waiting until we reach the end of the interpolated text before emit-
ting anything could not work either, as it may contain BEGIN blocks
that affect the way part of the interpolated code is parsed.
So what we do is introduce an egregious or clever hack, depending on
how you look at it.
Normally, the lexer turns "@foo" into:
stringify ( join ( $ " , @ foo ) )
(The " is a WORD token, representing a variable name.)
"$_" becomes:
stringify ( $ _ )
We can turn "$_->@*" into:
stringify ( $ _ -> @ * POSTJOIN )
Where POSTJOIN is a new lexer token with special handling that creates
a join op just the way join($", ...) does.
To make "foo$_->@*bar" work as well, we have to make POSTJOIN have
precedence just below ->, so that
stringify ( "foo" . $ _ -> @ * POSTJOIN . "bar" )
(what the parser sees) is equivalent to:
stringify ( "foo" . ( $ _ -> @ * POSTJOIN ) . "bar" )
Diffstat (limited to 'pod/perllexwarn.pod')
0 files changed, 0 insertions, 0 deletions