Anonymous avatar Anonymous committed b2e3bd0

Issue 8: use Stmts nodes for for-loops. isop44++

Comments (0)

Files changed (2)

Grammar/Actions.nqp

 
     # XXX implement complex for syntax
 
-    # XXX right now this uses a Block rather than Stmts so that $iter's scope
-    # XXX is confined to this 'for'. Better to use Stmts and make $iter an anonymous register.
-    #my $past := PAST::Stmts.new( :node($/) );
-    my $past := PAST::Block.new( :blocktype('immediate'), :node($/) );
+    my $past := PAST::Stmts.new( :node($/) );
 
     # create iterator
     my $list := $( $<expression_list> );
-    my $iter := PAST::Var.new(     :name('iter'), :scope('register'), :node($/) );
-    my $iterdecl := PAST::Var.new( :name('iter'), :scope('register'), :node($/), :isdecl(1) );
-    $past.push( $iterdecl );
+    my $iter := PAST::Var.new( :scope('register'), :node($/) );
     $past.push( PAST::Op.new( $iter, $list,
                               :inline('    %0 = new "Iterator", %1'),
                               :node($/) ) );

Lib/test/parrot/control-flow.py

     i = 2
 if i == 2: print('failure: nested scopes')
 else: print('success: nested scopes')
+
+print('test: for var exists after loop')
+i = 0
+for i in [7,1,3]:
+    pass
+if i == 3: print('success: for var exists after loop')
+else: print('failure: for var exists after loop')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.