develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r33783 - trunk/languages/perl6/src/parser

From:
tene
Date:
December 10, 2008 15:37
Subject:
[svn:parrot] r33783 - trunk/languages/perl6/src/parser
Message ID:
20081210233708.ABB51CBA89@x12.develooper.com
Author: tene
Date: Wed Dec 10 15:37:07 2008
New Revision: 33783

Modified:
   trunk/languages/perl6/src/parser/actions.pm
   trunk/languages/perl6/src/parser/grammar.pg

Log:
[rakudo]: Initial support for CATCH blocks.

Modified: trunk/languages/perl6/src/parser/actions.pm
==============================================================================
--- trunk/languages/perl6/src/parser/actions.pm	(original)
+++ trunk/languages/perl6/src/parser/actions.pm	Wed Dec 10 15:37:07 2008
@@ -381,6 +381,28 @@
     make $past;
 }
 
+method catch_statement($/) {
+    my $past := $( $<block> );
+    $past.blocktype('immediate');
+    $past := PAST::Stmts.new(
+        PAST::Op.new(
+            :pasttype('bind'),
+            PAST::Var.new( :name('$_'), :scope('lexical') ),
+            PAST::Var.new( :name('exception'), :scope('register') )
+        ),
+        $past
+    );
+    our $?BLOCK;
+    my $eh := PAST::Control.new( $past );
+    my @handlers;
+    if $?BLOCK.handlers() {
+        @handlers := $?BLOCK.handlers();
+    }
+    @handlers.push($eh);
+    $?BLOCK.handlers(@handlers);
+    make PAST::Stmts.new();
+}
+
 method statement_mod_loop($/) {
     my $expr := $( $<EXPR> );
     my $sym := ~$<sym>;

Modified: trunk/languages/perl6/src/parser/grammar.pg
==============================================================================
--- trunk/languages/perl6/src/parser/grammar.pg	(original)
+++ trunk/languages/perl6/src/parser/grammar.pg	Wed Dec 10 15:37:07 2008
@@ -240,6 +240,7 @@
     | <use_statement> {*}                        #= use_statement
     | <begin_statement> {*}                      #= begin_statement
     | <end_statement> {*}                        #= end_statement
+    | <catch_statement> {*}                      #= catch_statement
 }
 
 rule if_statement {
@@ -323,6 +324,12 @@
     {*}
 }
 
+rule catch_statement {
+    $<sym>=[CATCH]
+    <block>
+    {*}
+}
+
 rule statement_mod_loop {
     $<sym>=[while|until|for|given] <EXPR> {*}
 }



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About