This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add standard core test header to Test::Builder::Tester tests.
[perl5.git] / perly.y
diff --git a/perly.y b/perly.y
index 16ba650..1d20b04 100644 (file)
--- 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
@@ -338,7 +338,7 @@ startformsub:       /* NULL */      /* start a format subroutine scope */
        ;
 
 /* Name of a subroutine - must be a bareword, could be special */
-subname        :       WORD    { STRLEN n_a; const char *name = SvPV_const(((SVOP*)$1)->op_sv,n_a);
+subname        :       WORD    { const char *const name = SvPV_nolen_const(((SVOP*)$1)->op_sv);
                          if (strEQ(name, "BEGIN") || strEQ(name, "END")
                              || strEQ(name, "INIT") || strEQ(name, "CHECK"))
                              CvSPECIAL_on(PL_compcv);
@@ -487,6 +487,10 @@ subscripted:    star '{' expr ';' '}'        /* *main::{something} */
        |       subscripted '(' ')'        /* $foo->{bar}->() */
                        { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
                                   newCVREF(0, scalar($1))); }
+       |       '(' expr ')' '[' expr ']'            /* list slice */
+                       { $$ = newSLICEOP(0, $5, $2); }
+       |       '(' ')' '[' expr ']'                 /* empty list slice! */
+                       { $$ = newSLICEOP(0, $4, Nullop); }
     ;
 
 /* Binary operators between terms */
@@ -562,7 +566,7 @@ anonymous:  '[' expr ']'
 
 /* Things called with "do" */
 termdo :       DO term %prec UNIOP                     /* do $filename */
-                       { $$ = dofile($2); }
+                       { $$ = dofile($2, $1); }
        |       DO block        %prec '('               /* do { code */
                        { $$ = newUNOP(OP_NULL, OPf_SPECIAL, scope($2)); }
        |       DO WORD '(' ')'                         /* do somesub() */
@@ -622,10 +626,6 @@ term       :       termbinop
                        { $$ = newUNOP(OP_AV2ARYLEN, 0, ref($1, OP_AV2ARYLEN));}
        |       subscripted
                        { $$ = $1; }
-       |       '(' expr ')' '[' expr ']'            /* list slice */
-                       { $$ = newSLICEOP(0, $5, $2); }
-       |       '(' ')' '[' expr ']'                 /* empty list slice! */
-                       { $$ = newSLICEOP(0, $4, Nullop); }
        |       ary '[' expr ']'                     /* array slice */
                        { $$ = prepend_elem(OP_ASLICE,
                                newOP(OP_PUSHMARK, 0),
@@ -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))); }