Skip to content

Commit b9f1e11

Browse files
committed
Add an EXPR that produces QAST.
1 parent 10f4753 commit b9f1e11

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/NQPQ/Actions.pm

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,32 @@ class NQP::Actions is HLL::Actions {
437437
method statement_mod_loop:sym<while>($/) { make $<cond>.ast; }
438438
method statement_mod_loop:sym<until>($/) { make $<cond>.ast; }
439439

440+
## Expression handling.
441+
442+
method EXPR($/, $key?) {
443+
unless $key { return 0; }
444+
my $past := $/.ast // $<OPER>.ast;
445+
unless $past {
446+
$past := QAST::Op.new( :node($/) );
447+
if $<OPER><O><op> {
448+
$past.op( ~$<OPER><O><op> );
449+
}
450+
unless $past.op {
451+
if $key eq 'LIST' { $key := 'infix'; }
452+
my $name := nqp::lc($key) ~ ':<' ~ $<OPER><sym> ~ '>';
453+
$past.op('call'),
454+
$past.name('&' ~ $name);
455+
}
456+
}
457+
if $key eq 'POSTFIX' {
458+
$past.unshift($/[0].ast);
459+
}
460+
else {
461+
for $/.list { if nqp::defined($_.ast) { $past.push($_.ast); } }
462+
}
463+
make $past;
464+
}
465+
440466
## Terms
441467

442468
method term:sym<fatarrow>($/) { make $<fatarrow>.ast; }

0 commit comments

Comments
 (0)