This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Merge branch 'perlgov-omnibus-amendments' into blead
[perl5.git] / perly.y
diff --git a/perly.y b/perly.y
index 8e3630b..18ed6e8 100644 (file)
--- a/perly.y
+++ b/perly.y
@@ -69,6 +69,7 @@
 %token <ival> FORMAT SUB SIGSUB ANONSUB ANON_SIGSUB PACKAGE USE
 %token <ival> WHILE UNTIL IF UNLESS ELSE ELSIF CONTINUE FOR
 %token <ival> GIVEN WHEN DEFAULT
+%token <ival> TRY CATCH
 %token <ival> LOOPEX DOTDOT YADAYADA
 %token <ival> FUNC0 FUNC1 FUNC UNIOP LSTOP
 %token <ival> MULOP ADDOP
@@ -76,6 +77,7 @@
 %token <ival> LOCAL MY REQUIRE
 %token <ival> COLONATTR FORMLBRACK FORMRBRACK
 %token <ival> SUBLEXSTART SUBLEXEND
+%token <ival> DEFER
 
 %type <ival> grammar remember mremember
 %type <ival>  startsub startanonsub startformsub
@@ -459,6 +461,16 @@ barestmt:  PLUGSTMT
                                  newFOROP(0, NULL, $mexpr, $mblock, $cont));
                          parser->copline = (line_t)$FOR;
                        }
+       |       TRY mblock[try] CATCH PERLY_PAREN_OPEN 
+                       { parser->in_my = 1; }
+               remember scalar 
+                       { parser->in_my = 0; intro_my(); }
+               PERLY_PAREN_CLOSE mblock[catch]
+                       {
+                         $$ = newTRYCATCHOP(0,
+                                 $try, $scalar, block_end($remember, op_scope($catch)));
+                         parser->copline = (line_t)$TRY;
+                       }
        |       block cont
                        {
                          /* a block is a loop that happens once */
@@ -484,6 +496,10 @@ barestmt:  PLUGSTMT
                        {
                          $$ = $sideff;
                        }
+       |       DEFER mblock
+                       {
+                         $$ = newDEFEROP(0, op_scope($2));
+                       }
        |       YADAYADA PERLY_SEMICOLON
                        {
                          $$ = newLISTOP(OP_DIE, 0, newOP(OP_PUSHMARK, 0),