Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add negation meta-op, stub in some other metaops as NYI.
  • Loading branch information
pmichaud committed Jul 1, 2011
1 parent 0a8368a commit bef372d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
5 changes: 4 additions & 1 deletion src/Perl6/Actions.pm
Expand Up @@ -2519,7 +2519,10 @@ class Perl6::Actions is HLL::Actions {
!! PAST::Var.new(:name("&infix:<$basesym>"),
:scope<lexical_6model>);
my $helper := '';
if $metasym eq 'R' { $helper := '&METAOP_REVERSE'; }
if $metasym eq '!' { $helper := '&METAOP_NEGATE'; }
if $metasym eq 'R' { $helper := '&METAOP_REVERSE'; }
elsif $metasym eq 'X' { $helper := '&METAOP_CROSS'; }
elsif $metasym eq 'Z' { $helper := '&METAOP_ZIP'; }

make PAST::Op.new( :node($/),
PAST::Op.new( :pasttype<call>,
Expand Down
14 changes: 2 additions & 12 deletions src/Perl6/Grammar.pm
Expand Up @@ -1837,36 +1837,26 @@ grammar Perl6::Grammar is HLL::Grammar {
}

token infix_circumfix_meta_operator:sym<« »> {
$<opening>=[
| '«'
| '»'
]
$<opening>=[ '«' | '»' ]
{} <infixish>
$<closing>=[ '«' | '»' || <.panic("Missing « or »")> ]
<O=.copyO('infixish')>
}

token infix_circumfix_meta_operator:sym«<< >>» {
$<opening>=[
| '<<'
| '>>'
]
$<opening>=[ '<<' | '>>' ]
{} <infixish>
$<closing>=[ '<<' | '>>' || <.panic("Missing << or >>")> ]
<O=.copyO('infixish')>
}

method copyO($from) {
# There must be a a better way, but until pmichaud++ shows us it,
# this is the best I can come up with. :-) -- jnthn
my $m := self.MATCH();
my $r := $m{$from}<OPER><O>;
self.'!cursor_start'().'!cursor_pass'(self.pos(), '', $r);
}

method copyOPER($from) {
# There must be a a better way, but until pmichaud++ shows us it,
# this is the best I can come up with. :-) -- jnthn
my $m := self.MATCH();
my $r := $m{$from}<OPER>;
self.'!cursor_start'().'!cursor_pass'(self.pos(), '', $r);
Expand Down
12 changes: 12 additions & 0 deletions src/core/metaops.pm
Expand Up @@ -3,10 +3,22 @@ sub METAOP_ASSIGN(\$op) {
-> Mu \$a, Mu \$b { $a = $op($a, $b) }
}

sub METAOP_NEGATE(\$op) {
-> Mu \$a, Mu \$b { !$op($a,$b) }
}

sub METAOP_REVERSE(\$op) {
-> Mu \$a, Mu \$b { $op($b, $a) }
}

sub METAOP_CROSS(\$op) {
fail "X metaoperator NYI";
}

sub METAOP_ZIP(\$op) {
fail "Z metaoperator NYI";
}

sub METAOP_REDUCE(\$op, :$triangle) {
my $x :=
sub (*@values) {
Expand Down

0 comments on commit bef372d

Please sign in to comment.