Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Support use of does inside packages.
  • Loading branch information
jnthn committed Feb 18, 2009
1 parent 6663565 commit d2d0d84
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
19 changes: 18 additions & 1 deletion src/parser/actions.pm
Expand Up @@ -1538,10 +1538,27 @@ method package_declarator($/, $key) {
$?BLOCK_OPEN<pkgdecl> := $sym;
@?PKGDECL.unshift( $sym );
}
else {
elsif $key eq 'package_def' {
make $( $<package_def> );
@?PKGDECL.shift();
}
elsif $key eq 'does' {
our @?BLOCK;
our $?METACLASS;
my $block := @?BLOCK[0];
my $pkgdecl := $block<pkgdecl>;
my $typename := ~$<typename><name>;
unless $pkgdecl eq 'class' || $pkgdecl eq 'role' || $pkgdecl eq 'grammar' {
$/.panic("Cannot use does package declarator outside of class, role, or grammar");
}
$block[0].push(PAST::Op.new(
:name('!meta_trait'),
$?METACLASS,
'trait_auxiliary:does',
$typename
));
make PAST::Stmts.new()
}
}


Expand Down
5 changes: 3 additions & 2 deletions src/parser/grammar.pg
Expand Up @@ -625,8 +625,9 @@ token named_0ary {
}

rule package_declarator {
$<sym>=[class|grammar|module|package|role] {*} #= open
<package_def> {*} #= package_def
| $<sym>=[class|grammar|module|package|role] {*} #= open
<package_def> {*} #= package_def
| 'does' <typename> {*} #= does
}


Expand Down

0 comments on commit d2d0d84

Please sign in to comment.