Navigation Menu

Skip to content

Commit

Permalink
Start to refactor package handling a bit. Toss package_declarator:sym…
Browse files Browse the repository at this point in the history
…<does> - STD no longer does it that way.
  • Loading branch information
jnthn committed May 7, 2011
1 parent 417b4c3 commit 7112a1f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 22 deletions.
17 changes: 8 additions & 9 deletions src/Perl6/Actions.pm
Expand Up @@ -868,15 +868,14 @@ class Perl6::Actions is HLL::Actions {
method package_declarator:sym<class>($/) { make $<package_def>.ast; }
method package_declarator:sym<grammar>($/) { make $<package_def>.ast; }
method package_declarator:sym<role>($/) { make $<package_def>.ast; }

method package_declarator:sym<does>($/) {
our @PACKAGE;
@PACKAGE[0].traits.push(PAST::Op.new(
:pasttype('call'),
:name('&trait_mod:<does>'),
$<typename>.ast
));
make PAST::Stmts.new();
method package_declarator:sym<knowhow>($/) { make $<package_def>.ast; }

method package_declarator:sym<trusts>($/) {
$/.CURSOR.panic("trusts not yet implemented");
}

method package_declarator:sym<also>($/) {
$/.CURSOR.panic("also not yet implemented");
}

method package_def($/, $key?) {
Expand Down
45 changes: 32 additions & 13 deletions src/Perl6/Grammar.pm
Expand Up @@ -16,6 +16,7 @@ grammar Perl6::Grammar is HLL::Grammar {
# compile the setting, but it still wants some kinda package. We just
# fudge in knowhow for that.
my %*HOW;
%*HOW<knowhow> := pir::get_knowhow__P();
%*HOW<package> := pir::get_knowhow__P();

# Symbol table and serialization context builder - keeps track of
Expand Down Expand Up @@ -820,29 +821,47 @@ grammar Perl6::Grammar is HLL::Grammar {

proto token package_declarator { <...> }
token package_declarator:sym<package> {
<sym> :my $*PKGDECL := 'package';
<package_def>
:my $*OUTERPACKAGE := $*PACKAGE;
:my $*PKGDECL := 'package';
<sym> <package_def>
}
token package_declarator:sym<module> {
<sym> :my $*PKGDECL := 'module';
<package_def>
:my $*OUTERPACKAGE := $*PACKAGE;
:my $*PKGDECL := 'module';
<sym> <package_def>
}
token package_declarator:sym<class> {
<sym> :my $*PKGDECL := 'class';
<package_def>
:my $*OUTERPACKAGE := $*PACKAGE;
:my $*PKGDECL := 'class';
<sym> <package_def>
}
token package_declarator:sym<grammar> {
<sym> :my $*PKGDECL := 'grammar';
<package_def>
:my $*OUTERPACKAGE := $*PACKAGE;
:my $*PKGDECL := 'grammar';
<sym> <package_def>
}
token package_declarator:sym<role> {
<sym> :my $*PKGDECL := 'role';
<package_def>
:my $*OUTERPACKAGE := $*PACKAGE;
:my $*PKGDECL := 'role';
<sym> <package_def>
}

token package_declarator:sym<does> {
token package_declarator:sym<knowhow> {
:my $*OUTERPACKAGE := $*PACKAGE;
:my $*PKGDECL := 'knowhow';
<sym> <package_def>
}
token package_declarator:sym<slang> {
:my $*OUTERPACKAGE := $*PACKAGE;
:my $*PKGDECL := 'slang';
<sym> <package_def>
}
token package_declarator:sym<trusts> {
<sym> <.ws>
<typename>
<module_name>
}
token package_declarator:sym<also> {
<sym>:s
[ <trait>+ || <.panic: "No valid trait found after also"> ]
}

rule package_def {<.end_keyword>
Expand Down

0 comments on commit 7112a1f

Please sign in to comment.