igniteui-react-core
Version:
Ignite UI React Core.
864 lines (863 loc) • 30.1 kB
JavaScript
/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { __extends } from "tslib";
import { Base, markType } from "./type";
import { List$1 } from "./List$1";
import { FilterSyntaxToken } from "./FilterSyntaxToken";
import { InvalidOperationException } from "./InvalidOperationException";
import { CultureInfo } from "./culture";
import { truncate } from "./number";
import { dateParse, dateParseExact } from "./dateExtended";
import { stringContains } from "./string";
import { parseNumber1 } from "./numberExtended";
import { isLetterOrDigit, isLetter } from "./stringExtended";
/**
* @hidden
*/
var FilterSyntaxLexer = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(FilterSyntaxLexer, _super);
function FilterSyntaxLexer() {
return _super.call(this) || this;
}
FilterSyntaxLexer.prototype.e = function (a) {
var b = 0;
var c = a.length;
var d = new List$1(FilterSyntaxToken.$, 0);
while (b < c) {
b = this.f(d, b, c, a);
}
return d;
};
FilterSyntaxLexer.prototype.f = function (a, b, c, d) {
while (b < c && this.d(d.charAt(b))) {
b++;
}
if (b > (c - 1)) {
return b;
}
var e = d.charAt(b);
if (e == '{') {
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 14;
return $ret;
})()));
return b + 1;
}
if (e == '}') {
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 15;
return $ret;
})()));
return b + 1;
}
if (e == '(') {
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 10;
return $ret;
})()));
return b + 1;
}
if (e == ')') {
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 11;
return $ret;
})()));
return b + 1;
}
if (e == '[') {
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 12;
return $ret;
})()));
return b + 1;
}
if (e == ']') {
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 13;
return $ret;
})()));
return b + 1;
}
if (e == ':') {
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 18;
return $ret;
})()));
return b + 1;
}
if (e == ',') {
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 6;
return $ret;
})()));
return b + 1;
}
if (e == '.') {
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 17;
return $ret;
})()));
return b + 1;
}
if (e == '\'') {
var f_1 = "";
var g = b;
var h = false;
for (g = b + 1; g < c; g++) {
if (d.charAt(g) == '\\') {
if (g + 1 < c && d.charAt(g + 1) == '\'') {
g++;
}
else {
}
}
else if (d.charAt(g) == '\'' && g + 1 < c && d.charAt(g + 1) == '\'') {
g++;
}
else if (d.charAt(g) == '\'') {
h = true;
break;
}
else {
}
}
if (!h) {
throw new InvalidOperationException(1, "missing end quote for string starting at position: " + b);
}
else {
f_1 = d.substr(b + 1, (g - 1) - b);
b = g + 1;
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 2;
$ret.b = f_1;
return $ret;
})()));
}
return b;
}
if ((e == 't' || e == 'T') && (b + ("true").length) < c && d.substr(b, ("true").length).toLowerCase() == "true") {
b += ("true").length;
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 72;
$ret.b = true;
return $ret;
})()));
return b;
}
if ((e == 'f' || e == 'F') && (b + ("false").length) < c && d.substr(b, ("false").length).toLowerCase() == "false") {
b += ("false").length;
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 73;
$ret.b = false;
return $ret;
})()));
return b;
}
if ((e == 'n' || e == 'N') && (b + ("null").length) < c && d.substr(b, ("null").length).toLowerCase() == "null") {
b += ("null").length;
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 71;
return $ret;
})()));
return b;
}
if ((e == '-' && (b + 1 < c) && this.c(d.charAt(b + 1))) || this.c(e)) {
var i = this.h(e, b, c, d);
var j = this.g(e, b, c, d);
var k = this.i(e, b, c, d);
if (i >= 0) {
var l = d.substr(b, (i - b) + 1);
var m_1 = dateParse(l, CultureInfo.invariantCulture);
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 3;
$ret.b = m_1;
return $ret;
})()));
return i + 1;
}
else if (j >= 0) {
var n = d.substr(b, (j - b) + 1);
var o_1 = dateParse(n);
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 3;
$ret.b = o_1;
return $ret;
})()));
return j + 1;
}
else if (k >= 0) {
var p = d.substr(b, (j - b) + 1);
var q_1 = dateParseExact(p, "hh:mm:ss.FFFFFFFFFFFF", CultureInfo.invariantCulture);
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 5;
$ret.b = q_1;
return $ret;
})()));
return k + 1;
}
else {
var r = b;
var s = true;
var t = false;
var u = false;
var v_1 = "";
var w = false;
if (e == '-') {
v_1 += e;
r++;
}
while (r < c) {
var x = d.charAt(r);
if (u) {
if (x == '-') {
v_1 += x;
r++;
}
if (x == '+') {
v_1 += x;
r++;
}
if (r < c) {
x = d.charAt(r);
}
if (!this.c(x)) {
w = true;
break;
}
else {
v_1 += x;
r++;
}
}
else if (t) {
if (x == 'e' || x == 'E') {
v_1 += x;
r++;
u = true;
continue;
}
if (!this.c(x)) {
w = true;
break;
}
else {
v_1 += x;
r++;
}
}
else if (s) {
if (x == '.') {
v_1 += x;
r++;
t = true;
continue;
}
if (x == 'e' || x == 'E') {
v_1 += x;
r++;
u = true;
continue;
}
if (!this.c(x)) {
w = true;
break;
}
else {
v_1 += x;
r++;
}
}
}
if (r >= c - 1) {
w = true;
}
if (!w) {
if (v_1.charAt(v_1.length - 1) == 'E' || v_1.charAt(v_1.length - 1) == 'e' || v_1.charAt(v_1.length - 1) == '.') {
throw new InvalidOperationException(1, "expected end of number starting at: " + b);
}
}
else {
b = r;
if (stringContains(v_1, ".") || stringContains(v_1, "E") || stringContains(v_1, "e")) {
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 1;
$ret.b = parseNumber1(v_1, 167);
return $ret;
})()));
}
else {
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 0;
$ret.b = truncate(parseNumber1(v_1, 7));
return $ret;
})()));
}
}
return b;
}
}
if (this.a(e)) {
var y = "";
var z = b;
var aa = false;
for (z = b; z < c; z++) {
if (d.charAt(z) == '\r' || d.charAt(z) == '\n') {
aa = true;
break;
}
if (this.d(d.charAt(z))) {
aa = true;
break;
}
if (d.charAt(z) == ':') {
aa = true;
break;
}
if (!this.b(d.charAt(z))) {
aa = true;
break;
}
else {
y += d.charAt(z);
}
}
if (z >= c - 1) {
aa = true;
}
if (!aa) {
throw new InvalidOperationException(1, "invalidly formed identifier starting at position: " + b);
}
else {
b = z;
this.k(a, y);
}
return b;
}
throw new InvalidOperationException(1, "unexpected character: " + e + " at position: " + b);
};
FilterSyntaxLexer.prototype.i = function (a, b, c, d) {
if (this.c(a) && (b + 1) < c && this.c(d.charAt(b + 1)) && (b + 2) < c && (d.charAt(b + 2) == ':') && (b + 3) < c && this.c(d.charAt(b + 3)) && (b + 4) < c && this.c(d.charAt(b + 4))) {
if ((b + 5) < c && (d.charAt(b + 5) == ':')) {
if ((b + 6) < c && this.c(d.charAt(b + 6)) && (b + 7) < c && this.c(d.charAt(b + 7))) {
if ((b + 8) < c && (d.charAt(b + 8) == '.')) {
if ((b + 9) < c && this.c(d.charAt(b + 9))) {
var e = 0;
while (e < 12) {
var f = b + 9 + e;
if (f >= c) {
break;
}
if (!this.c(d.charAt(f))) {
break;
}
e++;
}
if (e > 12) {
return -1;
}
return b + 9 + (e - 1);
}
}
else {
return b + 7;
}
}
}
else {
return b + 4;
}
}
return -1;
};
FilterSyntaxLexer.prototype.h = function (a, b, c, d) {
if (this.g(a, b, c, d) >= 0) {
if ((b + 10) < c && (d.charAt(b + 10) == 'T')) {
if (b + 11 < c) {
var e = this.i(d.charAt(b + 11), b + 11, c, d);
if (e >= 0) {
if (e + 1 < c && (d.charAt(e + 1) == 'Z' || d.charAt(e + 1) == '+' || d.charAt(e + 1) == '-')) {
e = this.j(d.charAt(e + 1), e + 1, c, d);
}
}
return e;
}
}
}
return -1;
};
FilterSyntaxLexer.prototype.j = function (a, b, c, d) {
if (a == 'Z') {
return b;
}
else if (a == '+' || a == '-') {
return ((b + 1) < c && this.c(d.charAt(b + 1)) && (b + 2) < c && this.c(d.charAt(b + 2)) && (b + 3) < c && (d.charAt(b + 3) == ':') && (b + 5) < c && this.c(d.charAt(b + 5)) && (b + 6) < c && this.c(d.charAt(b + 6))) ? b + 6 : -1;
}
return -1;
};
FilterSyntaxLexer.prototype.g = function (a, b, c, d) {
return (this.c(a) && (b + 1) < c && this.c(d.charAt(b + 1)) && (b + 2) < c && this.c(d.charAt(b + 2)) && (b + 3) < c && this.c(d.charAt(b + 3)) && (b + 4) < c && (d.charAt(b + 4) == '-') && (b + 5) < c && this.c(d.charAt(b + 5)) && (b + 6) < c && this.c(d.charAt(b + 6)) && (b + 7) < c && (d.charAt(b + 7) == '-') && (b + 8) < c && this.c(d.charAt(b + 8)) && (b + 9) < c && this.c(d.charAt(b + 9))) ? b + 9 : -1;
};
FilterSyntaxLexer.prototype.k = function (a, b) {
switch (b) {
case "substringof":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 20;
$ret.b = b;
return $ret;
})()));
return;
case "startswith":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 21;
$ret.b = b;
return $ret;
})()));
return;
case "endswith":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 22;
$ret.b = b;
return $ret;
})()));
return;
case "length":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 24;
$ret.b = b;
return $ret;
})()));
return;
case "replace":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 23;
$ret.b = b;
return $ret;
})()));
return;
case "indexof":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 25;
$ret.b = b;
return $ret;
})()));
return;
case "substring":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 26;
$ret.b = b;
return $ret;
})()));
return;
case "contains":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 27;
$ret.b = b;
return $ret;
})()));
return;
case "tolower":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 28;
$ret.b = b;
return $ret;
})()));
return;
case "toupper":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 29;
$ret.b = b;
return $ret;
})()));
return;
case "trim":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 30;
$ret.b = b;
return $ret;
})()));
return;
case "concat":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 31;
$ret.b = b;
return $ret;
})()));
return;
case "year":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 32;
$ret.b = b;
return $ret;
})()));
return;
case "month":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 33;
$ret.b = b;
return $ret;
})()));
return;
case "day":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 34;
$ret.b = b;
return $ret;
})()));
return;
case "days":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 35;
$ret.b = b;
return $ret;
})()));
return;
case "hour":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 36;
$ret.b = b;
return $ret;
})()));
return;
case "hours":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 37;
$ret.b = b;
return $ret;
})()));
return;
case "minute":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 38;
$ret.b = b;
return $ret;
})()));
return;
case "minutes":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 39;
$ret.b = b;
return $ret;
})()));
return;
case "second":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 40;
$ret.b = b;
return $ret;
})()));
return;
case "seconds":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 41;
$ret.b = b;
return $ret;
})()));
return;
case "date":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 42;
$ret.b = b;
return $ret;
})()));
return;
case "time":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 43;
$ret.b = b;
return $ret;
})()));
return;
case "round":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 44;
$ret.b = b;
return $ret;
})()));
return;
case "floor":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 45;
$ret.b = b;
return $ret;
})()));
return;
case "ceiling":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 46;
$ret.b = b;
return $ret;
})()));
return;
case "fractionalseconds":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 47;
$ret.b = b;
return $ret;
})()));
return;
case "totaloffsetminutes":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 48;
$ret.b = b;
return $ret;
})()));
return;
case "mindatetime":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 49;
$ret.b = b;
return $ret;
})()));
return;
case "maxdatetime":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 50;
$ret.b = b;
return $ret;
})()));
return;
case "now":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 51;
$ret.b = b;
return $ret;
})()));
return;
case "and":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 52;
$ret.b = b;
return $ret;
})()));
return;
case "or":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 53;
$ret.b = b;
return $ret;
})()));
return;
case "eq":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 54;
$ret.b = b;
return $ret;
})()));
return;
case "ne":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 55;
$ret.b = b;
return $ret;
})()));
return;
case "lt":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 56;
$ret.b = b;
return $ret;
})()));
return;
case "le":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 57;
$ret.b = b;
return $ret;
})()));
return;
case "gt":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 58;
$ret.b = b;
return $ret;
})()));
return;
case "ge":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 59;
$ret.b = b;
return $ret;
})()));
return;
case "has":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 60;
$ret.b = b;
return $ret;
})()));
return;
case "add":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 61;
$ret.b = b;
return $ret;
})()));
return;
case "sub":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 62;
$ret.b = b;
return $ret;
})()));
return;
case "mul":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 63;
$ret.b = b;
return $ret;
})()));
return;
case "div":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 64;
$ret.b = b;
return $ret;
})()));
return;
case "mod":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 65;
$ret.b = b;
return $ret;
})()));
return;
case "not":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 66;
$ret.b = b;
return $ret;
})()));
return;
case "isof":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 67;
$ret.b = b;
return $ret;
})()));
return;
case "cast":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 68;
$ret.b = b;
return $ret;
})()));
return;
case "NaN":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 69;
$ret.b = b;
return $ret;
})()));
return;
case "infinity":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 70;
$ret.b = b;
return $ret;
})()));
return;
case "env":
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 75;
$ret.b = b;
return $ret;
})()));
return;
}
a.add(((function () {
var $ret = new FilterSyntaxToken();
$ret.a = 74;
$ret.b = b;
return $ret;
})()));
};
FilterSyntaxLexer.prototype.b = function (a) {
return isLetterOrDigit(a);
};
FilterSyntaxLexer.prototype.a = function (a) {
return isLetter(a);
};
FilterSyntaxLexer.prototype.c = function (a) {
return a == '0' || a == '1' || a == '2' || a == '3' || a == '4' || a == '5' || a == '6' || a == '7' || a == '8' || a == '9';
};
FilterSyntaxLexer.prototype.d = function (a) {
return a == '\r' || a == '\n' || a == ' ' || a == '\t';
};
FilterSyntaxLexer.$t = markType(FilterSyntaxLexer, 'FilterSyntaxLexer');
return FilterSyntaxLexer;
}(Base));
export { FilterSyntaxLexer };