diff --git a/src/NQP/Actions.pm b/src/NQP/Actions.pm index 6b81a64..2154aa8 100644 --- a/src/NQP/Actions.pm +++ b/src/NQP/Actions.pm @@ -105,6 +105,16 @@ method statement_control:sym($/) { make $past; } +method statement_control:sym($/) { + my $past := $.ast; + $past.pasttype('for'); + my $block := $past[1]; + $block[0].push( PAST::Var.new( :name('$_'), :scope('parameter') ) ); + $block.symbol('$_', :scope('lexical') ); + $block.arity(1); + make $past; +} + ## Terms method noun:sym($/) { make $.ast; } diff --git a/src/NQP/Grammar.pm b/src/NQP/Grammar.pm index 68153a0..a11cc1e 100644 --- a/src/NQP/Grammar.pm +++ b/src/NQP/Grammar.pm @@ -82,6 +82,11 @@ token statement_control:sym { ] } +token statement_control:sym { + :s + +} + ## Terms token noun:sym { } diff --git a/t/nqp/15-list.t b/t/nqp/15-list.t new file mode 100644 index 0000000..5569985 --- /dev/null +++ b/t/nqp/15-list.t @@ -0,0 +1,12 @@ +#!./parrot nqp.pbc + +# lists and for + +plan(3); + +my $list := (1,2,3); +my $indexer := 0; + +for $list { + print("ok "); print($_); say(" checking loop via indices"); +}