Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Add <block> subrule.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Nov 8, 2009
1 parent 238f21b commit 57d2a44
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/NQP/Actions.pm
Expand Up @@ -71,6 +71,10 @@ method pblock($/) {
make $<blockoid>.ast;
}

method block($/) {
make $<blockoid>.ast;
}

method blockoid($/) {
my $past := $<statementlist>.ast;
my $BLOCK := @BLOCK.shift;
Expand Down Expand Up @@ -159,8 +163,8 @@ method statement_prefix:sym<INIT>($/) {
}

method blorst($/) {
make $<pblock>
?? block_immediate($<pblock>.ast)
make $<block>
?? block_immediate($<block>.ast)
!! $<statement>.ast;
}

Expand Down
10 changes: 8 additions & 2 deletions src/NQP/Grammar.pm
Expand Up @@ -94,7 +94,13 @@ token xblock {
}

token pblock {
<?[{]>
[ <?[{]> || <.panic: 'Missing block'> ]
<.newpad>
<blockoid>
}

token block {
[ <?[{]> || <.panic: 'Missing block'> ]
<.newpad>
<blockoid>
}
Expand Down Expand Up @@ -162,7 +168,7 @@ proto token statement_prefix { <...> }
token statement_prefix:sym<INIT> { <sym> <blorst> }

token blorst {
\s <.ws> [ <pblock> | <statement> ]
\s <.ws> [ <?[{]> <block> | <statement> ]
}

## Terms
Expand Down

0 comments on commit 57d2a44

Please sign in to comment.