Skip to content

Commit 3300ce0

Browse files
authored
Allow trailing array commas (#139)
1 parent 9f4531c commit 3300ce0

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

TestHScript.hx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class TestHScript extends TestCase {
7373
assertScript("3 * 2 // + 5 \n + 6",12);
7474
assertScript("3 /* 2\n */ + 5",8);
7575
assertScript("[55,66,77][1]",66);
76+
assertScript("[11,22,33,][2]", 33);
7677
assertScript("var a = [55]; a[0] *= 2; a[0]",110);
7778
assertScript("x",55,{ x : 55 });
7879
assertScript("var y = 33; y",33);

hscript/Parser.hx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,11 @@ class Parser {
451451
if (!first) {
452452
if (tk != TComma)
453453
unexpected(tk);
454-
else
454+
else {
455455
tk = token();
456+
if (tk == TBkClose)
457+
break;
458+
}
456459
}
457460
first = false;
458461
push(tk);

0 commit comments

Comments
 (0)