X Tutup
Skip to content

Commit d24f417

Browse files
author
Troy Melhase
committed
Changes to close issue natural#1.
1 parent 1c8543a commit d24f417

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

java2python/lib/walker.g

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,16 @@ statement [block]
393393
}
394394

395395

396-
| #("do" statement[block] do_exp = expression[block])
397-
{raise NotImplementedError("do statement")}
396+
| {
397+
while_stat = block.newStatement("while")
398+
while_stat.setExpression("True")
399+
}
400+
#("do" statement[while_stat] do_exp = expression[block, False])
401+
{
402+
if_stat = while_stat.newStatement("if")
403+
if_stat.setExpression(("not %s", do_exp))
404+
if_stat.newStatement("break")
405+
}
398406

399407

400408
| {

java2python/tests/Loops.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ public static void main(String[] args) {
88
for (int b = 0; b < 20; b+=2) {
99
}
1010

11+
doWhile();
12+
}
13+
14+
public static int doWhile() {
15+
int x = 0;
16+
do {
17+
System.out.println(x);
18+
x += 1;
19+
} while (x <= 10);
20+
return x;
1121
}
1222
}
1323

0 commit comments

Comments
 (0)
X Tutup