Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added __LINE__ and __FILE__
  • Loading branch information
FROGGS committed Mar 30, 2013
1 parent fbfa1ac commit 197949f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/Perl6/P5Actions.pm
Expand Up @@ -3826,6 +3826,16 @@ class Perl6::P5Actions is HLL::Actions does STDActions {
make QAST::Op.new( :op('call'), :name('&rand'), :node($/) );
}

method term:sym<__LINE__>($/) {
$DEBUG && say("term:sym<__LINE__>($/)");
make $*W.add_constant('Int', 'int', HLL::Compiler.lineof($/.orig, $/.from, :cache(1)))
}

method term:sym<__FILE__>($/) {
$DEBUG && say("term:sym<__FILE__>($/)");
make $*W.add_string_constant(nqp::getlexdyn('$?FILES') // '<unknown file>');
}

sub make_yada($name, $/) {
my $past := $<args>.ast;
$past.name($name);
Expand Down
7 changes: 7 additions & 0 deletions lib/Perl6/P5Grammar.pm
Expand Up @@ -3361,6 +3361,13 @@ grammar Perl6::P5Grammar is HLL::Grammar does STD5 {
# token term:sym<rand>
# { <sym> » <?before \s*> <.ws> <EXPR('q=')>? }

token term:sym<__LINE__> {
<sym>
}
token term:sym<__FILE__> {
<sym>
}

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

Expand Down

0 comments on commit 197949f

Please sign in to comment.