Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix various bugs in \(...) syntax.
It didn't correctly differentiate quoted pairs (positional arg) from
identifier paris (named arg), nor did it support | for flattening into
the Capture. This patches fixes both of these issues, as well as making
it handle ;s.
  • Loading branch information
jnthn committed Mar 30, 2015
1 parent 64fe6c5 commit 253bb58
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
19 changes: 7 additions & 12 deletions src/Perl6/Actions.nqp
Expand Up @@ -3538,18 +3538,13 @@ class Perl6::Actions is HLL::Actions does STDActions {
}

method capterm($/) {
# Construct a Parcel, and then call .Capture to coerce it to a capture.
my $past := $<termish> ?? $<termish>.ast !!
$<capture> ?? $<capture>.ast !!
QAST::Op.new( :op('call'), :name('&infix:<,>') );
unless $past.isa(QAST::Op) && $past.name eq '&infix:<,>' {
$past := QAST::Op.new( :op('call'), :name('&infix:<,>'), $past );
}
make QAST::Op.new( :op('callmethod'), :name('Capture'), $past);
}

method capture($/) {
make $<EXPR>.ast;
my $past := $<termish>
?? QAST::Op.new( $<termish>.ast )
!! $<semiarglist>.ast;
$past.unshift(QAST::WVal.new( :value($*W.find_symbol(['Capture']) ) ));
$past.op('callmethod');
$past.name('from-args');
make $past;
}

method multisig($/) {
Expand Down
6 changes: 1 addition & 5 deletions src/Perl6/Grammar.nqp
Expand Up @@ -2804,16 +2804,12 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
token capterm {
'\\'
[
| '(' <.ws> <capture>? ')'
| '(' <semiarglist> ')'
| <?before \S> <termish>
| {} <.panic: "You can't backslash that">
]
}

rule capture {
<EXPR>
}

rule param_sep {
'' $<sep>=[','|':'|';;'|';'] { @*seps.push($<sep>) }
}
Expand Down
2 changes: 2 additions & 0 deletions src/core/Capture.pm
Expand Up @@ -7,6 +7,8 @@ my class Capture { # declared in BOOTSTRAP
nqp::create(self).BUILD(:@list,:%hash);
}

method from-args(|c) { c }

submethod BUILD(:@list, :%hash) {
nqp::bindattr(self, Capture, '$!list',
nqp::getattr(nqp::decont(@list.Parcel), Parcel, '$!storage')
Expand Down

0 comments on commit 253bb58

Please sign in to comment.