Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
implement length()
  • Loading branch information
FROGGS committed Mar 30, 2013
1 parent 206cb36 commit 082a2a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions lib/Perl6/P5Actions.pm
Expand Up @@ -3821,6 +3821,14 @@ class Perl6::P5Actions is HLL::Actions does STDActions {
make QAST::Op.new( :op('call'), :name('&term:<time>'), :node($/) );
}

method term:sym<length>($/) {
$DEBUG && say("term:sym<length>($/)");
make QAST::Op.new(
:op('callmethod'), :name('chars'),
$<EXPR> ?? $<EXPR>[0].ast
!! QAST::Var.new( :name('$_'), :scope('lexical') ) )
}

method term:sym<rand>($/) {
$DEBUG && say("term:sym<rand>($/)");
make QAST::Op.new( :op('call'), :name('&rand'), :node($/) );
Expand Down
4 changes: 2 additions & 2 deletions lib/Perl6/P5Grammar.pm
Expand Up @@ -3322,8 +3322,8 @@ grammar Perl6::P5Grammar is HLL::Grammar does STD5 {
# token term:sym<lcfirst>
# { <sym> » <?before \s*> <.ws> <EXPR('q=')>? }

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

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

0 comments on commit 082a2a3

Please sign in to comment.