Skip to content

Commit b9415cd

Browse files
author
Troy Melhase
committed
Bugfix for missing for_iter expressions. Closes natural#14.
1 parent edf0a51 commit b9415cd

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

java2python/lib/walker.g

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ statement [block]
366366
| {
367367
block.addComment("for-while")
368368
for_init, for_stat = block.newFor()
369+
for_iter = None
369370
}
370371
#("for"
371372
#(FOR_INIT
@@ -376,7 +377,8 @@ statement [block]
376377
)
377378
{
378379
for_stat.setExpression(("%s", for_cond))
379-
for_stat.addSource(("%s", for_iter))
380+
if for_iter:
381+
for_stat.addSource(("%s", for_iter))
380382
}
381383

382384

java2python/tests/Loops.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Loops {
2+
public static void main(String[] args) {
3+
for(int a = 1; a < 10;){
4+
a+= 3;
5+
System.out.println(a);
6+
}
7+
8+
for (int b = 0; b < 20; b+=2) {
9+
}
10+
11+
}
12+
}
13+

0 commit comments

Comments
 (0)