@qrvey/formula-lang 0.10.0 → 0.11.1
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/CHANGELOG.md +10 -0
- package/dist/cjs/constants/index.d.ts +2 -1
- package/dist/cjs/constants/index.js +1 -0
- package/dist/cjs/constants/index.js.map +1 -1
- package/dist/cjs/constants/interfaces.d.ts +18 -8
- package/dist/cjs/errors/analyzer/index.js +1 -1
- package/dist/cjs/errors/analyzer/index.js.map +1 -1
- package/dist/cjs/errors/definitions.d.ts +8 -1
- package/dist/cjs/errors/definitions.js +17 -2
- package/dist/cjs/errors/definitions.js.map +1 -1
- package/dist/cjs/errors/dictionary.d.ts +3 -1
- package/dist/cjs/errors/dictionary.js +10 -0
- package/dist/cjs/errors/dictionary.js.map +1 -1
- package/dist/cjs/errors/index.d.ts +1 -0
- package/dist/cjs/errors/index.js +1 -0
- package/dist/cjs/errors/index.js.map +1 -1
- package/dist/cjs/errors/mismatch.d.ts +33 -0
- package/dist/cjs/errors/mismatch.js +67 -0
- package/dist/cjs/errors/mismatch.js.map +1 -0
- package/dist/cjs/functions/abs.js +0 -2
- package/dist/cjs/functions/abs.js.map +1 -1
- package/dist/cjs/functions/datedif.js +7 -7
- package/dist/cjs/functions/datedif.js.map +1 -1
- package/dist/cjs/functions/day.js +0 -2
- package/dist/cjs/functions/day.js.map +1 -1
- package/dist/cjs/functions/hour.js +0 -2
- package/dist/cjs/functions/hour.js.map +1 -1
- package/dist/cjs/functions/if.js +4 -9
- package/dist/cjs/functions/if.js.map +1 -1
- package/dist/cjs/functions/ifs.js +3 -8
- package/dist/cjs/functions/ifs.js.map +1 -1
- package/dist/cjs/functions/isNull.js +3 -10
- package/dist/cjs/functions/isNull.js.map +1 -1
- package/dist/cjs/functions/mid.js +0 -4
- package/dist/cjs/functions/mid.js.map +1 -1
- package/dist/cjs/functions/minute.js +0 -2
- package/dist/cjs/functions/minute.js.map +1 -1
- package/dist/cjs/functions/month.js +0 -2
- package/dist/cjs/functions/month.js.map +1 -1
- package/dist/cjs/functions/second.js +0 -2
- package/dist/cjs/functions/second.js.map +1 -1
- package/dist/cjs/functions/year.js +0 -2
- package/dist/cjs/functions/year.js.map +1 -1
- package/dist/cjs/grammar/generated/qformula.lang.d.ts +2 -9
- package/dist/cjs/grammar/generated/qformula.lang.js +50 -27
- package/dist/cjs/grammar/generated/qformula.lang.js.map +1 -1
- package/dist/cjs/grammar/generated/qformula.lang.terms.d.ts +4 -3
- package/dist/cjs/grammar/generated/qformula.lang.terms.js +2 -2
- package/dist/cjs/grammar/generated/qformula.lang.terms.js.map +1 -1
- package/dist/cjs/grammar/tokens.d.ts +2 -0
- package/dist/cjs/grammar/tokens.js +26 -0
- package/dist/cjs/grammar/tokens.js.map +1 -0
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/parser/formula-parser.d.ts +2 -1
- package/dist/cjs/parser/formula-parser.js +11 -12
- package/dist/cjs/parser/formula-parser.js.map +1 -1
- package/dist/cjs/parser/json-parser.js +48 -19
- package/dist/cjs/parser/json-parser.js.map +1 -1
- package/dist/cjs/transpiler/columnTranspilation.d.ts +1 -1
- package/dist/cjs/transpiler/columnTranspilation.js +14 -3
- package/dist/cjs/transpiler/columnTranspilation.js.map +1 -1
- package/dist/cjs/transpiler/index.js +93 -14
- package/dist/cjs/transpiler/index.js.map +1 -1
- package/dist/cjs/transpiler/validateFuncStructure.d.ts +1 -1
- package/dist/cjs/transpiler/validateFuncStructure.js +60 -8
- package/dist/cjs/transpiler/validateFuncStructure.js.map +1 -1
- package/dist/module/constants/index.d.ts +2 -1
- package/dist/module/constants/index.js +1 -0
- package/dist/module/constants/index.js.map +1 -1
- package/dist/module/constants/interfaces.d.ts +18 -8
- package/dist/module/errors/analyzer/index.js +1 -1
- package/dist/module/errors/analyzer/index.js.map +1 -1
- package/dist/module/errors/definitions.d.ts +8 -1
- package/dist/module/errors/definitions.js +15 -1
- package/dist/module/errors/definitions.js.map +1 -1
- package/dist/module/errors/dictionary.d.ts +3 -1
- package/dist/module/errors/dictionary.js +10 -0
- package/dist/module/errors/dictionary.js.map +1 -1
- package/dist/module/errors/index.d.ts +1 -0
- package/dist/module/errors/index.js +1 -0
- package/dist/module/errors/index.js.map +1 -1
- package/dist/module/errors/mismatch.d.ts +33 -0
- package/dist/module/errors/mismatch.js +62 -0
- package/dist/module/errors/mismatch.js.map +1 -0
- package/dist/module/functions/abs.js +0 -2
- package/dist/module/functions/abs.js.map +1 -1
- package/dist/module/functions/datedif.js +7 -7
- package/dist/module/functions/datedif.js.map +1 -1
- package/dist/module/functions/day.js +0 -2
- package/dist/module/functions/day.js.map +1 -1
- package/dist/module/functions/hour.js +0 -2
- package/dist/module/functions/hour.js.map +1 -1
- package/dist/module/functions/if.js +4 -9
- package/dist/module/functions/if.js.map +1 -1
- package/dist/module/functions/ifs.js +3 -8
- package/dist/module/functions/ifs.js.map +1 -1
- package/dist/module/functions/isNull.js +3 -10
- package/dist/module/functions/isNull.js.map +1 -1
- package/dist/module/functions/mid.js +0 -4
- package/dist/module/functions/mid.js.map +1 -1
- package/dist/module/functions/minute.js +0 -2
- package/dist/module/functions/minute.js.map +1 -1
- package/dist/module/functions/month.js +0 -2
- package/dist/module/functions/month.js.map +1 -1
- package/dist/module/functions/second.js +0 -2
- package/dist/module/functions/second.js.map +1 -1
- package/dist/module/functions/year.js +0 -2
- package/dist/module/functions/year.js.map +1 -1
- package/dist/module/grammar/generated/qformula.lang.d.ts +2 -9
- package/dist/module/grammar/generated/qformula.lang.js +50 -27
- package/dist/module/grammar/generated/qformula.lang.js.map +1 -1
- package/dist/module/grammar/generated/qformula.lang.terms.d.ts +4 -3
- package/dist/module/grammar/generated/qformula.lang.terms.js +1 -1
- package/dist/module/grammar/generated/qformula.lang.terms.js.map +1 -1
- package/dist/module/grammar/tokens.d.ts +2 -0
- package/dist/module/grammar/tokens.js +23 -0
- package/dist/module/grammar/tokens.js.map +1 -0
- package/dist/module/index.d.ts +1 -1
- package/dist/module/index.js +1 -1
- package/dist/module/index.js.map +1 -1
- package/dist/module/parser/formula-parser.d.ts +2 -1
- package/dist/module/parser/formula-parser.js +9 -11
- package/dist/module/parser/formula-parser.js.map +1 -1
- package/dist/module/parser/json-parser.js +50 -21
- package/dist/module/parser/json-parser.js.map +1 -1
- package/dist/module/transpiler/columnTranspilation.d.ts +1 -1
- package/dist/module/transpiler/columnTranspilation.js +14 -3
- package/dist/module/transpiler/columnTranspilation.js.map +1 -1
- package/dist/module/transpiler/index.js +93 -14
- package/dist/module/transpiler/index.js.map +1 -1
- package/dist/module/transpiler/validateFuncStructure.d.ts +1 -1
- package/dist/module/transpiler/validateFuncStructure.js +60 -8
- package/dist/module/transpiler/validateFuncStructure.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { AST_PRIMITIVES } from '../constants';
|
|
2
|
-
import { ArgumentsDataTypeError } from '../errors';
|
|
3
1
|
import { isAColumn } from '../utils/isAColumn';
|
|
4
2
|
import { isNotAColumn } from '../utils/isNotAColumn';
|
|
5
3
|
import { inferPrimitive } from '../utils/primitiveFunctions';
|
|
@@ -8,18 +6,16 @@ import { inferPrimitive } from '../utils/primitiveFunctions';
|
|
|
8
6
|
*/
|
|
9
7
|
export const ISNULL = {
|
|
10
8
|
identifier: 'ISNULL',
|
|
11
|
-
name: 'ISNULL',
|
|
12
9
|
parameters: [
|
|
13
10
|
{
|
|
14
11
|
identifier: 'VALUE',
|
|
15
|
-
name: 'VALUE',
|
|
16
12
|
optional: false,
|
|
17
13
|
validator: [isAColumn],
|
|
18
14
|
},
|
|
19
15
|
{
|
|
20
16
|
identifier: 'REPLACEMENT',
|
|
21
|
-
name: 'REPLACEMENT',
|
|
22
17
|
optional: false,
|
|
18
|
+
generic: true,
|
|
23
19
|
validator: [isNotAColumn],
|
|
24
20
|
},
|
|
25
21
|
],
|
|
@@ -29,12 +25,9 @@ export const ISNULL = {
|
|
|
29
25
|
redshift,
|
|
30
26
|
postgresql,
|
|
31
27
|
},
|
|
28
|
+
maxPrimitiveValues: 1,
|
|
32
29
|
primitiveResult(args) {
|
|
33
|
-
|
|
34
|
-
const inferred = inferPrimitive(...(args || []).map((arg) => arg.primitive));
|
|
35
|
-
if (Array.isArray(inferred))
|
|
36
|
-
throw new ArgumentsDataTypeError(args[args.length - 1]);
|
|
37
|
-
return (_b = (_a = args === null || args === void 0 ? void 0 : args[0]) === null || _a === void 0 ? void 0 : _a.primitive) !== null && _b !== void 0 ? _b : AST_PRIMITIVES.UNKNOWN;
|
|
30
|
+
return inferPrimitive(...(args || []).map((arg) => arg.primitive));
|
|
38
31
|
},
|
|
39
32
|
};
|
|
40
33
|
function elasticsearch(value, replacement) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isNull.js","sourceRoot":"","sources":["../../../src/functions/isNull.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isNull.js","sourceRoot":"","sources":["../../../src/functions/isNull.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAuB;IACtC,UAAU,EAAE,QAAQ;IACpB,UAAU,EAAE;QACR;YACI,UAAU,EAAE,OAAO;YACnB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,CAAC,SAAS,CAAC;SACzB;QACD;YACI,UAAU,EAAE,aAAa;YACzB,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,IAAI;YACb,SAAS,EAAE,CAAC,YAAY,CAAC;SAC5B;KACJ;IACD,UAAU,EAAE;QACR,aAAa;QACb,SAAS;QACT,QAAQ;QACR,UAAU;KACb;IACD,kBAAkB,EAAE,CAAC;IACrB,eAAe,CAAC,IAAiB;QAC7B,OAAO,cAAc,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;IACvE,CAAC;CACJ,CAAC;AAEF,SAAS,aAAa,CAAC,KAAa,EAAE,WAAmB;IACrD,OAAO,kBAAkB,KAAK,KAAK,WAAW,GAAG,CAAC;AACtD,CAAC;AAED,SAAS,GAAG,CAAC,KAAa,EAAE,WAAmB;IAC3C,OAAO,YAAY,KAAK,KAAK,WAAW,GAAG,CAAC;AAChD,CAAC;AAED,SAAS,SAAS,CAAC,KAAa,EAAE,WAAmB;IACjD,OAAO,GAAG,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,WAAmB;IAChD,OAAO,GAAG,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,UAAU,CAAC,KAAa,EAAE,WAAmB;IAClD,OAAO,GAAG,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -5,23 +5,19 @@ import { isNumberParam, isStringParam } from '../utils';
|
|
|
5
5
|
*/
|
|
6
6
|
export const MID = {
|
|
7
7
|
identifier: 'MID',
|
|
8
|
-
name: 'MID',
|
|
9
8
|
parameters: [
|
|
10
9
|
{
|
|
11
10
|
identifier: 'CURRENT',
|
|
12
|
-
name: 'current',
|
|
13
11
|
optional: false,
|
|
14
12
|
validator: [isStringParam],
|
|
15
13
|
},
|
|
16
14
|
{
|
|
17
15
|
identifier: 'STARTING_AT',
|
|
18
|
-
name: 'starting_at',
|
|
19
16
|
optional: false,
|
|
20
17
|
validator: [isNumberParam],
|
|
21
18
|
},
|
|
22
19
|
{
|
|
23
20
|
identifier: 'EXTRACT_LENGTH',
|
|
24
|
-
name: 'extract_length',
|
|
25
21
|
optional: true,
|
|
26
22
|
validator: [isNumberParam],
|
|
27
23
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mid.js","sourceRoot":"","sources":["../../../src/functions/mid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAExD;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAuB;IACnC,UAAU,EAAE,KAAK;IACjB,
|
|
1
|
+
{"version":3,"file":"mid.js","sourceRoot":"","sources":["../../../src/functions/mid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAExD;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAuB;IACnC,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE;QACR;YACI,UAAU,EAAE,SAAS;YACrB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,CAAC,aAAa,CAAC;SAC7B;QACD;YACI,UAAU,EAAE,aAAa;YACzB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,CAAC,aAAa,CAAC;SAC7B;QACD;YACI,UAAU,EAAE,gBAAgB;YAC5B,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,CAAC,aAAa,CAAC;SAC7B;KACJ;IACD,UAAU,EAAE;QACR,aAAa;QACb,SAAS;QACT,QAAQ;QACR,UAAU;KACb;IACD,eAAe,EAAE,cAAc,CAAC,MAAM;CACzC,CAAC;AAEF,SAAS,aAAa,CAAC,OAAe,EAAE,KAAa,EAAE,MAAc;IACjE,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7C,OAAO,GAAG,0BAA0B,CAAC,SAAS,IAAI,OAAO,KAAK,KAAK,GAAG,QAAQ,GAAG,CAAC;AACtF,CAAC;AAED,SAAS,GAAG,CAAC,OAAe,EAAE,KAAa,EAAE,MAAc;IACvD,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7C,OAAO,aAAa,OAAO,KAAK,KAAK,GAAG,QAAQ,GAAG,CAAC;AACxD,CAAC;AAED,SAAS,SAAS,CAAC,OAAe,EAAE,KAAa,EAAE,MAAc;IAC7D,OAAO,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AACvC,CAAC;AAED,SAAS,QAAQ,CAAC,OAAe,EAAE,KAAa,EAAE,MAAc;IAC5D,OAAO,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AACvC,CAAC;AAED,SAAS,UAAU,CAAC,OAAe,EAAE,KAAa,EAAE,MAAc;IAC9D,OAAO,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"minute.js","sourceRoot":"","sources":["../../../src/functions/minute.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAuB;IACtC,UAAU,EAAE,QAAQ;IACpB,
|
|
1
|
+
{"version":3,"file":"minute.js","sourceRoot":"","sources":["../../../src/functions/minute.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAuB;IACtC,UAAU,EAAE,QAAQ;IACpB,UAAU,EAAE;QACR;YACI,UAAU,EAAE,MAAM;YAClB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,CAAC,WAAW,CAAC;SAC3B;KACJ;IACD,UAAU,EAAE;QACR,aAAa;QACb,SAAS;QACT,QAAQ;QACR,UAAU;KACb;IACD,eAAe,EAAE,cAAc,CAAC,MAAM;CACzC,CAAC;AAEF,SAAS,aAAa,CAAC,KAAa;IAChC,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,GAAG,CAAC,KAAa;IACtB,OAAO,uBAAuB,KAAK,GAAG,CAAC;AAC3C,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC5B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa;IAC3B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC7B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"month.js","sourceRoot":"","sources":["../../../src/functions/month.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAuB;IACrC,UAAU,EAAE,OAAO;IACnB,
|
|
1
|
+
{"version":3,"file":"month.js","sourceRoot":"","sources":["../../../src/functions/month.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAuB;IACrC,UAAU,EAAE,OAAO;IACnB,UAAU,EAAE;QACR;YACI,UAAU,EAAE,MAAM;YAClB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,CAAC,WAAW,CAAC;SAC3B;KACJ;IACD,UAAU,EAAE;QACR,aAAa;QACb,SAAS;QACT,QAAQ;QACR,UAAU;KACb;IACD,eAAe,EAAE,cAAc,CAAC,MAAM;CACzC,CAAC;AAEF,SAAS,aAAa,CAAC,KAAa;IAChC,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,GAAG,CAAC,KAAa;IACtB,OAAO,sBAAsB,KAAK,GAAG,CAAC;AAC1C,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC5B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa;IAC3B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC7B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"second.js","sourceRoot":"","sources":["../../../src/functions/second.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAuB;IACtC,UAAU,EAAE,QAAQ;IACpB,
|
|
1
|
+
{"version":3,"file":"second.js","sourceRoot":"","sources":["../../../src/functions/second.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAuB;IACtC,UAAU,EAAE,QAAQ;IACpB,UAAU,EAAE;QACR;YACI,UAAU,EAAE,MAAM;YAClB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,CAAC,WAAW,CAAC;SAC3B;KACJ;IACD,UAAU,EAAE;QACR,aAAa;QACb,SAAS;QACT,QAAQ;QACR,UAAU;KACb;IACD,eAAe,EAAE,cAAc,CAAC,MAAM;CACzC,CAAC;AAEF,SAAS,aAAa,CAAC,KAAa;IAChC,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,GAAG,CAAC,KAAa;IACtB,OAAO,uBAAuB,KAAK,GAAG,CAAC;AAC3C,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC5B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa;IAC3B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC7B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"year.js","sourceRoot":"","sources":["../../../src/functions/year.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAuB;IACpC,UAAU,EAAE,MAAM;IAClB,
|
|
1
|
+
{"version":3,"file":"year.js","sourceRoot":"","sources":["../../../src/functions/year.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAuB;IACpC,UAAU,EAAE,MAAM;IAClB,UAAU,EAAE;QACR;YACI,UAAU,EAAE,MAAM;YAClB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,CAAC,WAAW,CAAC;SAC3B;KACJ;IACD,UAAU,EAAE;QACR,aAAa;QACb,SAAS;QACT,QAAQ;QACR,UAAU;KACb;IACD,eAAe,EAAE,cAAc,CAAC,MAAM;CACzC,CAAC;AAEF,SAAS,aAAa,CAAC,KAAa;IAChC,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,GAAG,CAAC,KAAa;IACtB,OAAO,qBAAqB,KAAK,GAAG,CAAC;AACzC,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC5B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa;IAC3B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC7B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC"}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
export function QFormula(): LanguageSupport;
|
|
2
|
-
export namespace QFormulaHighlightConfig {
|
|
3
|
-
const parser: LRParser;
|
|
4
|
-
namespace languageData {
|
|
5
|
-
namespace commentTokens {
|
|
6
|
-
const line: string;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
2
|
export const QFormulaLang: LRLanguage;
|
|
3
|
+
export const QFormulaParser: LRParser;
|
|
11
4
|
import { LanguageSupport } from "@codemirror/language";
|
|
12
|
-
import { LRParser } from "@lezer/lr";
|
|
13
5
|
import { LRLanguage } from "@codemirror/language";
|
|
6
|
+
import { LRParser } from "@lezer/lr";
|
|
@@ -1,49 +1,72 @@
|
|
|
1
|
-
import { LRParser } from '@lezer/lr';
|
|
1
|
+
import { ExternalTokenizer, LRParser } from '@lezer/lr';
|
|
2
2
|
import { LRLanguage, LanguageSupport } from '@codemirror/language';
|
|
3
3
|
import { styleTags, tags } from '@lezer/highlight';
|
|
4
4
|
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
|
5
|
+
const noOprt = 24;
|
|
6
|
+
const space = [
|
|
7
|
+
9, 10, 11, 12, 13, 32, 133, 160, 5760, 8192, 8193, 8194, 8195, 8196, 8197,
|
|
8
|
+
8198, 8199, 8200, 8201, 8202, 8232, 8233, 8239, 8287, 12288,
|
|
9
|
+
];
|
|
10
|
+
const operators = [43, 45, 42, 47, 60, 61, 62];
|
|
11
|
+
const parenteses = [41, 40];
|
|
12
|
+
const comma = 44;
|
|
13
|
+
const noOperator = new ExternalTokenizer((input, stack) => {
|
|
14
|
+
const { next } = input;
|
|
15
|
+
if (space.indexOf(next) > -1 ||
|
|
16
|
+
parenteses.indexOf(next) > -1 ||
|
|
17
|
+
next === comma)
|
|
18
|
+
return;
|
|
19
|
+
if (operators.indexOf(next) === -1 &&
|
|
20
|
+
next != -1 &&
|
|
21
|
+
!stack.context &&
|
|
22
|
+
stack.canShift(noOprt)) {
|
|
23
|
+
input.acceptToken(noOprt);
|
|
24
|
+
}
|
|
25
|
+
}, { contextual: true });
|
|
26
|
+
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
|
5
27
|
const spec_identifier = { __proto__: null, true: 14, false: 14 };
|
|
6
28
|
const parser = LRParser.deserialize({
|
|
7
29
|
version: 14,
|
|
8
|
-
states: "
|
|
9
|
-
stateData: "%
|
|
10
|
-
goto: "#
|
|
30
|
+
states: "%^O]QQOOOOQP'#C_'#C_OOQO'#Cf'#CfOwQQO'#CeO|QSO'#CiO]QQO'#CjQ!RQROOO]QQO'#CqOOQP'#C^'#C^O!gQQO,59PO!nQQO,59TOOQP,59U,59UO]QQO,59WO]QQO,59WO]QQO,59WO]QQO,59WO]QQO,59WO!sQRO,59]O!zQRO'#CzOOQO'#Ch'#ChO#UQQO1G.kOOQP1G.o1G.oOOQP1G.r1G.rO#uQRO1G.rO#|QRO1G.rO$oQRO1G.rO$vQRO1G.rOOQP1G.w1G.wO]QQO'#CrO$}QQO,59fOOQP7+$V7+$VO%VQRO,59^OOQO-E6p-E6p",
|
|
31
|
+
stateData: "%k~OjOSkOSlOS~OSPOTPOUPOVPOZVO_TOmQOqSO~OZXO~OrYO~O_]Oa[Ob[Oc^Od_Oh`O~OWnP~P]OpeO~OWkO~P!ROolOWnX~P!ROWnO~Oa[Ob[Oc`id`ig`ih`iW`io`i~O_`i~P#ZO_]O~P#ZO_]Oa[Ob[Oc^Og`ih`iW`io`i~Od`i~P$TOd_O~P$TOolOWna~OWfaofa~P!ROTUjkjlmla~",
|
|
32
|
+
goto: "#UoPPp!`PPPPP!`!lP!x!`!`P!`PPPP!`!{PPPPPPP#RQUOQZTQaVQbXQf[Qg]Qh^Qi_Qj`RoleWOTVX[]^_`leROTVX[]^_`lRdXQmbRpmRcX",
|
|
11
33
|
nodeNames: "⚠ Program Expression Value Number Date String Boolean ParenthesisEnd Function FunctionIdentifier ParenthesisStart FunctionArguments Variable UnaryExpression ArithOp BinaryExpression ArithOp ArithOp LogicOp LogicOp ParenthesizedExpression",
|
|
12
|
-
maxTerm:
|
|
34
|
+
maxTerm: 34,
|
|
13
35
|
nodeProps: [
|
|
14
36
|
["openedBy", 8, "ParenthesisStart"],
|
|
15
37
|
["closedBy", 11, "ParenthesisEnd"]
|
|
16
38
|
],
|
|
17
39
|
skippedNodes: [0],
|
|
18
40
|
repeatNodeCount: 1,
|
|
19
|
-
tokenData: "=T~RpXY#VYZ#zZ[#V]^#zpq#Vrs$Pxy7kyz7pz{7u{|7z|}9S}!O7z!O!P9X!P!Q:a!Q![;Q!^!_;n!_!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#O#P%d#P;'S$u;'S;=`&]<%lO$u~6u[Or$urs%_s!P$u!P!Q'U!Q!R6S!R!S6S!S!T6S!T#O$u#O#P%d#P;'S$u;'S;=`&]<%lO$u~7pOZ~~7uOW~~7zOb~R8RV_PrQ{|8h}!O8h!O!P8h!Q![8h!c!}8h#R#S8h#T#o8hQ8mVrQ{|8h}!O8h!O!P8h!Q![8h!c!}8h#R#S8h#T#o8h~9XOo~R9^VrQ{|8h}!O8h!O!P8h!Q![9s!c!}8h#R#S8h#T#o8hR9zVSPrQ{|8h}!O8h!O!P8h!Q![9s!c!}8h#R#S9s#T#o8h~:fPa~!P!Q:i~:nSl~OY:iZ;'S:i;'S;=`:z<%lO:i~:}P;=`<%l:iR;XVSPrQ{|8h}!O8h!O!P9s!Q![;Q!c!}8h#R#S;Q#T#o8h~;sQc~!_!`;y!`!a<O~<OOc~~<TOd~~<YPc~!_!`;yR<dVrQmP{|8h}!O8h!O!P8h!Q![<]!c!}<]#R#S<]#T#o<]~=OOq~~=TOp~",
|
|
42
|
+
tokenizers: [noOperator, 0, 1],
|
|
21
43
|
topRules: { "Program": [0, 1] },
|
|
22
|
-
specialized: [{ term:
|
|
23
|
-
tokenPrec:
|
|
44
|
+
specialized: [{ term: 29, get: value => spec_identifier[value] || -1 }],
|
|
45
|
+
tokenPrec: 201
|
|
46
|
+
});
|
|
47
|
+
const QFormulaParser = parser.configure({
|
|
48
|
+
props: [
|
|
49
|
+
styleTags({
|
|
50
|
+
Boolean: tags.bool,
|
|
51
|
+
String: tags.string,
|
|
52
|
+
Date: tags.string,
|
|
53
|
+
Number: tags.number,
|
|
54
|
+
Variable: tags.variableName,
|
|
55
|
+
lineComment: tags.lineComment,
|
|
56
|
+
FunctionIdentifier: tags.keyword,
|
|
57
|
+
ParenthesisStart: tags.paren,
|
|
58
|
+
ParenthesisEnd: tags.paren,
|
|
59
|
+
}),
|
|
60
|
+
],
|
|
24
61
|
});
|
|
25
|
-
const
|
|
26
|
-
parser:
|
|
27
|
-
props: [
|
|
28
|
-
styleTags({
|
|
29
|
-
Boolean: tags.bool,
|
|
30
|
-
String: tags.string,
|
|
31
|
-
Date: tags.string,
|
|
32
|
-
Number: tags.number,
|
|
33
|
-
Variable: tags.keyword,
|
|
34
|
-
LineComment: tags.lineComment,
|
|
35
|
-
FunctionIdentifier: tags.lineComment,
|
|
36
|
-
'( )': tags.paren,
|
|
37
|
-
}),
|
|
38
|
-
],
|
|
39
|
-
}),
|
|
62
|
+
const QFormulaLang = LRLanguage.define({
|
|
63
|
+
parser: QFormulaParser,
|
|
40
64
|
languageData: {
|
|
41
65
|
commentTokens: { line: '//' },
|
|
42
66
|
},
|
|
43
|
-
};
|
|
44
|
-
const QFormulaLang = LRLanguage.define(QFormulaHighlightConfig);
|
|
67
|
+
});
|
|
45
68
|
function QFormula() {
|
|
46
69
|
return new LanguageSupport(QFormulaLang);
|
|
47
70
|
}
|
|
48
|
-
export { QFormula,
|
|
71
|
+
export { QFormula, QFormulaLang, QFormulaParser };
|
|
49
72
|
//# sourceMappingURL=qformula.lang.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qformula.lang.js","sourceRoot":"","sources":["../../../../src/grammar/generated/qformula.lang.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"qformula.lang.js","sourceRoot":"","sources":["../../../../src/grammar/generated/qformula.lang.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAEnD,8EAA8E;AAC9E,MAAM,MAAM,GAAG,EAAE,CAAC;AAElB,MAAM,KAAK,GAAG;IACV,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,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,aAAa,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;KAChC;CACJ,CAAC,CAAC;AACH,SAAS,QAAQ;IACb,OAAO,IAAI,eAAe,CAAC,YAAY,CAAC,CAAC;AAC7C,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export const
|
|
2
|
-
export const
|
|
3
|
-
export const
|
|
1
|
+
export const noOprt: 24;
|
|
2
|
+
export const spaces: 26;
|
|
3
|
+
export const newline: 27;
|
|
4
|
+
export const lineComment: 28;
|
|
4
5
|
export const Program: 1;
|
|
5
6
|
export const Expression: 2;
|
|
6
7
|
export const Value: 3;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
|
2
|
-
export const spaces =
|
|
2
|
+
export const noOprt = 24, spaces = 26, newline = 27, lineComment = 28, Program = 1, Expression = 2, Value = 3, Number = 4, Date = 5, String = 6, ParenthesisEnd = 8, Function = 9, FunctionIdentifier = 10, ParenthesisStart = 11, FunctionArguments = 12, Variable = 13, UnaryExpression = 14, BinaryExpression = 16, divide = 17, ParenthesizedExpression = 21;
|
|
3
3
|
//# sourceMappingURL=qformula.lang.terms.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qformula.lang.terms.js","sourceRoot":"","sources":["../../../../src/grammar/generated/qformula.lang.terms.js"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,MAAM,CAAC,MACL,MAAM,GAAG,EAAE,EACX,OAAO,GAAG,EAAE,EACZ,WAAW,GAAG,EAAE,EAChB,OAAO,GAAG,CAAC,EACX,UAAU,GAAG,CAAC,EACd,KAAK,GAAG,CAAC,EACT,MAAM,GAAG,CAAC,EACV,IAAI,GAAG,CAAC,EACR,MAAM,GAAG,CAAC,EACV,cAAc,GAAG,CAAC,EAClB,QAAQ,GAAG,CAAC,EACZ,kBAAkB,GAAG,EAAE,EACvB,gBAAgB,GAAG,EAAE,EACrB,iBAAiB,GAAG,EAAE,EACtB,QAAQ,GAAG,EAAE,EACb,eAAe,GAAG,EAAE,EACpB,gBAAgB,GAAG,EAAE,EACrB,MAAM,GAAG,EAAE,EACX,uBAAuB,GAAG,EAAE,CAAA"}
|
|
1
|
+
{"version":3,"file":"qformula.lang.terms.js","sourceRoot":"","sources":["../../../../src/grammar/generated/qformula.lang.terms.js"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,MAAM,CAAC,MACL,MAAM,GAAG,EAAE,EACX,MAAM,GAAG,EAAE,EACX,OAAO,GAAG,EAAE,EACZ,WAAW,GAAG,EAAE,EAChB,OAAO,GAAG,CAAC,EACX,UAAU,GAAG,CAAC,EACd,KAAK,GAAG,CAAC,EACT,MAAM,GAAG,CAAC,EACV,IAAI,GAAG,CAAC,EACR,MAAM,GAAG,CAAC,EACV,cAAc,GAAG,CAAC,EAClB,QAAQ,GAAG,CAAC,EACZ,kBAAkB,GAAG,EAAE,EACvB,gBAAgB,GAAG,EAAE,EACrB,iBAAiB,GAAG,EAAE,EACtB,QAAQ,GAAG,EAAE,EACb,eAAe,GAAG,EAAE,EACpB,gBAAgB,GAAG,EAAE,EACrB,MAAM,GAAG,EAAE,EACX,uBAAuB,GAAG,EAAE,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ExternalTokenizer } from '@lezer/lr';
|
|
2
|
+
import { noOprt } from './generated/qformula.lang.terms';
|
|
3
|
+
const space = [
|
|
4
|
+
9, 10, 11, 12, 13, 32, 133, 160, 5760, 8192, 8193, 8194, 8195, 8196, 8197,
|
|
5
|
+
8198, 8199, 8200, 8201, 8202, 8232, 8233, 8239, 8287, 12288,
|
|
6
|
+
];
|
|
7
|
+
const operators = [43, 45, 42, 47, 60, 61, 62];
|
|
8
|
+
const parenteses = [41, 40];
|
|
9
|
+
const comma = 44;
|
|
10
|
+
export const noOperator = new ExternalTokenizer((input, stack) => {
|
|
11
|
+
const { next } = input;
|
|
12
|
+
if (space.indexOf(next) > -1 ||
|
|
13
|
+
parenteses.indexOf(next) > -1 ||
|
|
14
|
+
next === comma)
|
|
15
|
+
return;
|
|
16
|
+
if (operators.indexOf(next) === -1 &&
|
|
17
|
+
next != -1 &&
|
|
18
|
+
!stack.context &&
|
|
19
|
+
stack.canShift(noOprt)) {
|
|
20
|
+
input.acceptToken(noOprt);
|
|
21
|
+
}
|
|
22
|
+
}, { contextual: true });
|
|
23
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/grammar/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAEzD,MAAM,KAAK,GAAG;IACV,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IACzE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK;CAC9D,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAC/C,MAAM,UAAU,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC5B,MAAM,KAAK,GAAG,EAAE,CAAC;AAEjB,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,iBAAiB,CAC3C,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;IACb,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IACvB,IACI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACxB,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,KAAK,KAAK;QAEd,OAAO;IACX,IACI,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9B,IAAI,IAAI,CAAC,CAAC;QACV,CAAC,KAAK,CAAC,OAAO;QACd,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EACxB;QACE,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;KAC7B;AACL,CAAC,EACD,EAAE,UAAU,EAAE,IAAI,EAAE,CACvB,CAAC"}
|
package/dist/module/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ENGINES } from './constants/index';
|
|
2
2
|
import { FormulaContext, TranspilationResponse } from './constants/interfaces';
|
|
3
|
-
export { QFormula as FormulaHighlight, QFormulaLang as FormulaLang,
|
|
3
|
+
export { QFormula as FormulaHighlight, QFormulaLang as FormulaLang, QFormulaParser as FormulaParser, } from './grammar/qformula.grammar';
|
|
4
4
|
export { calculateAST } from './parser/json-parser';
|
|
5
5
|
export { ENGINES, AST_PRIMITIVES } from './constants/index';
|
|
6
6
|
export { FUNCTION_LIST, getFunctionDetail } from './functions/index';
|
package/dist/module/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { QFormulaLang } from './grammar/qformula.grammar';
|
|
2
2
|
import { calculateAST } from './parser/json-parser';
|
|
3
3
|
import { TranspileAST } from './transpiler/index';
|
|
4
|
-
export { QFormula as FormulaHighlight, QFormulaLang as FormulaLang,
|
|
4
|
+
export { QFormula as FormulaHighlight, QFormulaLang as FormulaLang, QFormulaParser as FormulaParser, } from './grammar/qformula.grammar';
|
|
5
5
|
export { calculateAST } from './parser/json-parser';
|
|
6
6
|
export { ENGINES, AST_PRIMITIVES } from './constants/index';
|
|
7
7
|
export { FUNCTION_LIST, getFunctionDetail } from './functions/index';
|
package/dist/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EACH,QAAQ,IAAI,gBAAgB,EAC5B,YAAY,IAAI,WAAW,EAC3B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EACH,QAAQ,IAAI,gBAAgB,EAC5B,YAAY,IAAI,WAAW,EAC3B,cAAc,IAAI,aAAa,GAClC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAMlD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEpD,MAAM,UAAU,SAAS,CACrB,OAAe,EACf,MAAe,EACf,OAAwB;IAExB,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC;IACnC,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACnC,IAAI,CAAC,IAAI,CAAC,OAAO;QAAE,OAAO;IAC1B,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACjD,IAAI,CAAC,GAAG;QAAE,OAAO;IACjB,OAAO,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SyntaxNode } from '@lezer/common';
|
|
2
|
-
import { FormulaContext, FormulaInference, FunctionCallAST } from '../constants/interfaces';
|
|
2
|
+
import { FormulaContext, FormulaInference, FunctionCallAST, ProgramPosition } from '../constants/interfaces';
|
|
3
3
|
import { TransformNodeFNType } from './interfaces';
|
|
4
4
|
export declare function transformFunctionExpression(program: string, node: SyntaxNode, inference: FormulaInference, context: FormulaContext | undefined, transformNodeFunction: TransformNodeFNType): FunctionCallAST;
|
|
5
|
+
export declare function createPositionASTFromSyntaxNode({ from, to, }: SyntaxNode): ProgramPosition;
|
|
@@ -11,6 +11,7 @@ export function transformFunctionExpression(program, node, inference, context, t
|
|
|
11
11
|
const parenthesisStart = node.getChild('ParenthesisStart');
|
|
12
12
|
const parenthesisEnd = node.getChild('ParenthesisEnd');
|
|
13
13
|
const args = getFunctionArguments(node, parenthesisStart, program, inference, context, transformNodeFunction);
|
|
14
|
+
const functionIdentifier = createPositionASTFromSyntaxNode(fnIdentifier);
|
|
14
15
|
const baseNode = {
|
|
15
16
|
type: AST_TYPES.functionCall,
|
|
16
17
|
name: getNodeValue(program, fnIdentifier),
|
|
@@ -19,22 +20,16 @@ export function transformFunctionExpression(program, node, inference, context, t
|
|
|
19
20
|
to: node.to,
|
|
20
21
|
parenthesisStart: !!parenthesisStart,
|
|
21
22
|
parenthesisEnd: !!parenthesisEnd,
|
|
22
|
-
|
|
23
|
+
functionText: fnString,
|
|
24
|
+
functionIdentifier,
|
|
23
25
|
};
|
|
24
26
|
const functionExists = FUNCTION_LIST.includes(fnName);
|
|
25
27
|
const functionDetail = functionExists
|
|
26
28
|
? getFunctionDetail(fnName)
|
|
27
29
|
: undefined;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
? getFunctionPrimitive(functionDetail, baseNode.arguments)
|
|
32
|
-
: AST_PRIMITIVES.UNKNOWN;
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
primitive = AST_PRIMITIVES.UNKNOWN;
|
|
36
|
-
inference.errorList.push(error);
|
|
37
|
-
}
|
|
30
|
+
const primitive = functionDetail
|
|
31
|
+
? getFunctionPrimitive(functionDetail, baseNode.arguments)
|
|
32
|
+
: AST_PRIMITIVES.UNKNOWN;
|
|
38
33
|
const resultNode = Object.assign(Object.assign({}, baseNode), { primitive });
|
|
39
34
|
if (functionExists && (!parenthesisStart || !parenthesisEnd)) {
|
|
40
35
|
inference.errorList.push(new MissingParenthesisError(Object.assign(Object.assign({}, resultNode), { from: !parenthesisStart ? resultNode.from : resultNode.to })));
|
|
@@ -89,4 +84,7 @@ function createCommonASTFromNode(program, node, inference, context, transformNod
|
|
|
89
84
|
}
|
|
90
85
|
return transformNodeFunction(program, node, inference, context);
|
|
91
86
|
}
|
|
87
|
+
export function createPositionASTFromSyntaxNode({ from, to, }) {
|
|
88
|
+
return { from, to };
|
|
89
|
+
}
|
|
92
90
|
//# sourceMappingURL=formula-parser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formula-parser.js","sourceRoot":"","sources":["../../../src/parser/formula-parser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formula-parser.js","sourceRoot":"","sources":["../../../src/parser/formula-parser.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,E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;AACtB,CAAC;AAED,SAAS,uBAAuB,CAC5B,OAAe,EACf,IAAgB,EAChB,SAA2B,EAC3B,OAAmC,EACnC,qBAA0C;IAE1C,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;QACnB,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;KACnC;IACD,OAAO,qBAAqB,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,EAC5C,IAAI,EACJ,EAAE,GACO;IACT,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;AACxB,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AST_PRIMITIVES, AST_TYPES } from '../constants';
|
|
2
2
|
import { getNodeValue, getMonthMaxDayAllowed, isValidDate, getVariableType, getVariableContext, } from '../utils';
|
|
3
3
|
import { calculateNodeSyntaxErrors } from './syntax-errors';
|
|
4
|
-
import { MissingParenthesisError,
|
|
4
|
+
import { MissingParenthesisError, NotAllowedOperationError } from '../errors';
|
|
5
5
|
import { primitiveIsIncluded } from '../utils/primitiveFunctions';
|
|
6
|
-
import { transformFunctionExpression } from './formula-parser';
|
|
6
|
+
import { createPositionASTFromSyntaxNode, transformFunctionExpression, } from './formula-parser';
|
|
7
7
|
const PARSER_VERSION = '0.0.0';
|
|
8
8
|
const LANG_NAME = 'QrveyLang';
|
|
9
9
|
export function calculateAST(program, tree, context) {
|
|
@@ -76,9 +76,33 @@ function transformNode(program, node, inference, context) {
|
|
|
76
76
|
inference.flatBody.push(resultNode);
|
|
77
77
|
return resultNode;
|
|
78
78
|
}
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
const VALID_OPERATIONS_BY_TYPE = {
|
|
80
|
+
[AST_PRIMITIVES.NUMBER]: [
|
|
81
|
+
'+',
|
|
82
|
+
'-',
|
|
83
|
+
'*',
|
|
84
|
+
'/',
|
|
85
|
+
'<',
|
|
86
|
+
'<=',
|
|
87
|
+
'>',
|
|
88
|
+
'>=',
|
|
89
|
+
'=',
|
|
90
|
+
'<>',
|
|
91
|
+
],
|
|
92
|
+
[AST_PRIMITIVES.STRING]: ['=', '<>'],
|
|
93
|
+
[AST_PRIMITIVES.DATE]: ['=', '<>'],
|
|
94
|
+
[AST_PRIMITIVES.BOOLEAN]: [],
|
|
95
|
+
[AST_PRIMITIVES.UNKNOWN]: [],
|
|
96
|
+
};
|
|
97
|
+
function operatorIsValidForOperation(operator, leftPrimitive, rightPrimitive) {
|
|
98
|
+
const allowedOperators = calculateValidOperatorsByType(leftPrimitive, rightPrimitive);
|
|
99
|
+
return allowedOperators.includes(operator);
|
|
100
|
+
}
|
|
101
|
+
function calculateValidOperatorsByType(leftPrimitive, rightPrimitive) {
|
|
102
|
+
if (leftPrimitive === rightPrimitive && !Array.isArray(leftPrimitive)) {
|
|
103
|
+
return VALID_OPERATIONS_BY_TYPE[leftPrimitive];
|
|
104
|
+
}
|
|
105
|
+
return [];
|
|
82
106
|
}
|
|
83
107
|
function calculateBinaryElements(program, node, left, right) {
|
|
84
108
|
const leftPrimitive = left === null || left === void 0 ? void 0 : left.primitive;
|
|
@@ -87,23 +111,17 @@ function calculateBinaryElements(program, node, left, right) {
|
|
|
87
111
|
const arithOperator = node.getChild('ArithOp');
|
|
88
112
|
const leftIsAValidNumber = leftPrimitive === AST_PRIMITIVES.NUMBER;
|
|
89
113
|
const rightIsAValidNumber = rightPrimitive === AST_PRIMITIVES.NUMBER;
|
|
90
|
-
const leftIsAValidString = leftPrimitive === AST_PRIMITIVES.STRING;
|
|
91
|
-
const rightIsAValidString = rightPrimitive === AST_PRIMITIVES.STRING;
|
|
92
|
-
const leftIsAValidDate = leftPrimitive === AST_PRIMITIVES.DATE;
|
|
93
|
-
const rightIsAValidDate = rightPrimitive === AST_PRIMITIVES.DATE;
|
|
94
114
|
const operatorNode = (logicOperator !== null && logicOperator !== void 0 ? logicOperator : arithOperator);
|
|
95
115
|
const operator = getNodeValue(program, operatorNode);
|
|
116
|
+
const operatorPosition = !operatorNode
|
|
117
|
+
? undefined
|
|
118
|
+
: createPositionASTFromSyntaxNode(operatorNode);
|
|
119
|
+
const validOperators = calculateValidOperatorsByType(leftPrimitive, rightPrimitive);
|
|
96
120
|
// primitive is number if arithOperator is not null and both left and right are numbers
|
|
97
121
|
// primitive is boolean if logicOperator is not null and both left and right are booleans
|
|
98
122
|
let primitive = AST_PRIMITIVES.UNKNOWN;
|
|
99
123
|
if (logicOperator) {
|
|
100
|
-
if ((leftPrimitive
|
|
101
|
-
!leftIsAValidString &&
|
|
102
|
-
!leftIsAValidDate) ||
|
|
103
|
-
(((leftIsAValidString && rightIsAValidString) ||
|
|
104
|
-
(leftIsAValidDate && rightIsAValidDate)) &&
|
|
105
|
-
// string and date operation only with allowed operators
|
|
106
|
-
isValidStringDateBinaryOperation(operator))) {
|
|
124
|
+
if (operatorIsValidForOperation(operator, leftPrimitive, rightPrimitive)) {
|
|
107
125
|
primitive = AST_PRIMITIVES.BOOLEAN;
|
|
108
126
|
}
|
|
109
127
|
}
|
|
@@ -118,25 +136,29 @@ function calculateBinaryElements(program, node, left, right) {
|
|
|
118
136
|
return {
|
|
119
137
|
primitive,
|
|
120
138
|
operator,
|
|
139
|
+
operatorNode: operatorPosition,
|
|
121
140
|
hasInvalidError,
|
|
141
|
+
validOperators,
|
|
122
142
|
};
|
|
123
143
|
}
|
|
124
144
|
function transformBinaryExpression(program, node, inference, context) {
|
|
125
145
|
const [leftNode, rightNode] = node.getChildren('Expression');
|
|
126
146
|
const left = transformNode(program, leftNode, inference, context);
|
|
127
147
|
const right = transformNode(program, rightNode, inference, context);
|
|
128
|
-
const { primitive, operator, hasInvalidError } = calculateBinaryElements(program, node, left, right);
|
|
148
|
+
const { primitive, operator, operatorNode, hasInvalidError, validOperators, } = calculateBinaryElements(program, node, left, right);
|
|
129
149
|
const binaryAST = {
|
|
130
150
|
operator,
|
|
151
|
+
operatorNode,
|
|
131
152
|
type: AST_TYPES.binaryExpression,
|
|
132
153
|
left,
|
|
133
154
|
right,
|
|
134
155
|
from: node.from,
|
|
135
156
|
to: node.to,
|
|
136
157
|
primitive,
|
|
158
|
+
validOperators,
|
|
137
159
|
};
|
|
138
160
|
if (hasInvalidError) {
|
|
139
|
-
inference.errorList.push(new
|
|
161
|
+
inference.errorList.push(new NotAllowedOperationError(binaryAST));
|
|
140
162
|
}
|
|
141
163
|
return binaryAST;
|
|
142
164
|
}
|
|
@@ -147,16 +169,19 @@ function transformUnaryExpression(program, node, inference, context) {
|
|
|
147
169
|
const primitive = primitiveIsIncluded(right === null || right === void 0 ? void 0 : right.primitive, AST_PRIMITIVES.NUMBER, AST_PRIMITIVES.BOOLEAN)
|
|
148
170
|
? right.primitive
|
|
149
171
|
: AST_PRIMITIVES.UNKNOWN;
|
|
172
|
+
const validOperators = (right === null || right === void 0 ? void 0 : right.primitive) === AST_PRIMITIVES.NUMBER ? ['+', '-'] : [];
|
|
150
173
|
const unaryAST = {
|
|
151
174
|
operator: getNodeValue(program, operator),
|
|
175
|
+
operatorNode: createPositionASTFromSyntaxNode(operator),
|
|
152
176
|
type: AST_TYPES.unaryExpression,
|
|
153
177
|
right,
|
|
154
178
|
from: node.from,
|
|
155
179
|
to: node.to,
|
|
156
180
|
primitive,
|
|
181
|
+
validOperators,
|
|
157
182
|
};
|
|
158
183
|
if (!rightNode) {
|
|
159
|
-
inference.errorList.push(new
|
|
184
|
+
inference.errorList.push(new NotAllowedOperationError(unaryAST));
|
|
160
185
|
}
|
|
161
186
|
return unaryAST;
|
|
162
187
|
}
|
|
@@ -167,10 +192,14 @@ function transformParenthesizedExpression(program, node, inference, context) {
|
|
|
167
192
|
const parenthesisEnd = node.getChild('ParenthesisEnd');
|
|
168
193
|
const resultNode = transformNode(program, expressionNode, inference, context);
|
|
169
194
|
if (!parenthesisStart || !parenthesisEnd) {
|
|
195
|
+
const [from, to] = [
|
|
196
|
+
!parenthesisStart ? node.from : parenthesisStart.from,
|
|
197
|
+
!parenthesisStart ? node.to : parenthesisStart.to,
|
|
198
|
+
];
|
|
170
199
|
inference.errorList.push(new MissingParenthesisError({
|
|
171
200
|
type: AST_TYPES.parenthesisExpression,
|
|
172
|
-
from
|
|
173
|
-
to
|
|
201
|
+
from,
|
|
202
|
+
to,
|
|
174
203
|
primitive: (_a = resultNode === null || resultNode === void 0 ? void 0 : resultNode.primitive) !== null && _a !== void 0 ? _a : AST_PRIMITIVES.UNKNOWN,
|
|
175
204
|
}));
|
|
176
205
|
}
|