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/fesm2020/mevento.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
function error(token) {
|
|
2
|
-
const text = `Invalid token ${token.type}[${token.value}] at ${token.line}, ${token.col}\n`;
|
|
1
|
+
function error(token, expected) {
|
|
2
|
+
const text = `Invalid token ${token.type}[${token.value}] at ${token.line}, ${token.col} ${expected ? `: expecting ${expected} token` : ''}\n`;
|
|
3
3
|
throw (text);
|
|
4
4
|
}
|
|
5
5
|
function isNum(value) {
|
|
@@ -236,8 +236,7 @@ class Lexer {
|
|
|
236
236
|
['\n', '\r', '\u2028', '\u2029'].includes(String.fromCharCode(c));
|
|
237
237
|
}
|
|
238
238
|
_isWhiteSpace(c) {
|
|
239
|
-
return String.fromCharCode(c)
|
|
240
|
-
String.fromCharCode(c).length > 0;
|
|
239
|
+
return [' ', '\t'].includes(String.fromCharCode(c));
|
|
241
240
|
}
|
|
242
241
|
_isDigit(c) {
|
|
243
242
|
// tslint:disable-next-line:no-bitwise
|
|
@@ -762,7 +761,7 @@ class Parser {
|
|
|
762
761
|
this.currentToken = this.lexer.nextToken();
|
|
763
762
|
}
|
|
764
763
|
else {
|
|
765
|
-
error(this.currentToken);
|
|
764
|
+
error(this.currentToken, type);
|
|
766
765
|
}
|
|
767
766
|
}
|
|
768
767
|
_eatEOL() {
|
|
@@ -975,6 +974,7 @@ class Parser {
|
|
|
975
974
|
const node = this._expression();
|
|
976
975
|
if (![TokenType.semi, TokenType.eol, TokenType.eof]
|
|
977
976
|
.includes(this.currentToken.type)) {
|
|
977
|
+
console.log('DDDMMMS', this.currentToken);
|
|
978
978
|
error(this.currentToken);
|
|
979
979
|
}
|
|
980
980
|
return node;
|
|
@@ -1245,10 +1245,15 @@ class NodeVisitor extends ANodeVisitor {
|
|
|
1245
1245
|
this.registerVisitor(ContinueAST, this.visitContinueAST);
|
|
1246
1246
|
}
|
|
1247
1247
|
visit(node) {
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1248
|
+
try {
|
|
1249
|
+
const methodName = `visit${node.constructor.name}`;
|
|
1250
|
+
// const fn = Object.getPrototypeOf(this)[methodName];
|
|
1251
|
+
const fn = this._nodesVisitors[methodName];
|
|
1252
|
+
return fn?.call(this, node);
|
|
1253
|
+
}
|
|
1254
|
+
catch (error) {
|
|
1255
|
+
return null;
|
|
1256
|
+
}
|
|
1252
1257
|
}
|
|
1253
1258
|
assignProperty(owner, property, value) {
|
|
1254
1259
|
if (Array.isArray(owner)) {
|
|
@@ -1489,6 +1494,9 @@ class MEvento extends NodeVisitor {
|
|
|
1489
1494
|
visitIndexAccessorAST(node) {
|
|
1490
1495
|
const ownerNode = node.owner;
|
|
1491
1496
|
const owner = this.visit(ownerNode);
|
|
1497
|
+
if (owner === null || owner === undefined) {
|
|
1498
|
+
return null;
|
|
1499
|
+
}
|
|
1492
1500
|
if (typeof owner === 'object') {
|
|
1493
1501
|
const key = this.visit(node.key);
|
|
1494
1502
|
return owner[key];
|
|
@@ -1853,6 +1861,9 @@ class MEventoAsync extends MEvento {
|
|
|
1853
1861
|
async visitIndexAccessorAST(node) {
|
|
1854
1862
|
const ownerNode = node.owner;
|
|
1855
1863
|
const owner = await this.visit(ownerNode);
|
|
1864
|
+
if (owner === null || owner === undefined) {
|
|
1865
|
+
return null;
|
|
1866
|
+
}
|
|
1856
1867
|
if (typeof owner === 'object') {
|
|
1857
1868
|
const key = await this.visit(node.key);
|
|
1858
1869
|
return owner[key];
|