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 /perly.h | |
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 'perly.h')
-rw-r--r-- | perly.h | 28 |
1 files changed, 15 insertions, 13 deletions
@@ -120,12 +120,13 @@ REFGEN = 329, UMINUS = 330, POWOP = 331, - POSTDEC = 332, - POSTINC = 333, - PREDEC = 334, - PREINC = 335, - ARROW = 336, - PEG = 337 + POSTJOIN = 332, + POSTDEC = 333, + POSTINC = 334, + PREDEC = 335, + PREINC = 336, + ARROW = 337, + PEG = 338 }; #endif /* Tokens. */ @@ -203,12 +204,13 @@ #define REFGEN 329 #define UMINUS 330 #define POWOP 331 -#define POSTDEC 332 -#define POSTINC 333 -#define PREDEC 334 -#define PREINC 335 -#define ARROW 336 -#define PEG 337 +#define POSTJOIN 332 +#define POSTDEC 333 +#define POSTINC 334 +#define PREDEC 335 +#define PREINC 336 +#define ARROW 337 +#define PEG 338 @@ -266,6 +268,6 @@ typedef union YYSTYPE /* Generated from: - * 1197382d22c31fcdde494b49bf64759ffa9ecf45fb2536cefae6300977d788aa perly.y + * 020be75832dcc7c18bd88434c3ba0e24a136dc093c4b8bf2cef9efa5875c9a29 perly.y * 5c9d2a0262457fe9b70073fc8ad6c188f812f38ad57712b7e2f53daa01b297cc regen_perly.pl * ex: set ro: */ |