Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Simple implementation of [//] and [||] operators
(Improvements by Moritz: use slurpy arg, and register ops in grammer-oper.pg)

Signed-Off-By: Moritz Lenz <moritz@faui2k3.org>
  • Loading branch information
Kyle Hasselbacher authored and moritz committed Jul 24, 2009
1 parent 5167835 commit dd5767c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/parser/grammar-oper.pg
Expand Up @@ -179,6 +179,8 @@ proto prefix:<[,]> is precedence('e=') is subname('list') {...}
proto prefix:<[&]> is equiv(prefix:<[,]>) is subname('all') {...}
proto prefix:<[|]> is equiv(prefix:<[,]>) is subname('any') {...}
proto prefix:<[^]> is equiv(prefix:<[,]>) is subname('one') {...}
proto prefix:<[||]> is equiv(prefix:<[,]>) {...}
proto prefix:<[//]> is equiv(prefix:<[,]>) {...}

## loose and
proto infix:<and> is precedence('d=')
Expand Down
16 changes: 16 additions & 0 deletions src/setting/Operators.pm
Expand Up @@ -62,4 +62,20 @@ multi sub infix:<leg>($a, $b) {
~$a cmp ~$b;
}

sub prefix:<[//]>(*@a) {
for @a -> $item {
$item // next;
return $item;
}
return ();
}

sub prefix:<[||]>(*@a) {
for @a -> $item {
$item || next;
return $item;
}
return ();
}

# vim: ft=perl6

0 comments on commit dd5767c

Please sign in to comment.