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

Commit

Permalink
Handle postcircumfix: ast requirements.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Oct 20, 2009
1 parent 4e5addc commit 9bf6977
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
21 changes: 12 additions & 9 deletions src/HLL/Actions.pm
Expand Up @@ -2,16 +2,19 @@ class HLL::Actions;

method EXPR($/, $key?) {
unless $key { return 0; }
my $past := PAST::Op.new( :node($/) );
for $/.list { $past.push($_.ast); }
if $key eq 'INFIX' {
$past.name( 'infix:<' ~ $<OPER><sym> ~ '>' );
}
elsif $key eq 'PREFIX' {
$past.name( 'prefix:<' ~ $<OPER><sym> ~ '>' );
my $past := $<OPER>.peek_ast;
unless $past {
my $name := Q:PIR {
$P0 = find_lex '$key'
$S0 = $P0
$S0 = downcase $S0
%r = box $S0
} ~ ':<' ~ $key ~ '>';
$past := PAST::OP.new( :name($name), :node($/) );
}
elsif $key eq 'POSTFIX' {
$past.name( 'postfix:<' ~ $<OPER><sym> ~ '>' );
$past[0] := $/[0].ast;
if $key eq 'INFIX' {
$past[1] := $/[1].ast;
}
make $past;
}
Expand Down
2 changes: 1 addition & 1 deletion src/NQP/Actions.pm
Expand Up @@ -16,7 +16,7 @@ method term:sym<value>($/) { make $<value>.ast; }
method circumfix:sym<( )>($/) { make $<EXPR>.ast; }

method postcircumfix:sym<[ ]>($/) {
make PAST::Op.new( $<EXPR>.ast , :name('postcircumfix:<[ ]>') );
make PAST::Var.new( 0, $<EXPR>.ast , :scope('keyed_int') );
}

method value($/) {
Expand Down
8 changes: 8 additions & 0 deletions src/Regex/Match.pir
Expand Up @@ -107,6 +107,14 @@ has been set then returns C<Str> above.
.tailcall self.'Str'()
.end

.sub 'peek_ast' :method
.local pmc ast
ast = getattribute self, '$!ast'
unless null ast goto have_ast
ast = new ['Undef']
have_ast:
.return (ast)
.end

=back

Expand Down

0 comments on commit 9bf6977

Please sign in to comment.