From aaac98d7b0045a66942f2377fc40266f74e28d0c Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Thu, 25 Apr 2024 04:43:59 +0200 Subject: [PATCH] Small helper function --- hscript/Parser.hx | 7 +++++++ tests/src/tests/SwitchCase.hx | 1 + 2 files changed, 8 insertions(+) diff --git a/hscript/Parser.hx b/hscript/Parser.hx index 6a3822d..935ce78 100644 --- a/hscript/Parser.hx +++ b/hscript/Parser.hx @@ -2035,6 +2035,12 @@ class Parser { return TConst( CString(b.toString()) ); } + function peekToken():Token { + var t = token(); + push(t); + return t; + } + function token(/*?infos : Null*/) { //function ttrace(v:Dynamic, ?infos : Null) { // Sys.print(infos.fileName+":"+infos.lineNumber+": " + Std.string(v)); @@ -2042,6 +2048,7 @@ class Parser { //} #if hscriptPos + // Maybe have if( tokens.isEmpty() ) var t = tokens.pop(); if( t != null ) { tokenMin = t.min; diff --git a/tests/src/tests/SwitchCase.hx b/tests/src/tests/SwitchCase.hx index b49310e..a3d52a7 100644 --- a/tests/src/tests/SwitchCase.hx +++ b/tests/src/tests/SwitchCase.hx @@ -28,6 +28,7 @@ class SwitchCase extends TestCase { Util.runKnownBug("Switch statement with multiple cases in parentheses", () -> { assertEq("switch(5) { case (1|4): 'error'; default: -1; }", switch(5) { case (1|4): 'error'; default: -1; }); + assertEq("switch(6) { case (1|4|(6|7)): 6; default: -1; }", switch(6) { case (1|4|(6|7)): 6; default: -1; }); }); }