Integrate typescript #8
@ -46,6 +46,8 @@ public class Filename {
|
||||
|
||||
|
||||
public Filename(String protocol, String path) {
|
||||
path = path.trim();
|
||||
protocol = protocol.trim();
|
||||
this.protocol = protocol;
|
||||
this.path = path;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package me.topchetoeu.jscript;
|
||||
|
||||
public class Location implements Comparable<Location> {
|
||||
public static final Location INTERNAL = new Location(0, 0, new Filename("jscript", "internal"));
|
||||
public static final Location INTERNAL = new Location(0, 0, new Filename("jscript", "native"));
|
||||
private int line;
|
||||
private int start;
|
||||
private Filename filename;
|
||||
|
@ -2,7 +2,6 @@ package me.topchetoeu.jscript.engine.debug;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import me.topchetoeu.jscript.Filename;
|
||||
import me.topchetoeu.jscript.json.JSON;
|
||||
import me.topchetoeu.jscript.json.JSONElement;
|
||||
import me.topchetoeu.jscript.json.JSONMap;
|
||||
@ -33,7 +32,7 @@ public class V8Message {
|
||||
this.params = raw.contains("params") ? raw.map("params") : new JSONMap();
|
||||
}
|
||||
public V8Message(String raw) {
|
||||
this(JSON.parse(new Filename("jscript", "json-msg"), raw).map());
|
||||
this(JSON.parse(null, raw).map());
|
||||
}
|
||||
|
||||
public JSONMap toMap() {
|
||||
|
@ -177,6 +177,7 @@ public class JSON {
|
||||
return ParseRes.res(values, n);
|
||||
}
|
||||
public static JSONElement parse(Filename filename, String raw) {
|
||||
if (filename == null) filename = new Filename("jscript", "json");
|
||||
var res = parseValue(filename, Parsing.tokenize(filename, raw), 0);
|
||||
if (res.isFailed()) throw new SyntaxException(null, "Invalid JSON given.");
|
||||
else if (res.isError()) throw new SyntaxException(null, res.error);
|
||||
@ -191,6 +192,7 @@ public class JSON {
|
||||
.replace("\\", "\\\\")
|
||||
.replace("\n", "\\n")
|
||||
.replace("\r", "\\r")
|
||||
.replace("\t", "\\t")
|
||||
.replace("\"", "\\\"")
|
||||
+ "\"";
|
||||
if (el.isList()) {
|
||||
|
@ -1,17 +1,16 @@
|
||||
package me.topchetoeu.jscript.lib;
|
||||
|
||||
import me.topchetoeu.jscript.Filename;
|
||||
import me.topchetoeu.jscript.engine.Context;
|
||||
import me.topchetoeu.jscript.exceptions.EngineException;
|
||||
import me.topchetoeu.jscript.exceptions.SyntaxException;
|
||||
import me.topchetoeu.jscript.interop.Native;
|
||||
import me.topchetoeu.jscript.json.JSON;
|
||||
|
||||
public class JSONLib {
|
||||
@Native("JSON") public class JSONLib {
|
||||
@Native
|
||||
public static Object parse(Context ctx, String val) {
|
||||
try {
|
||||
return JSON.toJs(JSON.parse(new Filename("jscript", "json"), val));
|
||||
return JSON.toJs(JSON.parse(null, val));
|
||||
}
|
||||
catch (SyntaxException e) { throw EngineException.ofSyntax(e.msg); }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user