Skip to content

Commit

Permalink
Implement 'also'
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan O'Rear committed Jul 11, 2010
1 parent 13b25f8 commit 53b6cdf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
31 changes: 31 additions & 0 deletions Niecza/Actions.pm
Expand Up @@ -541,6 +541,11 @@ sub package_declarator__S_slang { my ($cl, $M) = @_;
$M->{_ast} = $M->{package_def}{_ast};
}

sub package_declarator__S_also { my ($cl, $M) = @_;
push @{ $::CURLEX->{'!decls'} //= [] },
map { $_->{_ast} } @{ $M->{trait} };
}

sub termish {}
sub EXPR {}

Expand Down Expand Up @@ -626,6 +631,32 @@ sub package_def { my ($cl, $M) = @_;
}
}

sub trait_mod {}
sub trait_mod__S_is { my ($cl, $M) = @_;
my $trait = $M->{longname}->Str;

if (!$M->is_name($trait)) {
$M->sorry('Non-superclass is traits NYI');
return;
}

if ($M->{circumfix}[0]) {
$M->sorry('Superclasses cannot have parameters');
return;
}

$M->{_ast} = Decl::Super->new(name => $trait);
}

sub trait { my ($cl, $M) = @_;
if ($M->{colonpair}) {
$M->sorry('Colonpair traits NYI');
return;
}

$M->{_ast} = $M->{trait_mod}{_ast};
}

sub routine_declarator {}
sub routine_declarator__S_sub { my ($cl, $M) = @_;
$M->{_ast} = $M->{routine_def}{_ast};
Expand Down
2 changes: 1 addition & 1 deletion setting
Expand Up @@ -219,6 +219,6 @@ sub say { Q:NIL {
=[0] @ unwrap:String .plaincall/1:Console.WriteLine null:Variable
} }

my class Foo { }
#my class Junction { also is Mu }

say("Hello, " ~ "World");

0 comments on commit 53b6cdf

Please sign in to comment.