Revision 33783

Date:
2008/12/10 23:37:07
Author:
tene
Revision Log:
[rakudo]: Initial support for CATCH blocks.
Files:

Legend:

 
Added
 
Removed
 
Modified
  • trunk/languages/perl6/src/parser/actions.pm

     
    381 381 make $past;
    382 382 }
    383 383
    384 method catch_statement($/) {
    385 my $past := $( $<block> );
    386 $past.blocktype('immediate');
    387 $past := PAST::Stmts.new(
    388 PAST::Op.new(
    389 :pasttype('bind'),
    390 PAST::Var.new( :name('$_'), :scope('lexical') ),
    391 PAST::Var.new( :name('exception'), :scope('register') )
    392 ),
    393 $past
    394 );
    395 our $?BLOCK;
    396 my $eh := PAST::Control.new( $past );
    397 my @handlers;
    398 if $?BLOCK.handlers() {
    399 @handlers := $?BLOCK.handlers();
    400 }
    401 @handlers.push($eh);
    402 $?BLOCK.handlers(@handlers);
    403 make PAST::Stmts.new();
    404 }
    405
    384 406 method statement_mod_loop($/) {
    385 407 my $expr := $( $<EXPR> );
    386 408 my $sym := ~$<sym>;
  • trunk/languages/perl6/src/parser/grammar.pg

     
    240 240 | <use_statement> {*} #= use_statement
    241 241 | <begin_statement> {*} #= begin_statement
    242 242 | <end_statement> {*} #= end_statement
    243 | <catch_statement> {*} #= catch_statement
    243 244 }
    244 245
    245 246 rule if_statement {
     
    323 324 {*}
    324 325 }
    325 326
    327 rule catch_statement {
    328 $<sym>=[CATCH]
    329 <block>
    330 {*}
    331 }
    332
    326 333 rule statement_mod_loop {
    327 334 $<sym>=[while|until|for|given] <EXPR> {*}
    328 335 }