Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement \(1) capture syntax
  • Loading branch information
sorear committed Feb 18, 2011
1 parent c2ca536 commit ca96dd2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/SAFE.setting
Expand Up @@ -171,8 +171,10 @@ my class Capture {
method Capture () { self }
method list () { @( Q:CgOp { (box Parcel (getslot positionals fvarlist
(@ {self}))) } ) }
method hash () { unitem( Q:CgOp { (box Hash (getslot named varhash
(@ {self}))) } // {} ) }
method hash () { unitem( Q:CgOp {
(letn h (getslot named varhash (@ {self}))
(ternary (== (l h) (null varhash)) {{}} (box Hash (l h))))
}) }
}
# }}}
# Scalar types {{{
Expand Down
16 changes: 16 additions & 0 deletions src/niecza
Expand Up @@ -49,6 +49,22 @@ sub mkstringycat($/, *@strings) {
}

augment class NieczaActions {
method capture($ ) {}
method capterm($/) {
my @args;
if $<capture> {
my $x = $<capture>[0]<EXPR>.ast;
if $x.^isa(::Op::SimpleParcel) {
@args = @($x.items);
} else {
@args = $x;
}
} elsif $<termish> {
@args = ::Op::Paren.new(|node($/), inside => $<termish>.ast);
}
make ::Op::CallSub.new(|node($/), invocant => mklex($/, '&_make_capture'),
args => @args);
}
method process_nibble($/, @bits, $prefix?) {
my @acc;
for @bits -> $n {
Expand Down

0 comments on commit ca96dd2

Please sign in to comment.