Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
let say be a term, rather then a sub
If it is a sub it will pollute nested v6 blocks.
  • Loading branch information
FROGGS committed Jun 4, 2013
1 parent 9353bdf commit 206e529
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
10 changes: 10 additions & 0 deletions lib/Perl5/Actions.nqp
Expand Up @@ -3795,6 +3795,16 @@ class Perl5::Actions is HLL::Actions does STDActions {
make $past
}

method term:sym<say>($/) {
$V5DEBUG && say("term:sym<say>($/)");
my $past := $<arglist> ?? $<arglist>.ast
!! QAST::Op.new( :op('call'), QAST::Var.new( :name('$_'), :scope('lexical') ) );
$past.name('&infix:<P5~>');

$past := QAST::Op.new( :op('callmethod'), :name('say'), $past );
make $past
}

method term:sym<rand>($/) {
$V5DEBUG && say("term:sym<rand>($/)");
make QAST::Op.new( :op('call'), :name('&rand'), :node($/) );
Expand Down
4 changes: 4 additions & 0 deletions lib/Perl5/Grammar.nqp
Expand Up @@ -3454,6 +3454,10 @@ grammar Perl5::Grammar is HLL::Grammar does STD5 {
#~ token term:sym<print>
#~ { <sym> » <?before \s*> <.ws> [ <fh=.EXPR('z=')> <?before \s+> <.ws> <arglist> | <arglist> ]? }

token term:sym<say> {
<sym> <.ws> <arglist>?
}

# token term:sym<prototype>
# { <sym> » <?before \s*> <.ws> <EXPR('q=')>? }

Expand Down
6 changes: 2 additions & 4 deletions lib/Perl5/Terms.pm
Expand Up @@ -133,8 +133,7 @@ multi sub shift(@a) is export { @a ?? @a.shift !! Nil
multi sub undef() is export { Nil }
multi sub undef($a is rw) is export { undefine $a; Nil }

multi infix:<P5~>(\a = '') is export { a.P5Str }
multi infix:<P5~>(\a, \b) is export { a.P5Str ~ b.P5Str }
multi infix:<P5~>(*@a) is export { [~] map { .P5Str }, @a }
multi infix:<|=> (\a, \b) is export { a = a +& b }
multi infix:<&=> (\a, \b) is export { a = a +| b }
multi infix:<||=>(\a, \b) is export { a = b unless a }
Expand All @@ -148,8 +147,6 @@ multi trait_mod:<is>(Routine:D $r, :$lvalue!) is export {
$r.set_rw();
}

sub say(*@a) is export { @a.P5Str.say }; # XXX $*MAIN eq 'Perl5' ?? @a.P5Str.say !! @a.say

use Perl5::warnings ();
use MONKEY_TYPING;

Expand Down Expand Up @@ -202,6 +199,7 @@ augment class Str {
}

augment class Int {
multi method P5Str(Int:U:) { '' }
multi method P5Str(Int:D:) { self.Int }
}

Expand Down

0 comments on commit 206e529

Please sign in to comment.