summaryrefslogtreecommitdiff
path: root/perly.y
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-09-26 14:04:21 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-09-26 14:04:21 +0000
commita72a1c8b669f627c80c2fa5d710eb7980a143476 (patch)
tree2fe0a5115982a725a716eb6ec15b5aea105577a6 /perly.y
parent204b4d7f800e266ce239f9e434271307a9c45b3e (diff)
downloadperl-a72a1c8b669f627c80c2fa5d710eb7980a143476.tar.gz
CORE::require was always parsed as require().
That's because require() isn't overridable at tokenizer-level like other overridable built-ins, but is handled by the optree builder. So, find a way to pass the information that require() was written as CORE::require() to Perl_ck_require. This is done by adding a new token type REQUIRE and by adding OPf_SPECIAL to OP_REQUIRE when it's saw as CORE::require in the program text. This fixes bug [perl #37274] The "CORE" in CORE::require is ignored. p4raw-id: //depot/perl@25599
Diffstat (limited to 'perly.y')
-rw-r--r--perly.y6
1 files changed, 5 insertions, 1 deletions
diff --git a/perly.y b/perly.y
index 37503ba24a..e88add1af6 100644
--- a/perly.y
+++ b/perly.y
@@ -45,7 +45,7 @@
%token <ival> FUNC0 FUNC1 FUNC UNIOP LSTOP
%token <ival> RELOP EQOP MULOP ADDOP
%token <ival> DOLSHARP DO HASHBRACK NOAMP
-%token <ival> LOCAL MY MYSUB
+%token <ival> LOCAL MY MYSUB REQUIRE
%token COLONATTR
%type <ival> prog decl format startsub startanonsub startformsub mintro
@@ -664,6 +664,10 @@ term : termbinop
{ $$ = newUNOP($1, 0, $2); }
| UNIOP term /* Unary op */
{ $$ = newUNOP($1, 0, $2); }
+ | REQUIRE /* require, $_ implied */
+ { $$ = newOP(OP_REQUIRE, $1 ? OPf_SPECIAL : 0); }
+ | REQUIRE term /* require Foo */
+ { $$ = newUNOP(OP_REQUIRE, $1 ? OPf_SPECIAL : 0, $2); }
| UNIOPSUB term /* Sub treated as unop */
{ $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
append_elem(OP_LIST, $2, scalar($1))); }