Navigation Menu

Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
[nqp]: Add $<foo> and $[0] variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Oct 28, 2009
1 parent dd2ec36 commit 1316068
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/NQP/Actions.pm
Expand Up @@ -141,12 +141,19 @@ method colonpair($/) {
}

method variable($/) {
my $past := PAST::Var.new( :name(~$/) );
if $<twigil> && $<twigil>[0] eq '*' {
$past.scope('contextual');
$past.viviself(
PAST::Op.new( 'Contextual ' ~ ~$/ ~ ' not found', :pirop('die') )
);
my $past;
if $<postcircumfix> {
$past := $<postcircumfix>.ast;
$past.unshift( PAST::Var.new( :name('$/') ) );
}
else {
$past := PAST::Var.new( :name(~$/) );
if $<twigil> && $<twigil>[0] eq '*' {
$past.scope('contextual');
$past.viviself( PAST::Op.new( 'Contextual ' ~ ~$/ ~ ' not found',
:pirop('die') )
);
}
}
make $past;
}
Expand Down
1 change: 1 addition & 0 deletions src/NQP/Grammar.pm
Expand Up @@ -127,6 +127,7 @@ token colonpair {

token variable {
| <sigil> <twigil>? <desigilname=ident>
| <sigil> <?[<[]> <postcircumfix>
| $<sigil>=['$'] $<desigilname>=[<[/_!]>]
}

Expand Down

0 comments on commit 1316068

Please sign in to comment.