Add first test #23
@ -1,14 +1,10 @@
|
|||||||
package me.topchetoeu.jscript.compilation;
|
package me.topchetoeu.jscript.compilation;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.common.Operation;
|
import me.topchetoeu.jscript.common.Operation;
|
||||||
import me.topchetoeu.jscript.common.parsing.Location;
|
|
||||||
|
|
||||||
public abstract class AssignableStatement extends Statement {
|
public interface AssignableStatement {
|
||||||
public abstract Statement toAssign(Statement val, Operation operation);
|
public abstract Statement toAssign(Statement val, Operation operation);
|
||||||
|
|
||||||
protected AssignableStatement(Location loc) {
|
|
||||||
super(loc);
|
|
||||||
}
|
|
||||||
// private static final Map<String, Operation> operations = Map.ofEntries(
|
// private static final Map<String, Operation> operations = Map.ofEntries(
|
||||||
// Map.entry("*=", Operation.MULTIPLY),
|
// Map.entry("*=", Operation.MULTIPLY),
|
||||||
// Map.entry("/=", Operation.DIVIDE),
|
// Map.entry("/=", Operation.DIVIDE),
|
||||||
|
@ -75,7 +75,7 @@ public class CompoundStatement extends Statement {
|
|||||||
if (!src.is(i + n, ",")) return ParseRes.failed();
|
if (!src.is(i + n, ",")) return ParseRes.failed();
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
var res = ES5.parseExpression(src, i + n, 2);
|
var res = JavaScript.parseExpression(src, i + n, 2);
|
||||||
if (!res.isSuccess()) return res.chainError(src.loc(i + n), "Expected a value after the comma");
|
if (!res.isSuccess()) return res.chainError(src.loc(i + n), "Expected a value after the comma");
|
||||||
n += res.n;
|
n += res.n;
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ public class CompoundStatement extends Statement {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var res = ES5.parseStatement(src, i + n);
|
var res = JavaScript.parseStatement(src, i + n);
|
||||||
if (!res.isSuccess()) return res.chainError(src.loc(i + n), "Expected a statement");
|
if (!res.isSuccess()) return res.chainError(src.loc(i + n), "Expected a statement");
|
||||||
n += res.n;
|
n += res.n;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ import me.topchetoeu.jscript.compilation.values.operations.TypeofStatement;
|
|||||||
import me.topchetoeu.jscript.compilation.values.operations.VariableIndexStatement;
|
import me.topchetoeu.jscript.compilation.values.operations.VariableIndexStatement;
|
||||||
import me.topchetoeu.jscript.runtime.exceptions.SyntaxException;
|
import me.topchetoeu.jscript.runtime.exceptions.SyntaxException;
|
||||||
|
|
||||||
public class ES5 {
|
public class JavaScript {
|
||||||
static final Set<String> reserved = Set.of(
|
static final Set<String> reserved = Set.of(
|
||||||
"true", "false", "void", "null", "this", "if", "else", "try", "catch",
|
"true", "false", "void", "null", "this", "if", "else", "try", "catch",
|
||||||
"finally", "for", "do", "while", "switch", "case", "default", "new",
|
"finally", "for", "do", "while", "switch", "case", "default", "new",
|
||||||
@ -59,7 +59,7 @@ public class ES5 {
|
|||||||
if (!openParen.isSuccess()) return openParen.chainError();
|
if (!openParen.isSuccess()) return openParen.chainError();
|
||||||
n += openParen.n;
|
n += openParen.n;
|
||||||
|
|
||||||
var res = ES5.parseExpression(src, i + n, 0);
|
var res = JavaScript.parseExpression(src, i + n, 0);
|
||||||
if (!res.isSuccess()) return res.chainError(src.loc(i + n), "Expected an expression in parens");
|
if (!res.isSuccess()) return res.chainError(src.loc(i + n), "Expected an expression in parens");
|
||||||
n += res.n;
|
n += res.n;
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ public class ES5 {
|
|||||||
return ParseRes.first(src, i,
|
return ParseRes.first(src, i,
|
||||||
(a, b) -> statement ? ParseRes.failed() : ObjectStatement.parse(a, b),
|
(a, b) -> statement ? ParseRes.failed() : ObjectStatement.parse(a, b),
|
||||||
(a, b) -> statement ? ParseRes.failed() : FunctionStatement.parseFunction(a, b, false),
|
(a, b) -> statement ? ParseRes.failed() : FunctionStatement.parseFunction(a, b, false),
|
||||||
ES5::parseLiteral,
|
JavaScript::parseLiteral,
|
||||||
StringStatement::parse,
|
StringStatement::parse,
|
||||||
RegexStatement::parse,
|
RegexStatement::parse,
|
||||||
NumberStatement::parse,
|
NumberStatement::parse,
|
||||||
@ -82,7 +82,7 @@ public class ES5 {
|
|||||||
ChangeStatement::parsePrefixIncrease,
|
ChangeStatement::parsePrefixIncrease,
|
||||||
OperationStatement::parsePrefix,
|
OperationStatement::parsePrefix,
|
||||||
ArrayStatement::parse,
|
ArrayStatement::parse,
|
||||||
ES5::parseParens,
|
JavaScript::parseParens,
|
||||||
CallStatement::parseNew,
|
CallStatement::parseNew,
|
||||||
TypeofStatement::parse,
|
TypeofStatement::parse,
|
||||||
DiscardStatement::parse,
|
DiscardStatement::parse,
|
||||||
@ -162,7 +162,7 @@ public class ES5 {
|
|||||||
var res = parseExpression(src, i, 0, true);
|
var res = parseExpression(src, i, 0, true);
|
||||||
if (!res.isSuccess()) return res.chainError();
|
if (!res.isSuccess()) return res.chainError();
|
||||||
|
|
||||||
var end = ES5.parseStatementEnd(src, i + res.n);
|
var end = JavaScript.parseStatementEnd(src, i + res.n);
|
||||||
if (!end.isSuccess()) return ParseRes.error(src.loc(i + res.n), "Expected an end of statement");
|
if (!end.isSuccess()) return ParseRes.error(src.loc(i + res.n), "Expected an end of statement");
|
||||||
|
|
||||||
return res.addN(end.n);
|
return res.addN(end.n);
|
||||||
@ -191,7 +191,7 @@ public class ES5 {
|
|||||||
TryStatement::parse,
|
TryStatement::parse,
|
||||||
CompoundStatement::parse,
|
CompoundStatement::parse,
|
||||||
(s, j) -> FunctionStatement.parseFunction(s, j, true),
|
(s, j) -> FunctionStatement.parseFunction(s, j, true),
|
||||||
ES5::parseExpressionStatement
|
JavaScript::parseExpressionStatement
|
||||||
);
|
);
|
||||||
return res.addN(n);
|
return res.addN(n);
|
||||||
}
|
}
|
||||||
@ -232,7 +232,7 @@ public class ES5 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkVarName(String name) {
|
public static boolean checkVarName(String name) {
|
||||||
return !ES5.reserved.contains(name);
|
return !JavaScript.reserved.contains(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ParseRes<List<String>> parseParamList(Source src, int i) {
|
public static ParseRes<List<String>> parseParamList(Source src, int i) {
|
||||||
@ -297,6 +297,6 @@ public class ES5 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static CompileResult compile(Filename filename, String raw) {
|
public static CompileResult compile(Filename filename, String raw) {
|
||||||
return ES5.compile(ES5.parse(filename, raw));
|
return JavaScript.compile(JavaScript.parse(filename, raw));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -63,7 +63,7 @@ public class VariableDeclareStatement extends Statement {
|
|||||||
|
|
||||||
var res = new ArrayList<Pair>();
|
var res = new ArrayList<Pair>();
|
||||||
|
|
||||||
var end = ES5.parseStatementEnd(src, i + n);
|
var end = JavaScript.parseStatementEnd(src, i + n);
|
||||||
if (end.isSuccess()) {
|
if (end.isSuccess()) {
|
||||||
n += end.n;
|
n += end.n;
|
||||||
return ParseRes.res(new VariableDeclareStatement(loc, res), n);
|
return ParseRes.res(new VariableDeclareStatement(loc, res), n);
|
||||||
@ -75,7 +75,7 @@ public class VariableDeclareStatement extends Statement {
|
|||||||
if (!name.isSuccess()) return name.chainError(nameLoc, "Expected a variable name");
|
if (!name.isSuccess()) return name.chainError(nameLoc, "Expected a variable name");
|
||||||
n += name.n;
|
n += name.n;
|
||||||
|
|
||||||
if (!ES5.checkVarName(name.result)) {
|
if (!JavaScript.checkVarName(name.result)) {
|
||||||
return ParseRes.error(src.loc(i + n), String.format("Unexpected identifier '%s'", name.result));
|
return ParseRes.error(src.loc(i + n), String.format("Unexpected identifier '%s'", name.result));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ public class VariableDeclareStatement extends Statement {
|
|||||||
if (src.is(i + n, "=")) {
|
if (src.is(i + n, "=")) {
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
var valRes = ES5.parseExpression(src, i + n, 2);
|
var valRes = JavaScript.parseExpression(src, i + n, 2);
|
||||||
if (!valRes.isSuccess()) return valRes.chainError(src.loc(i + n), "Expected a value after '='");
|
if (!valRes.isSuccess()) return valRes.chainError(src.loc(i + n), "Expected a value after '='");
|
||||||
|
|
||||||
n += valRes.n;
|
n += valRes.n;
|
||||||
@ -100,7 +100,7 @@ public class VariableDeclareStatement extends Statement {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
end = ES5.parseStatementEnd(src, i + n);
|
end = JavaScript.parseStatementEnd(src, i + n);
|
||||||
|
|
||||||
if (end.isSuccess()) {
|
if (end.isSuccess()) {
|
||||||
n += end.n;
|
n += end.n;
|
||||||
|
@ -6,7 +6,7 @@ import me.topchetoeu.jscript.common.parsing.ParseRes;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
|
|
||||||
public class BreakStatement extends Statement {
|
public class BreakStatement extends Statement {
|
||||||
@ -29,7 +29,7 @@ public class BreakStatement extends Statement {
|
|||||||
if (!Parsing.isIdentifier(src, i + n, "break")) return ParseRes.failed();
|
if (!Parsing.isIdentifier(src, i + n, "break")) return ParseRes.failed();
|
||||||
n += 5;
|
n += 5;
|
||||||
|
|
||||||
var end = ES5.parseStatementEnd(src, i + n);
|
var end = JavaScript.parseStatementEnd(src, i + n);
|
||||||
if (end.isSuccess()) {
|
if (end.isSuccess()) {
|
||||||
n += end.n;
|
n += end.n;
|
||||||
return ParseRes.res(new BreakStatement(loc, null), n);
|
return ParseRes.res(new BreakStatement(loc, null), n);
|
||||||
@ -39,7 +39,7 @@ public class BreakStatement extends Statement {
|
|||||||
if (label.isFailed()) return ParseRes.error(src.loc(i + n), "Expected a label name or an end of statement");
|
if (label.isFailed()) return ParseRes.error(src.loc(i + n), "Expected a label name or an end of statement");
|
||||||
n += label.n;
|
n += label.n;
|
||||||
|
|
||||||
end = ES5.parseStatementEnd(src, i + n);
|
end = JavaScript.parseStatementEnd(src, i + n);
|
||||||
if (end.isSuccess()) {
|
if (end.isSuccess()) {
|
||||||
n += end.n;
|
n += end.n;
|
||||||
return ParseRes.res(new BreakStatement(loc, label.result), n);
|
return ParseRes.res(new BreakStatement(loc, label.result), n);
|
||||||
|
@ -6,7 +6,7 @@ import me.topchetoeu.jscript.common.parsing.ParseRes;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
|
|
||||||
public class ContinueStatement extends Statement {
|
public class ContinueStatement extends Statement {
|
||||||
@ -29,7 +29,7 @@ public class ContinueStatement extends Statement {
|
|||||||
if (!Parsing.isIdentifier(src, i + n, "continue")) return ParseRes.failed();
|
if (!Parsing.isIdentifier(src, i + n, "continue")) return ParseRes.failed();
|
||||||
n += 8;
|
n += 8;
|
||||||
|
|
||||||
var end = ES5.parseStatementEnd(src, i + n);
|
var end = JavaScript.parseStatementEnd(src, i + n);
|
||||||
if (end.isSuccess()) {
|
if (end.isSuccess()) {
|
||||||
n += end.n;
|
n += end.n;
|
||||||
return ParseRes.res(new ContinueStatement(loc, null), n);
|
return ParseRes.res(new ContinueStatement(loc, null), n);
|
||||||
@ -39,7 +39,7 @@ public class ContinueStatement extends Statement {
|
|||||||
if (label.isFailed()) return ParseRes.error(src.loc(i + n), "Expected a label name or an end of statement");
|
if (label.isFailed()) return ParseRes.error(src.loc(i + n), "Expected a label name or an end of statement");
|
||||||
n += label.n;
|
n += label.n;
|
||||||
|
|
||||||
end = ES5.parseStatementEnd(src, i + n);
|
end = JavaScript.parseStatementEnd(src, i + n);
|
||||||
if (end.isSuccess()) {
|
if (end.isSuccess()) {
|
||||||
n += end.n;
|
n += end.n;
|
||||||
return ParseRes.res(new ContinueStatement(loc, label.result), n);
|
return ParseRes.res(new ContinueStatement(loc, label.result), n);
|
||||||
|
@ -6,7 +6,7 @@ import me.topchetoeu.jscript.common.parsing.ParseRes;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
|
|
||||||
public class DebugStatement extends Statement {
|
public class DebugStatement extends Statement {
|
||||||
@ -26,7 +26,7 @@ public class DebugStatement extends Statement {
|
|||||||
if (!Parsing.isIdentifier(src, i + n, "debugger")) return ParseRes.failed();
|
if (!Parsing.isIdentifier(src, i + n, "debugger")) return ParseRes.failed();
|
||||||
n += 8;
|
n += 8;
|
||||||
|
|
||||||
var end = ES5.parseStatementEnd(src, i + n);
|
var end = JavaScript.parseStatementEnd(src, i + n);
|
||||||
if (end.isSuccess()) {
|
if (end.isSuccess()) {
|
||||||
n += end.n;
|
n += end.n;
|
||||||
return ParseRes.res(new DebugStatement(loc), n);
|
return ParseRes.res(new DebugStatement(loc), n);
|
||||||
|
@ -6,7 +6,7 @@ import me.topchetoeu.jscript.common.parsing.ParseRes;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
import me.topchetoeu.jscript.compilation.values.VariableStatement;
|
import me.topchetoeu.jscript.compilation.values.VariableStatement;
|
||||||
import me.topchetoeu.jscript.compilation.values.constants.BoolStatement;
|
import me.topchetoeu.jscript.compilation.values.constants.BoolStatement;
|
||||||
@ -32,7 +32,7 @@ public class DeleteStatement extends Statement {
|
|||||||
if (!Parsing.isIdentifier(src, i + n, "delete")) return ParseRes.failed();
|
if (!Parsing.isIdentifier(src, i + n, "delete")) return ParseRes.failed();
|
||||||
n += 6;
|
n += 6;
|
||||||
|
|
||||||
var valRes = ES5.parseExpression(src, i + n, 15);
|
var valRes = JavaScript.parseExpression(src, i + n, 15);
|
||||||
if (!valRes.isSuccess()) return valRes.chainError(src.loc(i + n), "Expected a value after 'delete'");
|
if (!valRes.isSuccess()) return valRes.chainError(src.loc(i + n), "Expected a value after 'delete'");
|
||||||
n += valRes.n;
|
n += valRes.n;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import me.topchetoeu.jscript.common.parsing.ParseRes;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
|
|
||||||
public class DoWhileStatement extends Statement {
|
public class DoWhileStatement extends Statement {
|
||||||
@ -48,7 +48,7 @@ public class DoWhileStatement extends Statement {
|
|||||||
if (!Parsing.isIdentifier(src, i + n, "do")) return ParseRes.failed();
|
if (!Parsing.isIdentifier(src, i + n, "do")) return ParseRes.failed();
|
||||||
n += 2;
|
n += 2;
|
||||||
|
|
||||||
var bodyRes = ES5.parseStatement(src, i + n);
|
var bodyRes = JavaScript.parseStatement(src, i + n);
|
||||||
if (!bodyRes.isSuccess()) return bodyRes.chainError(src.loc(i + n), "Expected a do-while body.");
|
if (!bodyRes.isSuccess()) return bodyRes.chainError(src.loc(i + n), "Expected a do-while body.");
|
||||||
n += bodyRes.n;
|
n += bodyRes.n;
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ public class DoWhileStatement extends Statement {
|
|||||||
if (!src.is(i + n, "(")) return ParseRes.error(src.loc(i + n), "Expected a open paren after 'while'.");
|
if (!src.is(i + n, "(")) return ParseRes.error(src.loc(i + n), "Expected a open paren after 'while'.");
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
var condRes = ES5.parseExpression(src, i + n, 0);
|
var condRes = JavaScript.parseExpression(src, i + n, 0);
|
||||||
if (!condRes.isSuccess()) return condRes.chainError(src.loc(i + n), "Expected a do-while condition.");
|
if (!condRes.isSuccess()) return condRes.chainError(src.loc(i + n), "Expected a do-while condition.");
|
||||||
n += condRes.n;
|
n += condRes.n;
|
||||||
n += Parsing.skipEmpty(src, i + n);
|
n += Parsing.skipEmpty(src, i + n);
|
||||||
@ -67,7 +67,7 @@ public class DoWhileStatement extends Statement {
|
|||||||
if (!src.is(i + n, ")")) return ParseRes.error(src.loc(i + n), "Expected a closing paren after do-while condition.");
|
if (!src.is(i + n, ")")) return ParseRes.error(src.loc(i + n), "Expected a closing paren after do-while condition.");
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
var end = ES5.parseStatementEnd(src, i + n);
|
var end = JavaScript.parseStatementEnd(src, i + n);
|
||||||
if (end.isSuccess()) {
|
if (end.isSuccess()) {
|
||||||
n += end.n;
|
n += end.n;
|
||||||
return ParseRes.res(new DoWhileStatement(loc, labelRes.result, condRes.result, bodyRes.result), n);
|
return ParseRes.res(new DoWhileStatement(loc, labelRes.result, condRes.result, bodyRes.result), n);
|
||||||
|
@ -8,7 +8,7 @@ import me.topchetoeu.jscript.common.parsing.ParseRes;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
|
|
||||||
public class ForInStatement extends Statement {
|
public class ForInStatement extends Statement {
|
||||||
@ -91,7 +91,7 @@ public class ForInStatement extends Statement {
|
|||||||
if (!Parsing.isIdentifier(src, i + n, "in")) return ParseRes.error(src.loc(i + n), "Expected 'in' keyword after variable declaration");
|
if (!Parsing.isIdentifier(src, i + n, "in")) return ParseRes.error(src.loc(i + n), "Expected 'in' keyword after variable declaration");
|
||||||
n += 2;
|
n += 2;
|
||||||
|
|
||||||
var obj = ES5.parseExpression(src, i + n, 0);
|
var obj = JavaScript.parseExpression(src, i + n, 0);
|
||||||
if (!obj.isSuccess()) return obj.chainError(src.loc(i + n), "Expected a value");
|
if (!obj.isSuccess()) return obj.chainError(src.loc(i + n), "Expected a value");
|
||||||
n += obj.n;
|
n += obj.n;
|
||||||
n += Parsing.skipEmpty(src, i + n);
|
n += Parsing.skipEmpty(src, i + n);
|
||||||
@ -99,7 +99,7 @@ public class ForInStatement extends Statement {
|
|||||||
if (!src.is(i + n, ")")) return ParseRes.error(src.loc(i + n), "Expected a closing paren");
|
if (!src.is(i + n, ")")) return ParseRes.error(src.loc(i + n), "Expected a closing paren");
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
var bodyRes = ES5.parseStatement(src, i + n);
|
var bodyRes = JavaScript.parseStatement(src, i + n);
|
||||||
if (!bodyRes.isSuccess()) return bodyRes.chainError(src.loc(i + n), "Expected a for-in body");
|
if (!bodyRes.isSuccess()) return bodyRes.chainError(src.loc(i + n), "Expected a for-in body");
|
||||||
n += bodyRes.n;
|
n += bodyRes.n;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import me.topchetoeu.jscript.common.parsing.ParseRes;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
|
|
||||||
public class ForOfStatement extends Statement {
|
public class ForOfStatement extends Statement {
|
||||||
@ -103,7 +103,7 @@ public class ForOfStatement extends Statement {
|
|||||||
if (!Parsing.isIdentifier(src, i + n, "fo")) return ParseRes.error(src.loc(i + n), "Expected 'of' keyword after variable declaration");
|
if (!Parsing.isIdentifier(src, i + n, "fo")) return ParseRes.error(src.loc(i + n), "Expected 'of' keyword after variable declaration");
|
||||||
n += 2;
|
n += 2;
|
||||||
|
|
||||||
var obj = ES5.parseExpression(src, i + n, 0);
|
var obj = JavaScript.parseExpression(src, i + n, 0);
|
||||||
if (!obj.isSuccess()) return obj.chainError(src.loc(i + n), "Expected a value");
|
if (!obj.isSuccess()) return obj.chainError(src.loc(i + n), "Expected a value");
|
||||||
n += obj.n;
|
n += obj.n;
|
||||||
n += Parsing.skipEmpty(src, i + n);
|
n += Parsing.skipEmpty(src, i + n);
|
||||||
@ -111,7 +111,7 @@ public class ForOfStatement extends Statement {
|
|||||||
if (!src.is(i + n, ")")) return ParseRes.error(src.loc(i + n), "Expected a closing paren");
|
if (!src.is(i + n, ")")) return ParseRes.error(src.loc(i + n), "Expected a closing paren");
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
var bodyRes = ES5.parseStatement(src, i + n);
|
var bodyRes = JavaScript.parseStatement(src, i + n);
|
||||||
if (!bodyRes.isSuccess()) return bodyRes.chainError(src.loc(i + n), "Expected a for-of body");
|
if (!bodyRes.isSuccess()) return bodyRes.chainError(src.loc(i + n), "Expected a for-of body");
|
||||||
n += bodyRes.n;
|
n += bodyRes.n;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import me.topchetoeu.jscript.common.parsing.ParseRes;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
import me.topchetoeu.jscript.compilation.VariableDeclareStatement;
|
import me.topchetoeu.jscript.compilation.VariableDeclareStatement;
|
||||||
import me.topchetoeu.jscript.compilation.values.operations.DiscardStatement;
|
import me.topchetoeu.jscript.compilation.values.operations.DiscardStatement;
|
||||||
@ -58,7 +58,7 @@ public class ForStatement extends Statement {
|
|||||||
private static ParseRes<Statement> parseCondition(Source src, int i) {
|
private static ParseRes<Statement> parseCondition(Source src, int i) {
|
||||||
var n = Parsing.skipEmpty(src, i);
|
var n = Parsing.skipEmpty(src, i);
|
||||||
|
|
||||||
var res = ES5.parseExpression(src, i + n, 0);
|
var res = JavaScript.parseExpression(src, i + n, 0);
|
||||||
if (!res.isSuccess()) return res.chainError();
|
if (!res.isSuccess()) return res.chainError();
|
||||||
n += res.n;
|
n += res.n;
|
||||||
n += Parsing.skipEmpty(src, i + n);
|
n += Parsing.skipEmpty(src, i + n);
|
||||||
@ -67,7 +67,7 @@ public class ForStatement extends Statement {
|
|||||||
else return ParseRes.res(res.result, n + 1);
|
else return ParseRes.res(res.result, n + 1);
|
||||||
}
|
}
|
||||||
private static ParseRes<? extends Statement> parseUpdater(Source src, int i) {
|
private static ParseRes<? extends Statement> parseUpdater(Source src, int i) {
|
||||||
return ES5.parseExpression(src, i, 0);
|
return JavaScript.parseExpression(src, i, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ParseRes<ForStatement> parse(Source src, int i) {
|
public static ParseRes<ForStatement> parse(Source src, int i) {
|
||||||
@ -108,7 +108,7 @@ public class ForStatement extends Statement {
|
|||||||
if (!src.is(i + n, ")")) return ParseRes.error(src.loc(i + n), "Expected a close paren after for updater");
|
if (!src.is(i + n, ")")) return ParseRes.error(src.loc(i + n), "Expected a close paren after for updater");
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
var body = ES5.parseStatement(src, i + n);
|
var body = JavaScript.parseStatement(src, i + n);
|
||||||
if (!body.isSuccess()) return body.chainError(src.loc(i + n), "Expected a for body.");
|
if (!body.isSuccess()) return body.chainError(src.loc(i + n), "Expected a for body.");
|
||||||
n += body.n;
|
n += body.n;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import me.topchetoeu.jscript.common.parsing.ParseRes;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
|
|
||||||
public class IfStatement extends Statement {
|
public class IfStatement extends Statement {
|
||||||
@ -59,7 +59,7 @@ public class IfStatement extends Statement {
|
|||||||
var loc = src.loc(i + n);
|
var loc = src.loc(i + n);
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
var a = ES5.parseExpression(src, i + n, 2);
|
var a = JavaScript.parseExpression(src, i + n, 2);
|
||||||
if (!a.isSuccess()) return a.chainError(src.loc(i + n), "Expected a value after the ternary operator.");
|
if (!a.isSuccess()) return a.chainError(src.loc(i + n), "Expected a value after the ternary operator.");
|
||||||
n += a.n;
|
n += a.n;
|
||||||
n += Parsing.skipEmpty(src, i);
|
n += Parsing.skipEmpty(src, i);
|
||||||
@ -67,7 +67,7 @@ public class IfStatement extends Statement {
|
|||||||
if (!src.is(i + n, ":")) return ParseRes.failed();
|
if (!src.is(i + n, ":")) return ParseRes.failed();
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
var b = ES5.parseExpression(src, i + n, 2);
|
var b = JavaScript.parseExpression(src, i + n, 2);
|
||||||
if (!b.isSuccess()) return b.chainError(src.loc(i + n), "Expected a second value after the ternary operator.");
|
if (!b.isSuccess()) return b.chainError(src.loc(i + n), "Expected a second value after the ternary operator.");
|
||||||
n += b.n;
|
n += b.n;
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ public class IfStatement extends Statement {
|
|||||||
if (!src.is(i + n, "(")) return ParseRes.error(src.loc(i + n), "Expected a open paren after 'if'.");
|
if (!src.is(i + n, "(")) return ParseRes.error(src.loc(i + n), "Expected a open paren after 'if'.");
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
var condRes = ES5.parseExpression(src, i + n, 0);
|
var condRes = JavaScript.parseExpression(src, i + n, 0);
|
||||||
if (!condRes.isSuccess()) return condRes.chainError(src.loc(i + n), "Expected an if condition.");
|
if (!condRes.isSuccess()) return condRes.chainError(src.loc(i + n), "Expected an if condition.");
|
||||||
n += condRes.n;
|
n += condRes.n;
|
||||||
n += Parsing.skipEmpty(src, i + n);
|
n += Parsing.skipEmpty(src, i + n);
|
||||||
@ -92,7 +92,7 @@ public class IfStatement extends Statement {
|
|||||||
if (!src.is(i + n, ")")) return ParseRes.error(src.loc(i + n), "Expected a closing paren after if condition.");
|
if (!src.is(i + n, ")")) return ParseRes.error(src.loc(i + n), "Expected a closing paren after if condition.");
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
var res = ES5.parseStatement(src, i + n);
|
var res = JavaScript.parseStatement(src, i + n);
|
||||||
if (!res.isSuccess()) return res.chainError(src.loc(i + n), "Expected an if body.");
|
if (!res.isSuccess()) return res.chainError(src.loc(i + n), "Expected an if body.");
|
||||||
n += res.n;
|
n += res.n;
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ public class IfStatement extends Statement {
|
|||||||
if (!elseKw.isSuccess()) return ParseRes.res(new IfStatement(loc, condRes.result, res.result, null), n);
|
if (!elseKw.isSuccess()) return ParseRes.res(new IfStatement(loc, condRes.result, res.result, null), n);
|
||||||
n += elseKw.n;
|
n += elseKw.n;
|
||||||
|
|
||||||
var elseRes = ES5.parseStatement(src, i + n);
|
var elseRes = JavaScript.parseStatement(src, i + n);
|
||||||
if (!elseRes.isSuccess()) return elseRes.chainError(src.loc(i + n), "Expected an else body.");
|
if (!elseRes.isSuccess()) return elseRes.chainError(src.loc(i + n), "Expected an else body.");
|
||||||
n += elseRes.n;
|
n += elseRes.n;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import me.topchetoeu.jscript.common.parsing.ParseRes;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
|
|
||||||
public class ReturnStatement extends Statement {
|
public class ReturnStatement extends Statement {
|
||||||
@ -31,17 +31,17 @@ public class ReturnStatement extends Statement {
|
|||||||
if (!Parsing.isIdentifier(src, i + n, "return")) return ParseRes.failed();
|
if (!Parsing.isIdentifier(src, i + n, "return")) return ParseRes.failed();
|
||||||
n += 6;
|
n += 6;
|
||||||
|
|
||||||
var end = ES5.parseStatementEnd(src, i + n);
|
var end = JavaScript.parseStatementEnd(src, i + n);
|
||||||
if (end.isSuccess()) {
|
if (end.isSuccess()) {
|
||||||
n += end.n;
|
n += end.n;
|
||||||
return ParseRes.res(new ReturnStatement(loc, null), n);
|
return ParseRes.res(new ReturnStatement(loc, null), n);
|
||||||
}
|
}
|
||||||
|
|
||||||
var val = ES5.parseExpression(src, i + n, 0);
|
var val = JavaScript.parseExpression(src, i + n, 0);
|
||||||
if (val.isError()) return val.chainError();
|
if (val.isError()) return val.chainError();
|
||||||
n += val.n;
|
n += val.n;
|
||||||
|
|
||||||
end = ES5.parseStatementEnd(src, i + n);
|
end = JavaScript.parseStatementEnd(src, i + n);
|
||||||
if (end.isSuccess()) {
|
if (end.isSuccess()) {
|
||||||
n += end.n;
|
n += end.n;
|
||||||
return ParseRes.res(new ReturnStatement(loc, val.result), n);
|
return ParseRes.res(new ReturnStatement(loc, val.result), n);
|
||||||
|
@ -12,7 +12,7 @@ import me.topchetoeu.jscript.common.parsing.ParseRes;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
|
|
||||||
public class SwitchStatement extends Statement {
|
public class SwitchStatement extends Statement {
|
||||||
@ -90,7 +90,7 @@ public class SwitchStatement extends Statement {
|
|||||||
if (!Parsing.isIdentifier(src, i + n, "case")) return ParseRes.failed();
|
if (!Parsing.isIdentifier(src, i + n, "case")) return ParseRes.failed();
|
||||||
n += 4;
|
n += 4;
|
||||||
|
|
||||||
var valRes = ES5.parseExpression(src, i + n, 0);
|
var valRes = JavaScript.parseExpression(src, i + n, 0);
|
||||||
if (!valRes.isSuccess()) return valRes.chainError(src.loc(i + n), "Expected a value after 'case'");
|
if (!valRes.isSuccess()) return valRes.chainError(src.loc(i + n), "Expected a value after 'case'");
|
||||||
n += valRes.n;
|
n += valRes.n;
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ public class SwitchStatement extends Statement {
|
|||||||
if (!src.is(i + n, "(")) return ParseRes.error(src.loc(i + n), "Expected a open paren after 'switch'");
|
if (!src.is(i + n, "(")) return ParseRes.error(src.loc(i + n), "Expected a open paren after 'switch'");
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
var valRes = ES5.parseExpression(src, i + n, 0);
|
var valRes = JavaScript.parseExpression(src, i + n, 0);
|
||||||
if (!valRes.isSuccess()) return valRes.chainError(src.loc(i + n), "Expected a switch value");
|
if (!valRes.isSuccess()) return valRes.chainError(src.loc(i + n), "Expected a switch value");
|
||||||
n += valRes.n;
|
n += valRes.n;
|
||||||
n += Parsing.skipEmpty(src, i + n);
|
n += Parsing.skipEmpty(src, i + n);
|
||||||
@ -167,7 +167,7 @@ public class SwitchStatement extends Statement {
|
|||||||
}
|
}
|
||||||
if (caseRes.isError()) return caseRes.chainError();
|
if (caseRes.isError()) return caseRes.chainError();
|
||||||
|
|
||||||
var stm = ES5.parseStatement(src, i + n);
|
var stm = JavaScript.parseStatement(src, i + n);
|
||||||
if (stm.isSuccess()) {
|
if (stm.isSuccess()) {
|
||||||
n += stm.n;
|
n += stm.n;
|
||||||
statements.add(stm.result);
|
statements.add(stm.result);
|
||||||
|
@ -6,7 +6,7 @@ import me.topchetoeu.jscript.common.parsing.ParseRes;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
|
|
||||||
public class ThrowStatement extends Statement {
|
public class ThrowStatement extends Statement {
|
||||||
@ -30,17 +30,17 @@ public class ThrowStatement extends Statement {
|
|||||||
if (!Parsing.isIdentifier(src, i + n, "throw")) return ParseRes.failed();
|
if (!Parsing.isIdentifier(src, i + n, "throw")) return ParseRes.failed();
|
||||||
n += 5;
|
n += 5;
|
||||||
|
|
||||||
var end = ES5.parseStatementEnd(src, i + n);
|
var end = JavaScript.parseStatementEnd(src, i + n);
|
||||||
if (end.isSuccess()) {
|
if (end.isSuccess()) {
|
||||||
n += end.n;
|
n += end.n;
|
||||||
return ParseRes.res(new ThrowStatement(loc, null), n);
|
return ParseRes.res(new ThrowStatement(loc, null), n);
|
||||||
}
|
}
|
||||||
|
|
||||||
var val = ES5.parseExpression(src, i + n, 0);
|
var val = JavaScript.parseExpression(src, i + n, 0);
|
||||||
if (val.isFailed()) return ParseRes.error(src.loc(i + n), "Expected a value");
|
if (val.isFailed()) return ParseRes.error(src.loc(i + n), "Expected a value");
|
||||||
n += val.n;
|
n += val.n;
|
||||||
|
|
||||||
end = ES5.parseStatementEnd(src, i + n);
|
end = JavaScript.parseStatementEnd(src, i + n);
|
||||||
if (end.isSuccess()) {
|
if (end.isSuccess()) {
|
||||||
n += end.n;
|
n += end.n;
|
||||||
return ParseRes.res(new ThrowStatement(loc, val.result), n);
|
return ParseRes.res(new ThrowStatement(loc, val.result), n);
|
||||||
|
@ -8,7 +8,7 @@ import me.topchetoeu.jscript.common.parsing.ParseRes;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
|
|
||||||
public class WhileStatement extends Statement {
|
public class WhileStatement extends Statement {
|
||||||
@ -83,7 +83,7 @@ public class WhileStatement extends Statement {
|
|||||||
if (!src.is(i + n, "(")) return ParseRes.error(src.loc(i + n), "Expected a open paren after 'while'.");
|
if (!src.is(i + n, "(")) return ParseRes.error(src.loc(i + n), "Expected a open paren after 'while'.");
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
var condRes = ES5.parseExpression(src, i + n, 0);
|
var condRes = JavaScript.parseExpression(src, i + n, 0);
|
||||||
if (!condRes.isSuccess()) return condRes.chainError(src.loc(i + n), "Expected a while condition.");
|
if (!condRes.isSuccess()) return condRes.chainError(src.loc(i + n), "Expected a while condition.");
|
||||||
n += condRes.n;
|
n += condRes.n;
|
||||||
n += Parsing.skipEmpty(src, i + n);
|
n += Parsing.skipEmpty(src, i + n);
|
||||||
@ -91,7 +91,7 @@ public class WhileStatement extends Statement {
|
|||||||
if (!src.is(i + n, ")")) return ParseRes.error(src.loc(i + n), "Expected a closing paren after while condition.");
|
if (!src.is(i + n, ")")) return ParseRes.error(src.loc(i + n), "Expected a closing paren after while condition.");
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
var res = ES5.parseStatement(src, i + n);
|
var res = JavaScript.parseStatement(src, i + n);
|
||||||
if (!res.isSuccess()) return res.chainError(src.loc(i + n), "Expected a while body.");
|
if (!res.isSuccess()) return res.chainError(src.loc(i + n), "Expected a while body.");
|
||||||
n += res.n;
|
n += res.n;
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import me.topchetoeu.jscript.common.parsing.ParseRes;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
|
|
||||||
public class ArrayStatement extends Statement {
|
public class ArrayStatement extends Statement {
|
||||||
@ -70,7 +70,7 @@ public class ArrayStatement extends Statement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var res = ES5.parseExpression(src, i + n, 2);
|
var res = JavaScript.parseExpression(src, i + n, 2);
|
||||||
if (!res.isSuccess()) return res.chainError(src.loc(i + n), "Expected an array element.");
|
if (!res.isSuccess()) return res.chainError(src.loc(i + n), "Expected an array element.");
|
||||||
n += res.n;
|
n += res.n;
|
||||||
n += Parsing.skipEmpty(src, i + n);
|
n += Parsing.skipEmpty(src, i + n);
|
||||||
|
@ -9,7 +9,7 @@ import me.topchetoeu.jscript.common.parsing.Parsing;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.CompoundStatement;
|
import me.topchetoeu.jscript.compilation.CompoundStatement;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
import me.topchetoeu.jscript.runtime.exceptions.SyntaxException;
|
import me.topchetoeu.jscript.runtime.exceptions.SyntaxException;
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ public class FunctionStatement extends Statement {
|
|||||||
n += nameRes.n;
|
n += nameRes.n;
|
||||||
n += Parsing.skipEmpty(src, i + n);
|
n += Parsing.skipEmpty(src, i + n);
|
||||||
|
|
||||||
var args = ES5.parseParamList(src, i + n);
|
var args = JavaScript.parseParamList(src, i + n);
|
||||||
if (!args.isSuccess()) return args.chainError(src.loc(i + n), "Expected a parameter list");
|
if (!args.isSuccess()) return args.chainError(src.loc(i + n), "Expected a parameter list");
|
||||||
n += args.n;
|
n += args.n;
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import me.topchetoeu.jscript.common.parsing.Parsing;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.CompoundStatement;
|
import me.topchetoeu.jscript.compilation.CompoundStatement;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
|
|
||||||
public class ObjectStatement extends Statement {
|
public class ObjectStatement extends Statement {
|
||||||
@ -103,7 +103,7 @@ public class ObjectStatement extends Statement {
|
|||||||
if (!name.isSuccess()) return name.chainError(src.loc(i + n), "Expected a property name after '" + access + "'");
|
if (!name.isSuccess()) return name.chainError(src.loc(i + n), "Expected a property name after '" + access + "'");
|
||||||
n += name.n;
|
n += name.n;
|
||||||
|
|
||||||
var params = ES5.parseParamList(src, i + n);
|
var params = JavaScript.parseParamList(src, i + n);
|
||||||
if (!params.isSuccess()) return params.chainError(src.loc(i + n), "Expected an argument list");
|
if (!params.isSuccess()) return params.chainError(src.loc(i + n), "Expected an argument list");
|
||||||
n += params.n;
|
n += params.n;
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ public class ObjectStatement extends Statement {
|
|||||||
if (!src.is(i + n, ":")) return ParseRes.error(src.loc(i + n), "Expected a colon");
|
if (!src.is(i + n, ":")) return ParseRes.error(src.loc(i + n), "Expected a colon");
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
var valRes = ES5.parseExpression(src, i + n, 2);
|
var valRes = JavaScript.parseExpression(src, i + n, 2);
|
||||||
if (!valRes.isSuccess()) return valRes.chainError(src.loc(i + n), "Expected a value in array list");
|
if (!valRes.isSuccess()) return valRes.chainError(src.loc(i + n), "Expected a value in array list");
|
||||||
n += valRes.n;
|
n += valRes.n;
|
||||||
|
|
||||||
|
@ -8,11 +8,11 @@ import me.topchetoeu.jscript.common.parsing.Parsing;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.AssignableStatement;
|
import me.topchetoeu.jscript.compilation.AssignableStatement;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
import me.topchetoeu.jscript.compilation.values.operations.VariableAssignStatement;
|
import me.topchetoeu.jscript.compilation.values.operations.VariableAssignStatement;
|
||||||
|
|
||||||
public class VariableStatement extends AssignableStatement {
|
public class VariableStatement extends Statement implements AssignableStatement {
|
||||||
public final String name;
|
public final String name;
|
||||||
|
|
||||||
@Override public boolean pure() { return false; }
|
@Override public boolean pure() { return false; }
|
||||||
@ -42,7 +42,7 @@ public class VariableStatement extends AssignableStatement {
|
|||||||
if (!literal.isSuccess()) return literal.chainError();
|
if (!literal.isSuccess()) return literal.chainError();
|
||||||
n += literal.n;
|
n += literal.n;
|
||||||
|
|
||||||
if (!ES5.checkVarName(literal.result)) {
|
if (!JavaScript.checkVarName(literal.result)) {
|
||||||
if (literal.result.equals("await")) return ParseRes.error(src.loc(i + n), "'await' expressions are not supported.");
|
if (literal.result.equals("await")) return ParseRes.error(src.loc(i + n), "'await' expressions are not supported.");
|
||||||
if (literal.result.equals("const")) return ParseRes.error(src.loc(i + n), "'const' declarations are not supported.");
|
if (literal.result.equals("const")) return ParseRes.error(src.loc(i + n), "'const' declarations are not supported.");
|
||||||
if (literal.result.equals("let")) return ParseRes.error(src.loc(i + n), "'let' declarations are not supported.");
|
if (literal.result.equals("let")) return ParseRes.error(src.loc(i + n), "'let' declarations are not supported.");
|
||||||
|
@ -11,7 +11,7 @@ import me.topchetoeu.jscript.common.parsing.ParseRes;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
import me.topchetoeu.jscript.compilation.values.ArrayStatement;
|
import me.topchetoeu.jscript.compilation.values.ArrayStatement;
|
||||||
import me.topchetoeu.jscript.compilation.values.ObjectStatement;
|
import me.topchetoeu.jscript.compilation.values.ObjectStatement;
|
||||||
@ -136,7 +136,7 @@ public class CallStatement extends Statement {
|
|||||||
boolean prevArg = false;
|
boolean prevArg = false;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
var argRes = ES5.parseExpression(src, i + n, 2);
|
var argRes = JavaScript.parseExpression(src, i + n, 2);
|
||||||
n += argRes.n;
|
n += argRes.n;
|
||||||
n += Parsing.skipEmpty(src, i + n);
|
n += Parsing.skipEmpty(src, i + n);
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ public class CallStatement extends Statement {
|
|||||||
if (!Parsing.isIdentifier(src, i + n, "new")) return ParseRes.failed();
|
if (!Parsing.isIdentifier(src, i + n, "new")) return ParseRes.failed();
|
||||||
n += 3;
|
n += 3;
|
||||||
|
|
||||||
var valRes = ES5.parseExpression(src, i + n, 18);
|
var valRes = JavaScript.parseExpression(src, i + n, 18);
|
||||||
if (!valRes.isSuccess()) return valRes.chainError(src.loc(i + n), "Expected a value after 'new' keyword.");
|
if (!valRes.isSuccess()) return valRes.chainError(src.loc(i + n), "Expected a value after 'new' keyword.");
|
||||||
n += valRes.n;
|
n += valRes.n;
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import me.topchetoeu.jscript.common.parsing.Parsing;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.AssignableStatement;
|
import me.topchetoeu.jscript.compilation.AssignableStatement;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
import me.topchetoeu.jscript.compilation.values.constants.NumberStatement;
|
import me.topchetoeu.jscript.compilation.values.constants.NumberStatement;
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ public class ChangeStatement extends Statement {
|
|||||||
if (!src.is(i + n, "++")) return ParseRes.failed();
|
if (!src.is(i + n, "++")) return ParseRes.failed();
|
||||||
n += 2;
|
n += 2;
|
||||||
|
|
||||||
var res = ES5.parseExpression(src, i + n, 15);
|
var res = JavaScript.parseExpression(src, i + n, 15);
|
||||||
if (!res.isSuccess()) return res.chainError(src.loc(i + n), "Expected assignable value after prefix operator.");
|
if (!res.isSuccess()) return res.chainError(src.loc(i + n), "Expected assignable value after prefix operator.");
|
||||||
else if (!(res.result instanceof AssignableStatement)) return ParseRes.error(src.loc(i + n), "Expected assignable value after prefix operator.");
|
else if (!(res.result instanceof AssignableStatement)) return ParseRes.error(src.loc(i + n), "Expected assignable value after prefix operator.");
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ public class ChangeStatement extends Statement {
|
|||||||
if (!src.is(i + n, "--")) return ParseRes.failed();
|
if (!src.is(i + n, "--")) return ParseRes.failed();
|
||||||
n += 2;
|
n += 2;
|
||||||
|
|
||||||
var res = ES5.parseExpression(src, i + n, 15);
|
var res = JavaScript.parseExpression(src, i + n, 15);
|
||||||
if (!res.isSuccess()) return res.chainError(src.loc(i + n), "Expected assignable value after prefix operator.");
|
if (!res.isSuccess()) return res.chainError(src.loc(i + n), "Expected assignable value after prefix operator.");
|
||||||
else if (!(res.result instanceof AssignableStatement)) return ParseRes.error(src.loc(i + n), "Expected assignable value after prefix operator.");
|
else if (!(res.result instanceof AssignableStatement)) return ParseRes.error(src.loc(i + n), "Expected assignable value after prefix operator.");
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import me.topchetoeu.jscript.common.parsing.ParseRes;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
|
|
||||||
public class DiscardStatement extends Statement {
|
public class DiscardStatement extends Statement {
|
||||||
@ -31,7 +31,7 @@ public class DiscardStatement extends Statement {
|
|||||||
if (!Parsing.isIdentifier(src, i + n, "void")) return ParseRes.failed();
|
if (!Parsing.isIdentifier(src, i + n, "void")) return ParseRes.failed();
|
||||||
n += 4;
|
n += 4;
|
||||||
|
|
||||||
var valRes = ES5.parseExpression(src, i + n, 14);
|
var valRes = JavaScript.parseExpression(src, i + n, 14);
|
||||||
if (!valRes.isSuccess()) return valRes.chainError(src.loc(i + n), "Expected a value after 'void' keyword.");
|
if (!valRes.isSuccess()) return valRes.chainError(src.loc(i + n), "Expected a value after 'void' keyword.");
|
||||||
n += valRes.n;
|
n += valRes.n;
|
||||||
|
|
||||||
|
@ -9,11 +9,11 @@ import me.topchetoeu.jscript.common.parsing.Parsing;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.AssignableStatement;
|
import me.topchetoeu.jscript.compilation.AssignableStatement;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
import me.topchetoeu.jscript.compilation.values.constants.StringStatement;
|
import me.topchetoeu.jscript.compilation.values.constants.StringStatement;
|
||||||
|
|
||||||
public class IndexStatement extends AssignableStatement {
|
public class IndexStatement extends Statement implements AssignableStatement {
|
||||||
public final Statement object;
|
public final Statement object;
|
||||||
public final Statement index;
|
public final Statement index;
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ public class IndexStatement extends AssignableStatement {
|
|||||||
if (!src.is(i + n, "[")) return ParseRes.failed();
|
if (!src.is(i + n, "[")) return ParseRes.failed();
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
var valRes = ES5.parseExpression(src, i + n, 0);
|
var valRes = JavaScript.parseExpression(src, i + n, 0);
|
||||||
if (!valRes.isSuccess()) return valRes.chainError(src.loc(i + n), "Expected a value in index expression");
|
if (!valRes.isSuccess()) return valRes.chainError(src.loc(i + n), "Expected a value in index expression");
|
||||||
n += valRes.n;
|
n += valRes.n;
|
||||||
n += Parsing.skipEmpty(src, i + n);
|
n += Parsing.skipEmpty(src, i + n);
|
||||||
|
@ -6,7 +6,7 @@ import me.topchetoeu.jscript.common.parsing.ParseRes;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
|
|
||||||
public class LazyAndStatement extends Statement {
|
public class LazyAndStatement extends Statement {
|
||||||
@ -39,7 +39,7 @@ public class LazyAndStatement extends Statement {
|
|||||||
var loc = src.loc(i + n);
|
var loc = src.loc(i + n);
|
||||||
n += 2;
|
n += 2;
|
||||||
|
|
||||||
var res = ES5.parseExpression(src, i + n, 4);
|
var res = JavaScript.parseExpression(src, i + n, 4);
|
||||||
if (!res.isSuccess()) return res.chainError(src.loc(i + n), "Expected a value after the '&&' operator.");
|
if (!res.isSuccess()) return res.chainError(src.loc(i + n), "Expected a value after the '&&' operator.");
|
||||||
n += res.n;
|
n += res.n;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import me.topchetoeu.jscript.common.parsing.ParseRes;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
|
|
||||||
public class LazyOrStatement extends Statement {
|
public class LazyOrStatement extends Statement {
|
||||||
@ -39,7 +39,7 @@ public class LazyOrStatement extends Statement {
|
|||||||
var loc = src.loc(i + n);
|
var loc = src.loc(i + n);
|
||||||
n += 2;
|
n += 2;
|
||||||
|
|
||||||
var res = ES5.parseExpression(src, i + n, 4);
|
var res = JavaScript.parseExpression(src, i + n, 4);
|
||||||
if (!res.isSuccess()) return res.chainError(src.loc(i + n), "Expected a value after the '||' operator.");
|
if (!res.isSuccess()) return res.chainError(src.loc(i + n), "Expected a value after the '||' operator.");
|
||||||
n += res.n;
|
n += res.n;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import me.topchetoeu.jscript.common.parsing.Parsing;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.AssignableStatement;
|
import me.topchetoeu.jscript.compilation.AssignableStatement;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
|
|
||||||
public class OperationStatement extends Statement {
|
public class OperationStatement extends Statement {
|
||||||
@ -33,7 +33,7 @@ public class OperationStatement extends Statement {
|
|||||||
@Override public ParseRes<Statement> construct(Source src, int i, Statement prev) {
|
@Override public ParseRes<Statement> construct(Source src, int i, Statement prev) {
|
||||||
var loc = src.loc(i);
|
var loc = src.loc(i);
|
||||||
|
|
||||||
var other = ES5.parseExpression(src, i, precedence + 1);
|
var other = JavaScript.parseExpression(src, i, precedence + 1);
|
||||||
if (!other.isSuccess()) return other.chainError(src.loc(i + other.n), String.format("Expected a value after '%s'", token));
|
if (!other.isSuccess()) return other.chainError(src.loc(i + other.n), String.format("Expected a value after '%s'", token));
|
||||||
return ParseRes.res(new OperationStatement(loc, operation, prev, (Statement)other.result), other.n);
|
return ParseRes.res(new OperationStatement(loc, operation, prev, (Statement)other.result), other.n);
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ public class OperationStatement extends Statement {
|
|||||||
|
|
||||||
if (!(prev instanceof AssignableStatement)) return ParseRes.error(loc, String.format("Expected an assignable expression before '%s'", token));
|
if (!(prev instanceof AssignableStatement)) return ParseRes.error(loc, String.format("Expected an assignable expression before '%s'", token));
|
||||||
|
|
||||||
var other = ES5.parseExpression(src, i, precedence);
|
var other = JavaScript.parseExpression(src, i, precedence);
|
||||||
if (!other.isSuccess()) return other.chainError(src.loc(i + other.n), String.format("Expected a value after '%s'", token));
|
if (!other.isSuccess()) return other.chainError(src.loc(i + other.n), String.format("Expected a value after '%s'", token));
|
||||||
return ParseRes.res(((AssignableStatement)prev).toAssign(other.result, operation), other.n);
|
return ParseRes.res(((AssignableStatement)prev).toAssign(other.result, operation), other.n);
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ public class OperationStatement extends Statement {
|
|||||||
@Override public ParseRes<Statement> construct(Source src, int i, Statement prev) {
|
@Override public ParseRes<Statement> construct(Source src, int i, Statement prev) {
|
||||||
var loc = src.loc(i);
|
var loc = src.loc(i);
|
||||||
|
|
||||||
var other = ES5.parseExpression(src, i, 5);
|
var other = JavaScript.parseExpression(src, i, 5);
|
||||||
if (!other.isSuccess()) return other.chainError(src.loc(i + other.n), "Expected a value after '&&'");
|
if (!other.isSuccess()) return other.chainError(src.loc(i + other.n), "Expected a value after '&&'");
|
||||||
return ParseRes.res(new LazyAndStatement(loc, prev, (Statement)other.result), other.n);
|
return ParseRes.res(new LazyAndStatement(loc, prev, (Statement)other.result), other.n);
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ public class OperationStatement extends Statement {
|
|||||||
@Override public ParseRes<Statement> construct(Source src, int i, Statement prev) {
|
@Override public ParseRes<Statement> construct(Source src, int i, Statement prev) {
|
||||||
var loc = src.loc(i);
|
var loc = src.loc(i);
|
||||||
|
|
||||||
var other = ES5.parseExpression(src, i, 6);
|
var other = JavaScript.parseExpression(src, i, 6);
|
||||||
if (!other.isSuccess()) return other.chainError(src.loc(i + other.n), "Expected a value after '||'");
|
if (!other.isSuccess()) return other.chainError(src.loc(i + other.n), "Expected a value after '||'");
|
||||||
return ParseRes.res(new LazyOrStatement(loc, prev, (Statement)other.result), other.n);
|
return ParseRes.res(new LazyOrStatement(loc, prev, (Statement)other.result), other.n);
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ public class OperationStatement extends Statement {
|
|||||||
|
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
var res = ES5.parseExpression(src, i + n, 14);
|
var res = JavaScript.parseExpression(src, i + n, 14);
|
||||||
|
|
||||||
if (res.isSuccess()) return ParseRes.res(new OperationStatement(loc, operation, res.result), n + res.n);
|
if (res.isSuccess()) return ParseRes.res(new OperationStatement(loc, operation, res.result), n + res.n);
|
||||||
else return res.chainError(src.loc(i + n), String.format("Expected a value after the unary operator '%s'.", op));
|
else return res.chainError(src.loc(i + n), String.format("Expected a value after the unary operator '%s'.", op));
|
||||||
@ -186,7 +186,7 @@ public class OperationStatement extends Statement {
|
|||||||
if (!kw.isSuccess()) return kw.chainError();
|
if (!kw.isSuccess()) return kw.chainError();
|
||||||
n += kw.n;
|
n += kw.n;
|
||||||
|
|
||||||
var valRes = ES5.parseExpression(src, i + n, 10);
|
var valRes = JavaScript.parseExpression(src, i + n, 10);
|
||||||
if (!valRes.isSuccess()) return valRes.chainError(src.loc(i + n), "Expected a value after 'instanceof'.");
|
if (!valRes.isSuccess()) return valRes.chainError(src.loc(i + n), "Expected a value after 'instanceof'.");
|
||||||
n += valRes.n;
|
n += valRes.n;
|
||||||
|
|
||||||
@ -202,7 +202,7 @@ public class OperationStatement extends Statement {
|
|||||||
if (!kw.isSuccess()) return kw.chainError();
|
if (!kw.isSuccess()) return kw.chainError();
|
||||||
n += kw.n;
|
n += kw.n;
|
||||||
|
|
||||||
var valRes = ES5.parseExpression(src, i + n, 10);
|
var valRes = JavaScript.parseExpression(src, i + n, 10);
|
||||||
if (!valRes.isSuccess()) return valRes.chainError(src.loc(i + n), "Expected a value after 'in'.");
|
if (!valRes.isSuccess()) return valRes.chainError(src.loc(i + n), "Expected a value after 'in'.");
|
||||||
n += valRes.n;
|
n += valRes.n;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import me.topchetoeu.jscript.common.parsing.ParseRes;
|
|||||||
import me.topchetoeu.jscript.common.parsing.Parsing;
|
import me.topchetoeu.jscript.common.parsing.Parsing;
|
||||||
import me.topchetoeu.jscript.common.parsing.Source;
|
import me.topchetoeu.jscript.common.parsing.Source;
|
||||||
import me.topchetoeu.jscript.compilation.CompileResult;
|
import me.topchetoeu.jscript.compilation.CompileResult;
|
||||||
import me.topchetoeu.jscript.compilation.ES5;
|
import me.topchetoeu.jscript.compilation.JavaScript;
|
||||||
import me.topchetoeu.jscript.compilation.Statement;
|
import me.topchetoeu.jscript.compilation.Statement;
|
||||||
import me.topchetoeu.jscript.compilation.values.VariableStatement;
|
import me.topchetoeu.jscript.compilation.values.VariableStatement;
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ public class TypeofStatement extends Statement {
|
|||||||
if (!Parsing.isIdentifier(src, i + n, "typeof")) return ParseRes.failed();
|
if (!Parsing.isIdentifier(src, i + n, "typeof")) return ParseRes.failed();
|
||||||
n += 6;
|
n += 6;
|
||||||
|
|
||||||
var valRes = ES5.parseExpression(src, i + n, 15);
|
var valRes = JavaScript.parseExpression(src, i + n, 15);
|
||||||
if (!valRes.isSuccess()) return valRes.chainError(src.loc(i + n), "Expected a value after 'typeof' keyword.");
|
if (!valRes.isSuccess()) return valRes.chainError(src.loc(i + n), "Expected a value after 'typeof' keyword.");
|
||||||
n += valRes.n;
|
n += valRes.n;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user