From 64ee7221242b40c094ca4c3f1893fce4b2c8923f Mon Sep 17 00:00:00 2001 From: Jaime Humberto Macias Bustamante Date: Sun, 11 May 2025 12:36:55 -0700 Subject: [PATCH] Allow trailing array commas (https://github.com/HaxeFoundation/hscript/pull/139) --- TestHScript.hx | 1 + hscript/Parser.hx | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/TestHScript.hx b/TestHScript.hx index a20dd75..65ebd8c 100644 --- a/TestHScript.hx +++ b/TestHScript.hx @@ -57,6 +57,7 @@ class TestHScript extends TestCase { assertScript("3 * 2 // + 5 \n + 6",12); assertScript("3 /* 2\n */ + 5",8); assertScript("[55,66,77][1]",66); + assertScript("[11,22,33,][2]", 33); assertScript("var a = [55]; a[0] *= 2; a[0]",110); assertScript("x",55,{ x : 55 }); assertScript("var y = 33; y",33); diff --git a/hscript/Parser.hx b/hscript/Parser.hx index fd199ca..f5ed22d 100644 --- a/hscript/Parser.hx +++ b/hscript/Parser.hx @@ -486,8 +486,11 @@ class Parser { if(!first) { if(tk != TComma) unexpected(tk); - else + else { tk = token(); + if (tk == TBkClose) + break; + } } first = false; push(tk);