UNPKG

jql-parser

Version:
69 lines (68 loc) 2.27 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 (Object.prototype.hasOwnProperty.call(b, 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 __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.Operand = void 0; var List_1 = require("./List"); var Parenthesis_1 = require("./Parenthesis"); var Quote_1 = require("./Quote"); var Token_1 = require("./Token"); var Value_1 = require("./Value"); /** * operand :== quote | string | paren{list} */ var Operand = /** @class */ (function (_super) { __extends(Operand, _super); function Operand() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.spaces = 0; return _this; } Object.defineProperty(Operand.prototype, "end", { get: function () { var end = this.spaces; if (this.paren && this.paren.end > 0) { return end + this.paren.end; } return end + this.value.end; }, enumerable: false, configurable: true }); Operand.prototype.parse = function (input) { var str = input; if (input[0] === " ") { this.spaces = 1; str = input.substr(1); } var q = new Quote_1.Quote(); if (q.parse(str)) { this.value = q; return true; } var value = new Value_1.Value(); if (value.parse(str)) { this.value = value; return true; } this.paren = new Parenthesis_1.Parenthesis(); if (this.paren.parse(str)) { this.value = new List_1.List(); return this.value.parse(this.paren.content); } return false; }; return Operand; }(Token_1.Token)); exports.Operand = Operand;