From 18382c46211200eb079fa0d6521401df523e7e70 Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Thu, 25 Apr 2024 21:49:39 +0200 Subject: [PATCH] Fixed no hscriptPos errors --- hscript/Parser.hx | 18 ++++++++++++------ hscript/Tools.hx | 2 +- tests/src/Util.hx | 6 +++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/hscript/Parser.hx b/hscript/Parser.hx index 1e9a10f..281d4c7 100644 --- a/hscript/Parser.hx +++ b/hscript/Parser.hx @@ -37,9 +37,9 @@ typedef StoredToken = Token; #if hscriptPos typedef TokenList = List; #elseif haxe3 -typedef TokenList = haxe.ds.GenericStack; +typedef TokenList = List; #else -typedef TokenList = haxe.FastList; +typedef TokenList = haxe.FastList; #end enum Token { @@ -172,7 +172,7 @@ class Parser { #end } - public inline function error( err, pmin, pmax ) { + public inline function error( err: Error, pmin: Int, pmax: Int ) { if( !resumeErrors ) #if hscriptPos throw new Error(err, pmin, pmax, origin, line); @@ -193,11 +193,11 @@ class Parser { readPos = 0; tokenMin = oldTokenMin = 0; tokenMax = oldTokenMax = 0; - tokens = new List(); + tokens = new List(); #elseif haxe3 - tokens = new haxe.ds.GenericStack(); + tokens = new List(); #else - tokens = new haxe.FastList(); + tokens = new haxe.FastList(); #end char = -1; ops = new Array(); @@ -398,22 +398,28 @@ class Parser { function parseExprFromTokens(t:TokenList) { var oldPos = readPos; + #if hscriptPos var oldTokenMin = tokenMin; var oldTokenMax = tokenMax; + #end var oldTokens = tokens; tokens = t; // unsure about these + #if hscriptPos tokenMin = 0; tokenMax = t.length - 1; + #end readPos = 0; //trace(t.map(getTk).map(tokenString)); var e = parseExpr(); tokens = oldTokens; + #if hscriptPos tokenMin = oldTokenMin; tokenMax = oldTokenMax; + #end readPos = oldPos; return e; } diff --git a/hscript/Tools.hx b/hscript/Tools.hx index ea293e4..bf08360 100644 --- a/hscript/Tools.hx +++ b/hscript/Tools.hx @@ -93,7 +93,7 @@ class Tools { case ESwitch(e, cases, def): ESwitch(f(e), [for( c in cases ) new SwitchCase([for( v in c.values ) f(v)], f(c.expr))], def == null ? null : f(def)); case EMeta(name, args, e): EMeta(name, args == null ? null : [for( a in args ) f(a)], f(e)); case ECheckType(e,t): ECheckType(f(e), t); - case EImport(c): EImport(c); + case EImport(c, as): EImport(c, as); case EClass(name, el, extend, interfaces): EClass(name, [for( e in el ) f(e)], extend, interfaces); } return mk(edef, e); diff --git a/tests/src/Util.hx b/tests/src/Util.hx index 2cb2f60..39a1db5 100644 --- a/tests/src/Util.hx +++ b/tests/src/Util.hx @@ -274,9 +274,13 @@ class Util { } public static function errorHandler(error:hscript.Error) { + #if hscriptPos var fileName = error.origin; var fn = '$fileName:${error.line}: '; - var err = error.toString(); + #else + var fn = ''; + #end + var err = Std.string(error); if (err.startsWith(fn)) err = err.substr(fn.length); Sys.println("ERROR: " + fn + err);