From 712a06c80bfbdd838dcbe5c39504a7122878a827 Mon Sep 17 00:00:00 2001 From: tcurtis Date: Sun, 18 Jul 2010 09:34:33 -0500 Subject: [PATCH] Add updating of $?BLOCK and @?BLOCK to block action. --- src/Squaak/Actions.pm | 24 ++++++++++++++---------- src/Squaak/Grammar.pm | 5 +++++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/Squaak/Actions.pm b/src/Squaak/Actions.pm index 9dc3644..cc683a5 100644 --- a/src/Squaak/Actions.pm +++ b/src/Squaak/Actions.pm @@ -122,18 +122,22 @@ method statement:sym($/) { make PAST::Op.new( $cond, $body, :pasttype('while'), :node($/) ); } +method begin_block($/) { + our $?BLOCK; + our @?BLOCK; + $?BLOCK := PAST::Block.new(:blocktype('immediate'), + :node($/)); + @?BLOCK.unshift($?BLOCK); +} + method block($/) { - # create a new block, set its type to 'immediate', - # meaning it is potentially executed immediately - # (as opposed to a declaration, such as a - # subroutine definition). - my $past := PAST::Block.new( :blocktype('immediate'), - :node($/) ); - - # for each statement, add the result - # object to the block + our $?BLOCK; + our @?BLOCK; + my $past := @?BLOCK.shift(); + $?BLOCK := @?BLOCK[0]; + for $ { - $past.push($_.ast) ; + $past.push($_.ast); } make $past; } diff --git a/src/Squaak/Grammar.pm b/src/Squaak/Grammar.pm index e48ea8a..3e2f7ba 100644 --- a/src/Squaak/Grammar.pm +++ b/src/Squaak/Grammar.pm @@ -67,7 +67,12 @@ rule statement:sym { 'do' 'end' } +token begin_block { + +} + rule block { + <.begin_block> * }