Fixed no hscriptPos errors

This commit is contained in:
NeeEoo
2024-04-25 21:49:39 +02:00
parent ad93c1bc18
commit 18382c4621
3 changed files with 18 additions and 8 deletions
+12 -6
View File
@@ -37,9 +37,9 @@ typedef StoredToken = Token;
#if hscriptPos
typedef TokenList = List<StoredToken>;
#elseif haxe3
typedef TokenList = haxe.ds.GenericStack<Token>;
typedef TokenList = List<StoredToken>;
#else
typedef TokenList = haxe.FastList<Token>;
typedef TokenList = haxe.FastList<StoredToken>;
#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<StoredToken>();
#elseif haxe3
tokens = new haxe.ds.GenericStack<Token>();
tokens = new List<StoredToken>();
#else
tokens = new haxe.FastList<Token>();
tokens = new haxe.FastList<StoredToken>();
#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;
}
+1 -1
View File
@@ -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);
+5 -1
View File
@@ -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);