Skip to content

Commit

Permalink
Add updating of $?BLOCK and @?BLOCK to block action.
Browse files Browse the repository at this point in the history
  • Loading branch information
tcurtis committed Jul 18, 2010
1 parent 3c75a72 commit 712a06c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/Squaak/Actions.pm
Expand Up @@ -122,18 +122,22 @@ method statement:sym<while>($/) {
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 $<statement> {
$past.push($_.ast) ;
$past.push($_.ast);
}
make $past;
}
Expand Down
5 changes: 5 additions & 0 deletions src/Squaak/Grammar.pm
Expand Up @@ -67,7 +67,12 @@ rule statement:sym<while> {
<sym> <expression> 'do' <block> 'end'
}

token begin_block {
<?>
}

rule block {
<.begin_block>
<statement>*
}

Expand Down

0 comments on commit 712a06c

Please sign in to comment.