mevento 1.9.1 → 1.9.4
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 +21 -10
- package/fesm2015/mevento.mjs +20 -9
- package/fesm2015/mevento.mjs.map +1 -1
- package/fesm2020/mevento.mjs +20 -9
- package/fesm2020/mevento.mjs.map +1 -1
- package/package.json +1 -1
package/fesm2015/mevento.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
2
|
|
|
3
|
-
function error(token) {
|
|
4
|
-
const text = `Invalid token ${token.type}[${token.value}] at ${token.line}, ${token.col}\n`;
|
|
3
|
+
function error(token, expected) {
|
|
4
|
+
const text = `Invalid token ${token.type}[${token.value}] at ${token.line}, ${token.col} ${expected ? `: expecting ${expected} token` : ''}\n`;
|
|
5
5
|
throw (text);
|
|
6
6
|
}
|
|
7
7
|
function isNum(value) {
|
|
@@ -240,8 +240,7 @@ class Lexer {
|
|
|
240
240
|
['\n', '\r', '\u2028', '\u2029'].includes(String.fromCharCode(c));
|
|
241
241
|
}
|
|
242
242
|
_isWhiteSpace(c) {
|
|
243
|
-
return String.fromCharCode(c)
|
|
244
|
-
String.fromCharCode(c).length > 0;
|
|
243
|
+
return [' ', '\t'].includes(String.fromCharCode(c));
|
|
245
244
|
}
|
|
246
245
|
_isDigit(c) {
|
|
247
246
|
// tslint:disable-next-line:no-bitwise
|
|
@@ -767,7 +766,7 @@ class Parser {
|
|
|
767
766
|
this.currentToken = this.lexer.nextToken();
|
|
768
767
|
}
|
|
769
768
|
else {
|
|
770
|
-
error(this.currentToken);
|
|
769
|
+
error(this.currentToken, type);
|
|
771
770
|
}
|
|
772
771
|
}
|
|
773
772
|
_eatEOL() {
|
|
@@ -986,6 +985,7 @@ class Parser {
|
|
|
986
985
|
const node = this._expression();
|
|
987
986
|
if (![TokenType.semi, TokenType.eol, TokenType.eof]
|
|
988
987
|
.includes(this.currentToken.type)) {
|
|
988
|
+
console.log('DDDMMMS', this.currentToken);
|
|
989
989
|
error(this.currentToken);
|
|
990
990
|
}
|
|
991
991
|
return node;
|
|
@@ -1259,10 +1259,15 @@ class NodeVisitor extends ANodeVisitor {
|
|
|
1259
1259
|
this.registerVisitor(ContinueAST, this.visitContinueAST);
|
|
1260
1260
|
}
|
|
1261
1261
|
visit(node) {
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1262
|
+
try {
|
|
1263
|
+
const methodName = `visit${node.constructor.name}`;
|
|
1264
|
+
// const fn = Object.getPrototypeOf(this)[methodName];
|
|
1265
|
+
const fn = this._nodesVisitors[methodName];
|
|
1266
|
+
return fn === null || fn === void 0 ? void 0 : fn.call(this, node);
|
|
1267
|
+
}
|
|
1268
|
+
catch (error) {
|
|
1269
|
+
return null;
|
|
1270
|
+
}
|
|
1266
1271
|
}
|
|
1267
1272
|
assignProperty(owner, property, value) {
|
|
1268
1273
|
if (Array.isArray(owner)) {
|
|
@@ -1508,6 +1513,9 @@ class MEvento extends NodeVisitor {
|
|
|
1508
1513
|
visitIndexAccessorAST(node) {
|
|
1509
1514
|
const ownerNode = node.owner;
|
|
1510
1515
|
const owner = this.visit(ownerNode);
|
|
1516
|
+
if (owner === null || owner === undefined) {
|
|
1517
|
+
return null;
|
|
1518
|
+
}
|
|
1511
1519
|
if (typeof owner === 'object') {
|
|
1512
1520
|
const key = this.visit(node.key);
|
|
1513
1521
|
return owner[key];
|
|
@@ -1895,6 +1903,9 @@ class MEventoAsync extends MEvento {
|
|
|
1895
1903
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1896
1904
|
const ownerNode = node.owner;
|
|
1897
1905
|
const owner = yield this.visit(ownerNode);
|
|
1906
|
+
if (owner === null || owner === undefined) {
|
|
1907
|
+
return null;
|
|
1908
|
+
}
|
|
1898
1909
|
if (typeof owner === 'object') {
|
|
1899
1910
|
const key = yield this.visit(node.key);
|
|
1900
1911
|
return owner[key];
|