mevento 1.9.4 → 1.9.5

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.
@@ -464,7 +464,7 @@ class Lexer {
464
464
  if (this._currentChar === Chars.pipe && this._pick() === Chars.pipe) {
465
465
  this._advance();
466
466
  this._advance();
467
- return new Token(TokenType.and, '||', lastL, lastC);
467
+ return new Token(TokenType.or, '||', lastL, lastC);
468
468
  }
469
469
  if (this._currentChar === Chars.quote || this._currentChar === Chars.squote) {
470
470
  const startChar = this._currentChar;
@@ -800,7 +800,7 @@ class Parser {
800
800
  case TokenType.minus:
801
801
  case TokenType.not:
802
802
  this._eat(this.currentToken.type);
803
- return new UnaryExpressionAST(token, this._factor());
803
+ return new UnaryExpressionAST(token, this._expression());
804
804
  case TokenType.numberConst:
805
805
  this._eat(TokenType.numberConst);
806
806
  return new LiteralAST(token, token.value.toString());
@@ -898,6 +898,9 @@ class Parser {
898
898
  while (((_b = this.currentToken) === null || _b === void 0 ? void 0 : _b.type) === TokenType.comma) {
899
899
  this._eat(TokenType.comma);
900
900
  this._eatEOL();
901
+ if (this._expect(TokenType.rbrace)) {
902
+ break;
903
+ }
901
904
  properties.push(this._property());
902
905
  this._eatEOL();
903
906
  }
@@ -956,6 +959,10 @@ class Parser {
956
959
  const result = [expr];
957
960
  while (((_a = this.currentToken) === null || _a === void 0 ? void 0 : _a.type) === TokenType.comma) {
958
961
  this._eat(TokenType.comma);
962
+ this._eatEOL();
963
+ if (this._expect(TokenType.rbracket)) {
964
+ break;
965
+ }
959
966
  expr = this._expression();
960
967
  result.push(expr);
961
968
  }
@@ -985,7 +992,6 @@ class Parser {
985
992
  const node = this._expression();
986
993
  if (![TokenType.semi, TokenType.eol, TokenType.eof]
987
994
  .includes(this.currentToken.type)) {
988
- console.log('DDDMMMS', this.currentToken);
989
995
  error(this.currentToken);
990
996
  }
991
997
  return node;
@@ -1230,7 +1236,6 @@ class ANodeVisitor {
1230
1236
  }
1231
1237
  registerVisitor(type, visitor) {
1232
1238
  const methodName = `visit${type.name}`;
1233
- // console.log('Reg::::::', methodName, type);
1234
1239
  this._nodesVisitors[methodName] = visitor;
1235
1240
  }
1236
1241
  }
@@ -1259,11 +1264,12 @@ class NodeVisitor extends ANodeVisitor {
1259
1264
  this.registerVisitor(ContinueAST, this.visitContinueAST);
1260
1265
  }
1261
1266
  visit(node) {
1267
+ var _a;
1262
1268
  try {
1263
1269
  const methodName = `visit${node.constructor.name}`;
1264
1270
  // const fn = Object.getPrototypeOf(this)[methodName];
1265
1271
  const fn = this._nodesVisitors[methodName];
1266
- return fn === null || fn === void 0 ? void 0 : fn.call(this, node);
1272
+ return (_a = fn === null || fn === void 0 ? void 0 : fn.call(this, node)) !== null && _a !== void 0 ? _a : null;
1267
1273
  }
1268
1274
  catch (error) {
1269
1275
  return null;
@@ -1500,13 +1506,20 @@ class MEvento extends NodeVisitor {
1500
1506
  }
1501
1507
  visitLogicalExpressionAST(node) {
1502
1508
  const leftNode = node.left;
1503
- const test = this.visit(leftNode);
1509
+ let test = this.visit(leftNode);
1504
1510
  const testBoolValue = _boolValue(test);
1505
1511
  if (node.operator.type === TokenType.and) {
1506
- return testBoolValue && _boolValue(this.visit(node.right));
1512
+ if (!testBoolValue) {
1513
+ return false;
1514
+ }
1515
+ return _boolValue(this.visit(node.right));
1507
1516
  }
1508
1517
  if (node.operator.type === TokenType.or) {
1509
- return testBoolValue || _boolValue(this.visit(node.right));
1518
+ if (testBoolValue) {
1519
+ return test;
1520
+ }
1521
+ test = this.visit(node.right);
1522
+ return test;
1510
1523
  }
1511
1524
  return false;
1512
1525
  }
@@ -1587,7 +1600,6 @@ class MEvento extends NodeVisitor {
1587
1600
  if (!isNum(tmp))
1588
1601
  throw Error("Cant update value");
1589
1602
  this.changeVariable(loopIdentifier.value, node.direction.type === TokenType.up ? tmp + updateValue : tmp - updateValue);
1590
- // console.log('Update loop from ' + tmp + ' to ' + this.resolve(loopIdentifier.value))
1591
1603
  }
1592
1604
  else {
1593
1605
  throw Error("Update value cant be non number");
@@ -1888,13 +1900,20 @@ class MEventoAsync extends MEvento {
1888
1900
  visitLogicalExpressionAST(node) {
1889
1901
  return __awaiter(this, void 0, void 0, function* () {
1890
1902
  const leftNode = node.left;
1891
- const test = yield this.visit(leftNode);
1903
+ let test = yield this.visit(leftNode);
1892
1904
  const testBoolValue = _boolValue(test);
1893
1905
  if (node.operator.type === TokenType.and) {
1894
- return testBoolValue && _boolValue(yield this.visit(node.right));
1906
+ if (!testBoolValue) {
1907
+ return false;
1908
+ }
1909
+ return _boolValue(yield this.visit(node.right));
1895
1910
  }
1896
1911
  if (node.operator.type === TokenType.or) {
1897
- return testBoolValue || _boolValue(yield this.visit(node.right));
1912
+ if (testBoolValue) {
1913
+ return test;
1914
+ }
1915
+ test = yield this.visit(node.right);
1916
+ return test;
1898
1917
  }
1899
1918
  return false;
1900
1919
  });