UNPKG

@drewsonne/maya-calculator-parser

Version:

Typescript package to parse plaintext calculations and create operators

50 lines 2.42 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var base_1 = require("../base"); var long_count_token_1 = __importDefault(require("../layer-1/long-count-token")); var calendar_round_token_1 = __importDefault(require("../layer-1/calendar-round-token")); var calendar_round_operation_token_1 = __importDefault(require("./calendar-round-operation-token")); var long_count_operation_token_1 = __importDefault(require("./long-count-operation-token")); var OperationToken = (function (_super) { __extends(OperationToken, _super); function OperationToken() { return _super !== null && _super.apply(this, arguments) || this; } OperationToken.prototype.equal = function (otherToken) { debugger; return false; }; OperationToken.parse = function (tokens) { if (tokens.length === 3) { var firstOperand = tokens[0]; var operator = tokens[1]; var secondOperand = tokens[2]; if ((firstOperand instanceof calendar_round_token_1.default) && (secondOperand instanceof calendar_round_token_1.default)) { return calendar_round_operation_token_1.default.parse([firstOperand, operator, secondOperand]); } if ((firstOperand instanceof long_count_token_1.default) && (secondOperand instanceof long_count_token_1.default)) { return long_count_operation_token_1.default.parse([firstOperand, operator, secondOperand]); } } throw new Error("Could not parse: '" + tokens + "'"); }; return OperationToken; }(base_1.Token)); exports.default = OperationToken; //# sourceMappingURL=operation-token.js.map