Skip to content

Commit

Permalink
Add ability to define operator subs.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed May 14, 2009
1 parent bf281cf commit 8349d75
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/parser/actions.pm
Expand Up @@ -758,10 +758,16 @@ method routine_declarator($/, $key) {


method routine_def($/) {
my $block := $<block>.ast;
our $?BLOCK_OPEN;
unless $?BLOCK_OPEN {
$?BLOCK_OPEN := PAST::Block.new( PAST::Stmts.new(), :node($/) );
}
my $block := $?BLOCK_OPEN;
$block.blocktype('declaration');
if $<deflongname> {
my $name := ~$<deflongname>[0];
my $match := Perl6::Grammar::opname($name, :grammar('Perl6::Grammar') );
if $match { $name := ~$match<category> ~ ':' ~ ~$match[0]; }
our @?BLOCK;
my $existing := @?BLOCK[0].symbol($name);
if $existing && !$existing<is_proto> && !$existing<is_multi> {
Expand Down
4 changes: 2 additions & 2 deletions src/parser/grammar.pg
Expand Up @@ -418,9 +418,9 @@ rule multisig {
}

rule routine_def {
[ <deflongname=identifier> ]? [ <multisig> | <trait> ]*
<block>
[ <deflongname=longname> ]? [ <multisig> | <trait> ]*
{*}
<block>
|| <.panic: "Malformed routine definition">
}

Expand Down

0 comments on commit 8349d75

Please sign in to comment.