Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement s[...] op= foo.
  • Loading branch information
jnthn committed Jan 12, 2015
1 parent d7338dc commit 495bc53
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
16 changes: 15 additions & 1 deletion src/Perl6/Actions.nqp
Expand Up @@ -6108,7 +6108,21 @@ class Perl6::Actions is HLL::Actions does STDActions {
$<sibble><left>.ast, 'anon', '', %sig_info, $rx_block, :use_outer_match(1)) if $<sibble><left>.ast;

# Quote needs to be closure-i-fied.
my $closure := block_closure(make_thunk_ref($<sibble><right>.ast, $<sibble><right>));
my $infixish := $<sibble><infixish>;
my $right;
if !$infixish || $infixish.Str eq '=' {
$right := $<sibble><right>.ast;
}
else {
$right := $infixish.ast;
$right.push(QAST::Op.new(
:op('assign'),
QAST::Op.new( :op('p6scalarfromdesc'), QAST::Op.new( :op('null') ) ),
QAST::Var.new( :name('$/'), :scope('lexical') )
));
$right.push($<sibble><right>.ast);
}
my $closure := block_closure(make_thunk_ref($right, $<sibble><right>));

# make $/ = $_.subst-mutate(...)
my $past := QAST::Op.new(
Expand Down
3 changes: 1 addition & 2 deletions src/Perl6/Grammar.nqp
Expand Up @@ -3464,8 +3464,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
<.ws>
[ <?[ \[ \{ \( \< ]> <.obs('brackets around replacement', 'assignment syntax')> ]?
[ <infixish> || <.missing: "assignment operator"> ]
[ <?{ $<infixish>.Str eq '=' }> || <.malformed: "assignment operator"> ]
# XXX When we support it, above check should add: || $<infixish><infix_postfix_meta_operator>[0]
[ <?{ $<infixish>.Str eq '=' || $<infixish><infix_postfix_meta_operator> }> || <.malformed: "assignment operator"> ]
<.ws>
[ <right=.EXPR('i')> || <.panic: "Assignment operator missing its expression"> ]
||
Expand Down

0 comments on commit 495bc53

Please sign in to comment.