From 7ba0f603e294ea0cfddfb6b03a2e0ad92ccbf6ce Mon Sep 17 00:00:00 2001 From: k Date: Fri, 14 Feb 2025 08:20:40 +0100 Subject: [PATCH 1/2] Fix var parsing with metadata --- hscript/Parser.hx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hscript/Parser.hx b/hscript/Parser.hx index aa011d0e..598a5fb4 100644 --- a/hscript/Parser.hx +++ b/hscript/Parser.hx @@ -605,8 +605,9 @@ class Parser { switch (tk) { case TOp("="): e = parseExpr(); - case TComma | TSemicolon: push(tk); - default: unexpected(tk); + case TOp(_): unexpected(tk); + // TComma | TSemicolon | TMeta should be enough? but would need more testing + default: push(tk); } mk(EVar(ident,t,e),p1,(e == null) ? tokenMax : pmax(e)); From 043d9b4e471260b74e1fd01fab1dd681b92ba2d6 Mon Sep 17 00:00:00 2001 From: k Date: Fri, 14 Feb 2025 09:45:10 +0100 Subject: [PATCH 2/2] Only allow arbitrary tokens after a type (potential optional semicolon) --- hscript/Parser.hx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hscript/Parser.hx b/hscript/Parser.hx index 598a5fb4..f71bb59b 100644 --- a/hscript/Parser.hx +++ b/hscript/Parser.hx @@ -606,8 +606,10 @@ class Parser { { case TOp("="): e = parseExpr(); case TOp(_): unexpected(tk); - // TComma | TSemicolon | TMeta should be enough? but would need more testing - default: push(tk); + case TComma | TSemicolon: push(tk); + // Above case should be enough but semicolon is not mandatory after } + case _ if (t != null): push(tk); + default: unexpected(tk); } mk(EVar(ident,t,e),p1,(e == null) ? tokenMax : pmax(e));