remove formatted
This commit is contained in:
parent
51789efd90
commit
33d96429f4
@ -426,7 +426,7 @@ public class Values {
|
||||
if (clazz == Void.class) return null;
|
||||
if (clazz == null || clazz == Object.class) return (T)obj;
|
||||
|
||||
var err = new IllegalArgumentException("Cannot convert '%s' to '%s'.".formatted(type(obj), clazz.getName()));
|
||||
var err = new IllegalArgumentException(String.format("Cannot convert '%s' to '%s'.", type(obj), clazz.getName()));
|
||||
|
||||
if (obj instanceof NativeWrapper) {
|
||||
var res = ((NativeWrapper)obj).wrapped;
|
||||
|
@ -7,7 +7,7 @@ public class SyntaxException extends RuntimeException {
|
||||
public final String msg;
|
||||
|
||||
public SyntaxException(Location loc, String msg) {
|
||||
super("Syntax error (at %s): %s".formatted(loc, msg));
|
||||
super(String.format("Syntax error (at %s): %s", loc, msg));
|
||||
this.loc = loc;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class JSONMap implements Map<String, JSONElement> {
|
||||
|
||||
public JSONMap map(String path) {
|
||||
var el = get(path);
|
||||
if (el == null) throw new IllegalStateException("'%s' doesn't exist.".formatted(path));
|
||||
if (el == null) throw new IllegalStateException(String.format("'%s' doesn't exist.", path));
|
||||
return el.map();
|
||||
}
|
||||
public JSONMap map(String path, JSONMap defaultVal) {
|
||||
@ -63,7 +63,7 @@ public class JSONMap implements Map<String, JSONElement> {
|
||||
|
||||
public JSONList list(String path) {
|
||||
var el = get(path);
|
||||
if (el == null) throw new IllegalStateException("'%s' doesn't exist.".formatted(path));
|
||||
if (el == null) throw new IllegalStateException(String.format("'%s' doesn't exist.", path));
|
||||
return el.list();
|
||||
}
|
||||
public JSONList list(String path, JSONList defaultVal) {
|
||||
@ -75,7 +75,7 @@ public class JSONMap implements Map<String, JSONElement> {
|
||||
|
||||
public String string(String path) {
|
||||
var el = get(path);
|
||||
if (el == null) throw new IllegalStateException("'%s' doesn't exist.".formatted(path));
|
||||
if (el == null) throw new IllegalStateException(String.format("'%s' doesn't exist.", path));
|
||||
return el.string();
|
||||
}
|
||||
public String string(String path, String defaultVal) {
|
||||
@ -87,7 +87,7 @@ public class JSONMap implements Map<String, JSONElement> {
|
||||
|
||||
public double number(String path) {
|
||||
var el = get(path);
|
||||
if (el == null) throw new IllegalStateException("'%s' doesn't exist.".formatted(path));
|
||||
if (el == null) throw new IllegalStateException(String.format("'%s' doesn't exist.", path));
|
||||
return el.number();
|
||||
}
|
||||
public double number(String path, double defaultVal) {
|
||||
@ -99,7 +99,7 @@ public class JSONMap implements Map<String, JSONElement> {
|
||||
|
||||
public boolean bool(String path) {
|
||||
var el = get(path);
|
||||
if (el == null) throw new IllegalStateException("'%s' doesn't exist.".formatted(path));
|
||||
if (el == null) throw new IllegalStateException(String.format("'%s' doesn't exist.", path));
|
||||
return el.bool();
|
||||
}
|
||||
public boolean bool(String path, boolean defaultVal) {
|
||||
|
@ -374,7 +374,7 @@ public class Parsing {
|
||||
currStage = CURR_STRING;
|
||||
continue;
|
||||
}
|
||||
else throw new SyntaxException(new Location(line, start, filename), "Unrecognized character %s.".formatted(c));
|
||||
else throw new SyntaxException(new Location(line, start, filename), String.format("Unrecognized character %s.", c));
|
||||
}
|
||||
|
||||
// if we got here, we know that we have encountered the end of a token
|
||||
@ -542,7 +542,7 @@ public class Parsing {
|
||||
else res.add(Token.number(el.line, el.start, Double.parseDouble(el.value))); break;
|
||||
case OPERATOR:
|
||||
Operator op = Operator.parse(el.value);
|
||||
if (op == null) throw new SyntaxException(loc, "Unrecognized operator '%s'.".formatted(el.value));
|
||||
if (op == null) throw new SyntaxException(loc, String.format("Unrecognized operator '%s'.", el.value));
|
||||
res.add(Token.operator(el.line, el.start, op));
|
||||
break;
|
||||
case STRING:
|
||||
@ -959,7 +959,7 @@ public class Parsing {
|
||||
var res = parseValue(filename, tokens, n + i, 14);
|
||||
|
||||
if (res.isSuccess()) return ParseRes.res(new OperationStatement(loc, operation, res.result), n + res.n);
|
||||
else return ParseRes.error(loc, "Expected a value after the unary operator '%s'.".formatted(op.value), res);
|
||||
else return ParseRes.error(loc, String.format("Expected a value after the unary operator '%s'.", op.value), res);
|
||||
}
|
||||
public static ParseRes<ChangeStatement> parsePrefixChange(String filename, List<Token> tokens, int i) {
|
||||
var loc = getLoc(filename, tokens, i);
|
||||
@ -1029,7 +1029,7 @@ public class Parsing {
|
||||
if (literal.result.equals("async")) return ParseRes.error(loc, "'async' is not supported.");
|
||||
if (literal.result.equals("const")) return ParseRes.error(loc, "'const' declarations are not supported.");
|
||||
if (literal.result.equals("let")) return ParseRes.error(loc, "'let' declarations are not supported.");
|
||||
return ParseRes.error(loc, "Unexpected identifier '%s'.".formatted(literal.result));
|
||||
return ParseRes.error(loc, String.format("Unexpected identifier '%s'.", literal.result));
|
||||
}
|
||||
|
||||
return ParseRes.res(new VariableStatement(loc, literal.result), 1);
|
||||
@ -1106,7 +1106,7 @@ public class Parsing {
|
||||
if (!(prev instanceof AssignableStatement)) return ParseRes.error(loc, "Invalid expression on left hand side of assign operator.");
|
||||
|
||||
var res = parseValue(filename, tokens, i + n, 2);
|
||||
if (!res.isSuccess()) return ParseRes.error(loc, "Expected value after assignment operator '%s'.".formatted(op.value), res);
|
||||
if (!res.isSuccess()) return ParseRes.error(loc, String.format("Expected value after assignment operator '%s'.", op.value), res);
|
||||
n += res.n;
|
||||
|
||||
Operation operation = null;
|
||||
@ -1245,7 +1245,7 @@ public class Parsing {
|
||||
if (op.isAssign()) return parseAssign(filename, tokens, i + n - 1, prev, precedence);
|
||||
|
||||
var res = parseValue(filename, tokens, i + n, op.precedence + (op.reverse ? 0 : 1));
|
||||
if (!res.isSuccess()) return ParseRes.error(loc, "Expected a value after the '%s' operator.".formatted(op.value), res);
|
||||
if (!res.isSuccess()) return ParseRes.error(loc, String.format("Expected a value after the '%s' operator.", op.value), res);
|
||||
n += res.n;
|
||||
|
||||
if (op == Operator.LAZY_AND) {
|
||||
@ -1337,7 +1337,7 @@ public class Parsing {
|
||||
if (!nameRes.isSuccess()) return ParseRes.error(loc, "Expected a variable name.");
|
||||
|
||||
if (!checkVarName(nameRes.result)) {
|
||||
return ParseRes.error(loc, "Unexpected identifier '%s'.".formatted(nameRes.result));
|
||||
return ParseRes.error(loc, String.format("Unexpected identifier '%s'.", nameRes.result));
|
||||
}
|
||||
|
||||
Statement val = null;
|
||||
|
@ -73,7 +73,7 @@ public class PolyfillEngine extends Engine {
|
||||
return Values.call(ctx, values[0], ctx);
|
||||
}
|
||||
finally {
|
||||
System.out.println("Function took %s ms".formatted((System.nanoTime() - start) / 1000000.));
|
||||
System.out.println(String.format("Function took %s ms", (System.nanoTime() - start) / 1000000.));
|
||||
}
|
||||
}));
|
||||
global().define(true, new NativeFunction("isNaN", (ctx, thisArg, args) -> {
|
||||
|
Loading…
Reference in New Issue
Block a user