mevento 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/mevento.mjs +55 -62
- package/fesm2015/mevento.mjs +29 -38
- package/fesm2015/mevento.mjs.map +1 -1
- package/fesm2020/mevento.mjs +29 -36
- package/fesm2020/mevento.mjs.map +1 -1
- package/lib/mevento.d.ts +116 -22
- package/package.json +1 -1
package/fesm2015/mevento.mjs
CHANGED
|
@@ -883,7 +883,7 @@ class Parser {
|
|
|
883
883
|
if (((_a = this.currentToken) === null || _a === void 0 ? void 0 : _a.type) != TokenType.rbrace) {
|
|
884
884
|
properties.push(this._property());
|
|
885
885
|
}
|
|
886
|
-
while (((_b = this.currentToken) === null || _b === void 0 ? void 0 : _b.type)
|
|
886
|
+
while (((_b = this.currentToken) === null || _b === void 0 ? void 0 : _b.type) === TokenType.comma) {
|
|
887
887
|
this._eat(TokenType.comma);
|
|
888
888
|
properties.push(this._property());
|
|
889
889
|
}
|
|
@@ -1007,8 +1007,7 @@ class Parser {
|
|
|
1007
1007
|
// endBlock
|
|
1008
1008
|
this._eat(TokenType.rbrace);
|
|
1009
1009
|
}
|
|
1010
|
-
|
|
1011
|
-
return ret;
|
|
1010
|
+
return new BlockStatementAST(body, this.currentToken);
|
|
1012
1011
|
}
|
|
1013
1012
|
_ifStatement() {
|
|
1014
1013
|
this._eat(TokenType.IF);
|
|
@@ -1048,7 +1047,7 @@ class Parser {
|
|
|
1048
1047
|
const token = this.currentToken;
|
|
1049
1048
|
this._eat(TokenType.WHILE_TILL);
|
|
1050
1049
|
const test = this._expression();
|
|
1051
|
-
const body = this.currentToken.type
|
|
1050
|
+
const body = this.currentToken.type === TokenType.lbrace ? this._blockStatement() : this._expression();
|
|
1052
1051
|
return new WhileLoopStatement(test, body, token, this.currentToken);
|
|
1053
1052
|
}
|
|
1054
1053
|
_forOfIdentifier() {
|
|
@@ -1113,13 +1112,13 @@ class Parser {
|
|
|
1113
1112
|
else {
|
|
1114
1113
|
update = new LiteralAST(new Token(TokenType.numberConst, 1, this.currentToken.line, this.currentToken.col), "1");
|
|
1115
1114
|
}
|
|
1116
|
-
const body = (this.currentToken.type
|
|
1115
|
+
const body = (this.currentToken.type === TokenType.lbrace) ? this._blockStatement() : this._expression();
|
|
1117
1116
|
node = new ForLoopStatement(node, test, update, direction, body, startToken, this.currentToken);
|
|
1118
1117
|
}
|
|
1119
1118
|
else if (forOf) {
|
|
1120
1119
|
this._eat(TokenType.in);
|
|
1121
1120
|
const collection = this._expression();
|
|
1122
|
-
const body = (this.currentToken.type
|
|
1121
|
+
const body = (this.currentToken.type === TokenType.lbrace) ? this._blockStatement() : this._expression();
|
|
1123
1122
|
node = new ForOfStatement(node, collection, body, startToken, this.currentToken);
|
|
1124
1123
|
}
|
|
1125
1124
|
else {
|
|
@@ -1210,31 +1209,9 @@ class ANodeVisitor {
|
|
|
1210
1209
|
this._nodesVisitors[methodName] = visitor;
|
|
1211
1210
|
}
|
|
1212
1211
|
}
|
|
1213
|
-
class AsyncNodeVisitor extends ANodeVisitor {
|
|
1214
|
-
visit(node) {
|
|
1215
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1216
|
-
const methodName = `visit${node.constructor.name}`;
|
|
1217
|
-
// const fn = Object.getPrototypeOf(this)[methodName];
|
|
1218
|
-
const fn = this._nodesVisitors[methodName];
|
|
1219
|
-
return yield (fn === null || fn === void 0 ? void 0 : fn.call(this, node));
|
|
1220
|
-
});
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
1212
|
class NodeVisitor extends ANodeVisitor {
|
|
1224
|
-
visit(node) {
|
|
1225
|
-
// console.log('node::', node);
|
|
1226
|
-
const methodName = `visit${node.constructor.name}`;
|
|
1227
|
-
// const fn = Object.getPrototypeOf(this)[methodName];
|
|
1228
|
-
const fn = this._nodesVisitors[methodName];
|
|
1229
|
-
return fn === null || fn === void 0 ? void 0 : fn.call(this, node);
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
class MEvento extends NodeVisitor {
|
|
1233
1213
|
constructor() {
|
|
1234
1214
|
super();
|
|
1235
|
-
this._memory = {};
|
|
1236
|
-
this.debug = false;
|
|
1237
|
-
this._functionsRegistry = {};
|
|
1238
1215
|
this.registerVisitor(RootAST, this.visitRootAST);
|
|
1239
1216
|
this.registerVisitor(BlockStatementAST, this.visitBlockStatementAST);
|
|
1240
1217
|
this.registerVisitor(IdentifierAST, this.visitIdentifierAST);
|
|
@@ -1254,6 +1231,29 @@ class MEvento extends NodeVisitor {
|
|
|
1254
1231
|
this.registerVisitor(ForLoopStatement, this.visitForLoopStatement);
|
|
1255
1232
|
this.registerVisitor(ForOfStatement, this.visitForOfStatement);
|
|
1256
1233
|
this.registerVisitor(BreakAST, this.visitBreakAST);
|
|
1234
|
+
}
|
|
1235
|
+
visit(node) {
|
|
1236
|
+
const methodName = `visit${node.constructor.name}`;
|
|
1237
|
+
// const fn = Object.getPrototypeOf(this)[methodName];
|
|
1238
|
+
const fn = this._nodesVisitors[methodName];
|
|
1239
|
+
return fn === null || fn === void 0 ? void 0 : fn.call(this, node);
|
|
1240
|
+
}
|
|
1241
|
+
assignProperty(owner, property, value) {
|
|
1242
|
+
if (Array.isArray(owner)) {
|
|
1243
|
+
owner[property] = value;
|
|
1244
|
+
}
|
|
1245
|
+
else if (typeof owner === 'object') {
|
|
1246
|
+
owner[property] = value;
|
|
1247
|
+
}
|
|
1248
|
+
else { }
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
class MEvento extends NodeVisitor {
|
|
1252
|
+
constructor() {
|
|
1253
|
+
super();
|
|
1254
|
+
this._memory = {};
|
|
1255
|
+
this.debug = false;
|
|
1256
|
+
this._functionsRegistry = {};
|
|
1257
1257
|
this._functionsRegistry = Object.assign({}, MEvento._globalFunctionsRegistry);
|
|
1258
1258
|
}
|
|
1259
1259
|
log(message) {
|
|
@@ -1301,15 +1301,6 @@ class MEvento extends NodeVisitor {
|
|
|
1301
1301
|
}
|
|
1302
1302
|
return value;
|
|
1303
1303
|
}
|
|
1304
|
-
assignProperty(owner, property, value) {
|
|
1305
|
-
if (Array.isArray(owner)) {
|
|
1306
|
-
owner[property] = value;
|
|
1307
|
-
}
|
|
1308
|
-
else if (typeof owner === 'object') {
|
|
1309
|
-
owner[property] = value;
|
|
1310
|
-
}
|
|
1311
|
-
else { }
|
|
1312
|
-
}
|
|
1313
1304
|
visitExpressionStatementAST(node) {
|
|
1314
1305
|
const expr = node.expression;
|
|
1315
1306
|
return this.visit(expr);
|
|
@@ -1946,5 +1937,5 @@ class MEventoAsync extends MEvento {
|
|
|
1946
1937
|
* Generated bundle index. Do not edit.
|
|
1947
1938
|
*/
|
|
1948
1939
|
|
|
1949
|
-
export { MEvento, MEventoAsync };
|
|
1940
|
+
export { AST, ArrayExpression, AssignmentExpressionAST, BinaryExpressionAST, BlockStatementAST, BreakAST, BreakBranch, CallExpressionAST, ExpressionStatementAST, ForLoopStatement, ForOfStatement, IdentifierAST, IfStatementAST, IndexAccessorAST, LexerDictionary, LiteralAST, LogicalExpressionAST, MEvento, MEventoAsync, NodeVisitor, ObjectExpression, ObjectProperty, RootAST, Token, TokenType, TupleExpression, UnaryExpressionAST, WhileLoopStatement };
|
|
1950
1941
|
//# sourceMappingURL=mevento.mjs.map
|