Skip to content

Commit f70b982

Browse files
author
Troy Melhase
committed
Fixes for issue natural#25.
1 parent d24f417 commit f70b982

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

java2python/lib/walker.g

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,20 @@ returns [init = block.emptyAssign]
284284
initializer [block]
285285
returns [init]
286286
: init = expression[block, False]
287-
| init = array_initializer[block]
287+
| init = array_initializer[block] { init = ("[%s]", init) }
288288
;
289289

290290

291291
array_initializer [block]
292-
returns [init]
293-
: #(ARRAY_INIT (init = initializer[block])*)
292+
returns [ret = None]
293+
: #(ARRAY_INIT
294+
(init = initializer[block]
295+
{
296+
if ret:
297+
ret = ("%s, %s", (ret, init))
298+
else:
299+
ret = ("%s", init)
300+
} )*)
294301
;
295302

296303

java2python/tests/ArrayValues.java

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

0 commit comments

Comments
 (0)