@witchcraft/expressit 0.0.2 → 0.0.3
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/README.md +3 -3
- package/dist/ast/builders/token.js +1 -1
- package/dist/ast/index.d.ts.map +1 -1
- package/dist/examples/index.d.ts +2 -0
- package/dist/examples/index.d.ts.map +1 -0
- package/dist/examples/index.js +4 -0
- package/dist/examples/shortcutContextParser.d.ts +1 -0
- package/dist/examples/shortcutContextParser.d.ts.map +1 -1
- package/dist/examples/shortcutContextParser.js +8 -4
- package/dist/grammar/ParserBase.d.ts.map +1 -1
- package/dist/grammar/ParserBase.js +2 -1
- package/dist/grammar/createTokens.d.ts.map +1 -1
- package/dist/grammar/createTokens.js +2 -1
- package/dist/helpers/errors.d.ts.map +1 -1
- package/dist/helpers/errors.js +3 -1
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/parser/checkParserOpts.d.ts.map +1 -1
- package/dist/helpers/parser/checkParserOpts.js +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/methods/autocomplete.js +1 -1
- package/dist/methods/autoreplace.js +1 -1
- package/dist/methods/autosuggest.js +1 -1
- package/dist/methods/evaluate.d.ts.map +1 -1
- package/dist/methods/evaluate.js +3 -1
- package/dist/methods/getIndexes.d.ts.map +1 -1
- package/dist/methods/getIndexes.js +2 -1
- package/dist/methods/normalize.d.ts +0 -2
- package/dist/methods/normalize.d.ts.map +1 -1
- package/dist/methods/normalize.js +2 -3
- package/dist/methods/validate.d.ts.map +1 -1
- package/dist/methods/validate.js +2 -1
- package/dist/package.json.js +25 -5
- package/dist/parser.d.ts +1 -1
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +2 -1
- package/dist/types/ast.d.ts +1 -1
- package/dist/types/ast.d.ts.map +1 -1
- package/dist/types/errors.d.ts +1 -1
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/parser.d.ts +6 -2
- package/dist/types/parser.d.ts.map +1 -1
- package/dist/utils/extractTokens.js +1 -1
- package/dist/utils/getCursorInfo.d.ts.map +1 -1
- package/dist/utils/getCursorInfo.js +5 -1
- package/dist/utils/getOppositeDelimiter.js +1 -1
- package/dist/utils/prettyAst.d.ts.map +1 -1
- package/dist/utils/prettyAst.js +14 -9
- package/package.json +25 -5
- package/src/ast/builders/array.ts +1 -1
- package/src/ast/builders/index.ts +1 -1
- package/src/ast/builders/token.ts +1 -1
- package/src/ast/classes/index.ts +1 -1
- package/src/ast/index.ts +2 -2
- package/src/examples/index.ts +3 -0
- package/src/examples/shortcutContextParser.ts +9 -4
- package/src/grammar/ParserBase.ts +2 -1
- package/src/grammar/createTokens.ts +2 -1
- package/src/helpers/errors.ts +4 -2
- package/src/helpers/general/index.ts +1 -1
- package/src/helpers/index.ts +3 -2
- package/src/helpers/parser/checkParserOpts.ts +3 -2
- package/src/helpers/parser/index.ts +1 -1
- package/src/index.ts +1 -0
- package/src/methods/autocomplete.ts +1 -1
- package/src/methods/autoreplace.ts +1 -1
- package/src/methods/autosuggest.ts +2 -2
- package/src/methods/evaluate.ts +3 -1
- package/src/methods/getIndexes.ts +2 -1
- package/src/methods/normalize.ts +2 -3
- package/src/methods/validate.ts +3 -1
- package/src/parser.ts +3 -2
- package/src/types/ast.ts +1 -1
- package/src/types/errors.ts +1 -1
- package/src/types/parser.ts +6 -3
- package/src/utils/extractTokens.ts +1 -1
- package/src/utils/getCursorInfo.ts +2 -1
- package/src/utils/getOppositeDelimiter.ts +1 -1
- package/src/utils/prettyAst.ts +4 -2
- package/dist/examples/advancedValueComparer.d.ts +0 -3
- package/dist/examples/advancedValueComparer.d.ts.map +0 -1
- package/dist/examples/advancedValueComparer.js +0 -28
- package/src/examples/advancedValueComparer.ts +0 -31
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
### 🚧 WORK IN PROGRESS 🚧
|
|
3
3
|
|
|
4
|
-

|
|
5
|
+

|
|
6
|
+
[](https://www.npmjs.com/@witchcraft/expressit)
|
|
7
7
|
|
|
8
8
|
Expressit is a blazing fast, customizable, error-tolerant expression parser that creates safe to eval expressions + a few other goodies.
|
|
9
9
|
|
package/dist/ast/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ast/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ast/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAG7C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/examples/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA"}
|
|
@@ -17,6 +17,7 @@ export declare class ShortcutContextParser<T extends Position & {
|
|
|
17
17
|
validKeys: string[];
|
|
18
18
|
regexablekeys: string[];
|
|
19
19
|
constructor(dummyContext: Record<string, any>, validRegexFlags?: string[]);
|
|
20
|
+
setContext(context: Record<string, any>): void;
|
|
20
21
|
private _extractKeysFromContext;
|
|
21
22
|
}
|
|
22
23
|
//# sourceMappingURL=shortcutContextParser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shortcutContextParser.d.ts","sourceRoot":"","sources":["../../src/examples/shortcutContextParser.ts"],"names":[],"mappings":"AACA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAI/C,qBAAa,qBAAqB,CAAC,CAAC,SACnC,QAAQ,GAAG;IAAE,IAAI,EAAE,CAAC,YAAY,GAAG,gBAAgB,GAAG,kBAAkB,GAAG,oBAAoB,CAAC,CAAA;CAAE,GAClG,QAAQ,GAAG;IAAE,IAAI,EAAE,CAAC,YAAY,GAAG,gBAAgB,GAAG,kBAAkB,GAAG,oBAAoB,CAAC,CAAA;CAAE,CACjG,SAAQ,MAAM,CAAC,CAAC,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAK;IAExB,aAAa,EAAE,MAAM,EAAE,CAAK;gBAG3B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,eAAe,GAAE,MAAM,EAAoB;IAmG5C,OAAO,CAAC,uBAAuB;CAa/B"}
|
|
1
|
+
{"version":3,"file":"shortcutContextParser.d.ts","sourceRoot":"","sources":["../../src/examples/shortcutContextParser.ts"],"names":[],"mappings":"AACA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAI/C,qBAAa,qBAAqB,CAAC,CAAC,SACnC,QAAQ,GAAG;IAAE,IAAI,EAAE,CAAC,YAAY,GAAG,gBAAgB,GAAG,kBAAkB,GAAG,oBAAoB,CAAC,CAAA;CAAE,GAClG,QAAQ,GAAG;IAAE,IAAI,EAAE,CAAC,YAAY,GAAG,gBAAgB,GAAG,kBAAkB,GAAG,oBAAoB,CAAC,CAAA;CAAE,CACjG,SAAQ,MAAM,CAAC,CAAC,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAK;IAExB,aAAa,EAAE,MAAM,EAAE,CAAK;gBAG3B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,eAAe,GAAE,MAAM,EAAoB;IAmG5C,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAK9C,OAAO,CAAC,uBAAuB;CAa/B"}
|
|
@@ -24,11 +24,11 @@ class ShortcutContextParser extends Parser {
|
|
|
24
24
|
}
|
|
25
25
|
return prefix + variable;
|
|
26
26
|
},
|
|
27
|
-
valueComparer: (
|
|
28
|
-
if (
|
|
29
|
-
return contextValue.match(
|
|
27
|
+
valueComparer: (condition, contextValue, _context) => {
|
|
28
|
+
if (condition.value instanceof RegExp) {
|
|
29
|
+
return contextValue.match(condition.value) !== null;
|
|
30
30
|
}
|
|
31
|
-
return contextValue ===
|
|
31
|
+
return contextValue === condition.value;
|
|
32
32
|
},
|
|
33
33
|
valueValidator: (_contextValue, query) => {
|
|
34
34
|
let tokens = [];
|
|
@@ -106,6 +106,10 @@ class ShortcutContextParser extends Parser {
|
|
|
106
106
|
__publicField(this, "regexablekeys", []);
|
|
107
107
|
this._extractKeysFromContext(dummyContext);
|
|
108
108
|
}
|
|
109
|
+
setContext(context) {
|
|
110
|
+
this.validKeys = [];
|
|
111
|
+
this._extractKeysFromContext(context);
|
|
112
|
+
}
|
|
109
113
|
_extractKeysFromContext(context, prev) {
|
|
110
114
|
for (const key of Object.keys(context)) {
|
|
111
115
|
if (typeof context[key] === "boolean") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParserBase.d.ts","sourceRoot":"","sources":["../../src/grammar/ParserBase.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ParserBase.d.ts","sourceRoot":"","sources":["../../src/grammar/ParserBase.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAO,KAAK,MAAM,EAAgB,MAAM,YAAY,CAAA;AAElF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGrD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAE/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,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C,CAAA;IAC/C,QAAQ,EAAE,MAAM,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAA;CAC3D"}
|
|
@@ -4,7 +4,8 @@ var __publicField = (obj, key, value) => {
|
|
|
4
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
|
-
import { isArray
|
|
7
|
+
import { isArray } from "@alanscodelog/utils/isArray";
|
|
8
|
+
import { unreachable } from "@alanscodelog/utils/unreachable";
|
|
8
9
|
import { EmbeddedActionsParser, EOF, tokenMatcher } from "chevrotain";
|
|
9
10
|
import { pos } from "../ast/builders/pos.js";
|
|
10
11
|
import { ArrayNode } from "../ast/classes/ArrayNode.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTokens.d.ts","sourceRoot":"","sources":["../../src/grammar/createTokens.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createTokens.d.ts","sourceRoot":"","sources":["../../src/grammar/createTokens.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAA;AAE/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAG3D,iGAAiG;AAEjG,aAAK,EAAE;IACN,CAAC,MAAM;IACP,GAAG,QAAQ;IACX,SAAS,cAAc;IACvB,YAAY,iBAAiB;IAC7B,YAAY,iBAAiB;IAC7B,cAAc,mBAAmB;IACjC,KAAK,UAAU;IACf,SAAS,cAAc;IACvB,cAAc,mBAAmB;IACjC,sBAAsB,2BAA2B;IACjD,WAAW,gBAAgB;IAC3B,gBAAgB,qBAAqB;IACrC,gBAAgB,qBAAqB;IACrC,kBAAkB,uBAAuB;IACzC,gBAAgB,qBAAqB;IACrC,gBAAgB,qBAAqB;IACrC,kBAAkB,uBAAuB;IACzC,WAAW,gBAAgB;IAC3B,YAAY,iBAAiB;IAC7B,YAAY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apeRegex } from "@alanscodelog/utils/escapeRegex";
|
|
2
|
+
import { isBlank } from "@alanscodelog/utils/isBlank";
|
|
2
3
|
import { createToken, Lexer } from "chevrotain";
|
|
3
4
|
function clone(token) {
|
|
4
5
|
const t = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/helpers/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/helpers/errors.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAGhE,qBAAa,yBAAyB,CAAC,CAAC,SAAS,WAAW,CAAE,SAAQ,KAAK;IAC1E,OAAO,EAAE,MAAM,CAAU;IAEzB,IAAI,EAAE,MAAM,CAAa;IAEzB,IAAI,EAAE,CAAC,CAAA;IAEP,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAA;gBAEN,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM;CAYzD"}
|
package/dist/helpers/errors.js
CHANGED
|
@@ -4,7 +4,9 @@ var __publicField = (obj, key, value) => {
|
|
|
4
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { crop } from "@alanscodelog/utils/crop";
|
|
8
|
+
import { indent } from "@alanscodelog/utils/indent";
|
|
9
|
+
import { pretty } from "@alanscodelog/utils/pretty";
|
|
8
10
|
import { version, repository } from "../package.js";
|
|
9
11
|
class BooleanParserLibraryError extends Error {
|
|
10
12
|
constructor(type, info, message) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAC7C,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAI3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkParserOpts.d.ts","sourceRoot":"","sources":["../../../src/helpers/parser/checkParserOpts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"checkParserOpts.d.ts","sourceRoot":"","sources":["../../../src/helpers/parser/checkParserOpts.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,uBAAuB,CAAA;AAM7E,wBAAgB,eAAe,CAAC,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAAE,eAAe,GAAE,OAAe,EAAE,eAAe,GAAE,OAAe,GAAG,IAAI,CAoIlJ"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isBlank } from "@alanscodelog/utils/isBlank";
|
|
2
|
+
import { pushIfNotIn } from "@alanscodelog/utils/pushIfNotIn";
|
|
2
3
|
import { ERROR_CODES } from "../../types/errors.js";
|
|
3
4
|
import { BooleanParserLibraryError } from "../errors.js";
|
|
4
5
|
import { defaultConditionNormalizer } from "../general/defaultConditionNormalizer.js";
|
|
@@ -18,7 +19,7 @@ function checkParserOpts(opts, evaluatorChecks = false, validatorChecks = false)
|
|
|
18
19
|
if (opts.expandedPropertySeparator)
|
|
19
20
|
extra.push(opts.expandedPropertySeparator);
|
|
20
21
|
if (opts.customPropertyOperators)
|
|
21
|
-
pushIfNotIn(extra,
|
|
22
|
+
pushIfNotIn(extra, opts.customPropertyOperators);
|
|
22
23
|
if (opts.expandedPropertySeparator && isBlank(opts.expandedPropertySeparator)) {
|
|
23
24
|
throw new BooleanParserLibraryError(
|
|
24
25
|
ERROR_CODES.PARSER_CONFLICTING_OPTIONS_ERROR,
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,GAAG,MAAM,wBAAwB,CAAA;AAC7C,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,cAAc,kBAAkB,CAAA;AAChC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { unreachable } from "@alanscodelog/utils";
|
|
1
|
+
import { unreachable } from "@alanscodelog/utils/unreachable";
|
|
2
2
|
import { ConditionNode } from "../ast/classes/ConditionNode.js";
|
|
3
3
|
import { VariableNode } from "../ast/classes/VariableNode.js";
|
|
4
4
|
import { SUGGESTION_TYPE } from "../types/autocomplete.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { insert } from "@alanscodelog/utils";
|
|
1
|
+
import { insert } from "@alanscodelog/utils/insert";
|
|
2
2
|
class AutoreplaceMixin {
|
|
3
3
|
/**
|
|
4
4
|
* Given the input string and a @see Completion consisting of the value of the replacement and a @see Suggestion entry, returns the replacement string and the new position of the cursor.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { unreachable } from "@alanscodelog/utils";
|
|
1
|
+
import { unreachable } from "@alanscodelog/utils/unreachable";
|
|
2
2
|
import { pos } from "../ast/builders/pos.js";
|
|
3
3
|
import { ArrayNode } from "../ast/classes/ArrayNode.js";
|
|
4
4
|
import { ConditionNode } from "../ast/classes/ConditionNode.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../src/methods/evaluate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../src/methods/evaluate.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA;AAKzD,qBAAa,aAAa,CAAC,CAAC,SAAS,EAAE;IACtC;;;;OAIG;IACH,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO;CAsBhG"}
|
package/dist/methods/evaluate.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { get
|
|
1
|
+
import { get } from "@alanscodelog/utils/get";
|
|
2
|
+
import "@alanscodelog/utils/types";
|
|
3
|
+
import { unreachable } from "@alanscodelog/utils/unreachable";
|
|
2
4
|
import { Condition } from "../ast/classes/Condition.js";
|
|
3
5
|
import { Expression } from "../ast/classes/Expression.js";
|
|
4
6
|
import { TOKEN_TYPE } from "../types/ast.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getIndexes.d.ts","sourceRoot":"","sources":["../../src/methods/getIndexes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getIndexes.d.ts","sourceRoot":"","sources":["../../src/methods/getIndexes.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA;AAIzD,qBAAa,aAAa,CAAC,CAAC;IAC3B;;;;;;;;;;OAUG;IACH,UAAU,CAAC,GAAG,EAAE,SAAS,GAAG,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE;CAqEtD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "@alanscodelog/utils/types";
|
|
2
|
+
import { unreachable } from "@alanscodelog/utils/unreachable";
|
|
2
3
|
import { Condition } from "../ast/classes/Condition.js";
|
|
3
4
|
import { Expression } from "../ast/classes/Expression.js";
|
|
4
5
|
import { TOKEN_TYPE } from "../types/ast.js";
|
|
@@ -4,8 +4,6 @@ import { type ParserResults } from "../types/ast.js";
|
|
|
4
4
|
export declare class NormalizeMixin<T extends {}> {
|
|
5
5
|
/**
|
|
6
6
|
* Normalizes the ast by applying {@link GroupNode GroupNodes} and converting {@link ConditionNode ConditionNodes} to {@link NormalizedConditionNode NormalizedConditionNodes}.
|
|
7
|
-
*
|
|
8
|
-
* To do this, a
|
|
9
7
|
*/
|
|
10
8
|
normalize<TType extends string, TValue>(ast: ParserResults): Condition<TType, TValue> | Expression<TType, TValue>;
|
|
11
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/methods/normalize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/methods/normalize.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAGvD,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA;AAQzD,OAAO,EAAE,KAAK,aAAa,EAAsC,MAAM,iBAAiB,CAAA;AASxF,qBAAa,cAAc,CAAC,CAAC,SAAS,EAAE;IACvC;;OAEG;IACH,SAAS,CAAC,KAAK,SAAS,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,GAAG,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC;CA4GjH"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "@alanscodelog/utils/types";
|
|
2
|
+
import { unreachable } from "@alanscodelog/utils/unreachable";
|
|
2
3
|
import { ArrayNode } from "../ast/classes/ArrayNode.js";
|
|
3
4
|
import { Condition } from "../ast/classes/Condition.js";
|
|
4
5
|
import { ConditionNode } from "../ast/classes/ConditionNode.js";
|
|
@@ -18,8 +19,6 @@ const OPPOSITE = {
|
|
|
18
19
|
class NormalizeMixin {
|
|
19
20
|
/**
|
|
20
21
|
* Normalizes the ast by applying {@link GroupNode GroupNodes} and converting {@link ConditionNode ConditionNodes} to {@link NormalizedConditionNode NormalizedConditionNodes}.
|
|
21
|
-
*
|
|
22
|
-
* To do this, a
|
|
23
22
|
*/
|
|
24
23
|
normalize(ast) {
|
|
25
24
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/methods/validate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/methods/validate.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,QAAQ,EAAc,MAAM,iBAAiB,CAAA;AAI/E,qBAAa,aAAa,CAAC,CAAC,SAAS,EAAE;IACtC;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,EAAE;CAqH7E"}
|
package/dist/methods/validate.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { get
|
|
1
|
+
import { get } from "@alanscodelog/utils/get";
|
|
2
|
+
import { isArray } from "@alanscodelog/utils/isArray";
|
|
2
3
|
import { ArrayNode } from "../ast/classes/ArrayNode.js";
|
|
3
4
|
import { ConditionNode } from "../ast/classes/ConditionNode.js";
|
|
4
5
|
import { ErrorToken } from "../ast/classes/ErrorToken.js";
|
package/dist/package.json.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const name = "@witchcraft/expressit";
|
|
2
2
|
const description = "A blazing fast, customizable, error-tolerant expression parser that creates safe to eval expressions + a few other goodies like autocomplete.";
|
|
3
|
-
const version = "0.0.
|
|
3
|
+
const version = "0.0.3";
|
|
4
4
|
const types = "./dist/index.d.ts";
|
|
5
5
|
const type = "module";
|
|
6
6
|
const exports = {
|
|
@@ -12,30 +12,50 @@ const exports = {
|
|
|
12
12
|
types: "./dist/ast/index.d.ts",
|
|
13
13
|
"import": "./dist/ast/index.js"
|
|
14
14
|
},
|
|
15
|
+
"./ast/*": {
|
|
16
|
+
types: "./dist/ast/*",
|
|
17
|
+
"import": "./dist/ast/*"
|
|
18
|
+
},
|
|
15
19
|
"./grammar": {
|
|
16
20
|
types: "./dist/grammar/index.d.ts",
|
|
17
21
|
"import": "./dist/grammar/index.js"
|
|
18
22
|
},
|
|
23
|
+
"./grammar/*": {
|
|
24
|
+
types: "./dist/grammar/*",
|
|
25
|
+
"import": "./dist/grammar/*"
|
|
26
|
+
},
|
|
19
27
|
"./helpers": {
|
|
20
28
|
types: "./dist/helpers/index.d.ts",
|
|
21
29
|
"import": "./dist/helpers/index.js"
|
|
22
30
|
},
|
|
31
|
+
"./helpers/*": {
|
|
32
|
+
types: "./dist/helpers/*",
|
|
33
|
+
"import": "./dist/helpers/*"
|
|
34
|
+
},
|
|
23
35
|
"./methods": {
|
|
24
36
|
types: "./dist/methods/index.d.ts",
|
|
25
37
|
"import": "./dist/methods/index.js"
|
|
26
38
|
},
|
|
27
|
-
"./
|
|
28
|
-
types: "./dist/
|
|
29
|
-
"import": "./dist/
|
|
39
|
+
"./methods/*": {
|
|
40
|
+
types: "./dist/methods/*",
|
|
41
|
+
"import": "./dist/methods/*"
|
|
30
42
|
},
|
|
31
43
|
"./utils": {
|
|
32
44
|
types: "./dist/utils/index.d.ts",
|
|
33
45
|
"import": "./dist/utils/index.js"
|
|
34
46
|
},
|
|
47
|
+
"./utils/*": {
|
|
48
|
+
types: "./dist/utils/*",
|
|
49
|
+
"import": "./dist/utils/*"
|
|
50
|
+
},
|
|
35
51
|
"./examples": {
|
|
36
52
|
types: "./dist/examples/index.d.ts",
|
|
37
53
|
"import": "./dist/examples/index.js"
|
|
38
54
|
},
|
|
55
|
+
"./examples/*": {
|
|
56
|
+
types: "./dist/examples/*",
|
|
57
|
+
"import": "./dist/examples/*"
|
|
58
|
+
},
|
|
39
59
|
"./*": {
|
|
40
60
|
types: "./dist/*",
|
|
41
61
|
"import": "./dist/*"
|
|
@@ -70,7 +90,7 @@ const scripts = {
|
|
|
70
90
|
prepare: "husky install && npm run build"
|
|
71
91
|
};
|
|
72
92
|
const dependencies = {
|
|
73
|
-
"@alanscodelog/utils": "
|
|
93
|
+
"@alanscodelog/utils": "4.0.0-beta.15",
|
|
74
94
|
chevrotain: "^11.0.3"
|
|
75
95
|
};
|
|
76
96
|
const devDependencies = {
|
package/dist/parser.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Docs work like normal (on methods). From the outside, users of the library cannot even tell the class is composed of mixins.
|
|
10
10
|
*/
|
|
11
|
-
import type { Mixin } from "@alanscodelog/utils";
|
|
11
|
+
import type { Mixin } from "@alanscodelog/utils/types";
|
|
12
12
|
import { createTokens } from "./grammar/createTokens.js";
|
|
13
13
|
import { ParserBase } from "./grammar/ParserBase.js";
|
|
14
14
|
import { AutocompleteMixin } from "./methods/autocomplete.js";
|
package/dist/parser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AAItD,OAAO,EAAE,YAAY,EAAE,MAAM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AMhC;;;OAGG;IACH,OAAO,CAAC,IAAI;CAGZ;AAED,MAAM,WAAW,MAAM,CAAC,CAAC,SAAS,EAAE,GAAG,EAAE,CAAE,SAAQ,KAAK,CACrD,iBAAiB,CAAC,CAAC,CAAC,GACpB,gBAAgB,GAChB,WAAW,CAAC,CAAC,CAAC,GACd,aAAa,CAAC,CAAC,CAAC,GAChB,aAAa,CAAC,CAAC,CAAC,GAChB,cAAc,CAAC,CAAC,CAAC,GACjB,aAAa,CAAC,CAAC,CAAC,GAChB,mBAAmB,CACrB,EACA,iBAAiB,CAAC,CAAC,CAAC,EACpB,gBAAgB,EAChB,WAAW,CAAC,CAAC,CAAC,EACd,aAAa,CAAC,CAAC,CAAC,EAChB,aAAa,CAAG,CAAC,CAAE,EACnB,cAAc,CAAC,CAAC,CAAC,EACjB,aAAa,CAAC,CAAC,CAAC,EAChB,mBAAmB;CAClB"}
|
package/dist/parser.js
CHANGED
|
@@ -4,7 +4,8 @@ var __publicField = (obj, key, value) => {
|
|
|
4
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { isWhitespace } from "@alanscodelog/utils/isWhitespace";
|
|
8
|
+
import { mixin } from "@alanscodelog/utils/mixin";
|
|
8
9
|
import { createSyntaxDiagramsCode } from "chevrotain";
|
|
9
10
|
import { token } from "./ast/handlers.js";
|
|
10
11
|
import { createTokens } from "./grammar/createTokens.js";
|
package/dist/types/ast.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AnyFunction } from "@alanscodelog/utils";
|
|
1
|
+
import type { AnyFunction } from "@alanscodelog/utils/types";
|
|
2
2
|
import type { ArrayNode } from "../ast/classes/ArrayNode.js";
|
|
3
3
|
import type { ConditionNode } from "../ast/classes/ConditionNode.js";
|
|
4
4
|
import type { ErrorToken } from "../ast/classes/ErrorToken.js";
|
package/dist/types/ast.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/types/ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/types/ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAGlE,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,WAAW,EAAE,MAAM,SAAS,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,CAAA;AAE9I,oBAAY,UAAU;IACrB,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,EAAE,OAAO;IACT,GAAG,QAAQ;IACX,QAAQ,aAAa;IACrB,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;IAC3B,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,eAAe,gBAAgB;IAC/B,SAAS,cAAc;IACvB,KAAK,UAAU;CACf;AAED;;;GAGG;AACH,MAAM,MAAM,gBAA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U,CAAC,KAAK,CAAC,CAAA;CACpC,CAAA"}
|
package/dist/types/errors.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DeepPartial } from "@alanscodelog/utils";
|
|
1
|
+
import type { DeepPartial } from "@alanscodelog/utils/types";
|
|
2
2
|
import type { ILexingError, IRecognitionException, IToken } from "chevrotain";
|
|
3
3
|
import type { ParserOptions } from "./parser.js";
|
|
4
4
|
export declare enum ERROR_CODES {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAE7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAGhD,oBAAY,WAAW;IACtB,cAAc,iBAAiB;IAC/B,uBAAuB,oBAAoB;IAC3C,kCAAkC,+BAA+B;IACjE,8BAA8B,mCAAmC;CACjE;AACD,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,UAAU,IAAI,UAAU,CAAC,CAAC,CAAC,CAAA;AACjE,MAAM,MAAM,UAAU,GAAG;IACxB,CAAC,WAAW,CAAC,YAAY,CAAC,EAAE;QAC3B,KAAK,EAAE,MAAM,CAAA;QACb,OAAO,EAAE,WAAW,CAAC,aAAa,CAAC,GAAG,SAAS,CAAA;QAE/C,gBAAgB,EAAE,aAAa,CAAA;QAC/B,KAAK,EAAE,KAAK,CAAA;QAEZ,cAAc,EAAE,YAAY,EAAE,CAAA;QAE9B,cAAc,EAAE,MAAM,EAAE,CAAA;QAExB,eAAe,EAAE,qBAAqB,EAAE,CAAA;KACxC,CAAA;IACD,CAAC,WAAW,CAAC,qBAAqB,CAAC,EAAE;QACpC,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,GAAG,CAAC,EAAE,MAAM,CAAA;KACZ,CAAA;IACD,CAAC,WAAW,CAAC,gCAAgC,CAAC,EAAE;QAC/C,UAAU,EAAE,MAAM,EAAE,CAAA;QACpB,OAAO,EAAE,MAAM,CAAA;KACf,CAAA;IACD,CAAC,WAAW,CAAC,4BAA4B,CAAC,EAAE;QAC3C,OAAO,CAAC,EAAE,CAAC,MAAM,aAAa,CAAC,EAAE,CAAA;QACjC,QAAQ,EAAE,MAAM,aAAa,CAAA;KAC7B,CAAA;CACD,CAAA"}
|
package/dist/types/parser.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import type { DeepRequired, MakeRequired } from "@alanscodelog/utils";
|
|
1
|
+
import type { DeepRequired, MakeRequired } from "@alanscodelog/utils/types";
|
|
2
2
|
import type { Position, TOKEN_TYPE } from "./ast.js";
|
|
3
|
-
import type { ArrayNode
|
|
3
|
+
import type { ArrayNode } from "../ast/classes/ArrayNode.js";
|
|
4
|
+
import type { Condition } from "../ast/classes/Condition.js";
|
|
5
|
+
import type { ConditionNode } from "../ast/classes/ConditionNode.js";
|
|
6
|
+
import type { ValidToken } from "../ast/classes/ValidToken.js";
|
|
7
|
+
import type { VariableNode } from "../ast/classes/VariableNode.js";
|
|
4
8
|
export type FullParserOptions<T extends {} = {}> = MakeRequired<ParserOptions<T>, Exclude<keyof ParserOptions<T>, "prefixableStrings" | "expandedPropertySeparator" | "customPropertyOperators" | "keywords">> & {
|
|
5
9
|
keywords: DeepRequired<KeywordOptions>;
|
|
6
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/types/parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,
|
|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CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAA;AACvG,MAAM,MAAM,cAAc,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,GAAG,SAAS,EAAE,KAAK,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,EAAE,GAAG,SAAS,GAAG,IAAI,CAAA;AAEnL,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,EAAE,CAAA;AACjD,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAA;AAExE,MAAM,MAAM,YAAY,GAAG;IAC1B,+CAA+C;IAC/C,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;CACb,CAAA;AACD,MAAM,MAAM,cAAc,GAAG;IAC5B,EAAE,CAAC,EAAE,YAAY,EAAE,CAAA;IACnB,GAAG,CAAC,EAAE,YAAY,EAAE,CAAA;IACpB,GAAG,CAAC,EAAE,YAAY,EAAE,CAAA;CACpB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { unreachable } from "@alanscodelog/utils";
|
|
1
|
+
import { unreachable } from "@alanscodelog/utils/unreachable";
|
|
2
2
|
import { ArrayNode } from "../ast/classes/ArrayNode.js";
|
|
3
3
|
import { ConditionNode } from "../ast/classes/ConditionNode.js";
|
|
4
4
|
import { ErrorToken } from "../ast/classes/ErrorToken.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCursorInfo.d.ts","sourceRoot":"","sources":["../../src/utils/getCursorInfo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getCursorInfo.d.ts","sourceRoot":"","sources":["../../src/utils/getCursorInfo.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAG1D;;GAEG;AACH,wBAAgB,aAAa,CAC5B,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,aAAa,GAAG,QAAQ,EAAE,EAC/B,KAAK,EAAE,MAAM,GACX,UAAU,CAoDZ"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { isArray
|
|
1
|
+
import { isArray } from "@alanscodelog/utils/isArray";
|
|
2
|
+
import { unreachable } from "@alanscodelog/utils/unreachable";
|
|
2
3
|
import { extractTokens } from "./extractTokens.js";
|
|
4
|
+
import "@alanscodelog/utils/crop";
|
|
5
|
+
import "@alanscodelog/utils/indent";
|
|
6
|
+
import "@alanscodelog/utils/pretty";
|
|
3
7
|
import { ValidToken } from "../ast/classes/ValidToken.js";
|
|
4
8
|
import { ErrorToken } from "../ast/classes/ErrorToken.js";
|
|
5
9
|
function getCursorInfo(input, ast, index) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prettyAst.d.ts","sourceRoot":"","sources":["../../src/utils/prettyAst.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prettyAst.d.ts","sourceRoot":"","sources":["../../src/utils/prettyAst.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAA6C,SAAS,EAAc,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACnI,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAc,MAAM,iBAAiB,CAAA;AAG/E,KAAK,MAAM,GAAG;IACb,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAA;IACd,6NAA6N;IAC7N,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,mKAAmK;IACnK,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAA;CACb,CAAA;AAoBD;;;;;;;;;;;;;;;;;GAiBG;AAEH,wBAAgB,SAAS,CACxB,GAAG,EAAE,aAAa,GAAG,QAAQ,GAAG,YAAY,GAAG,SAAS,GAAG,SAAS,EACpE,EAAE,MAAc,EAAE,QAAe,EAAE,IAAW,EAAE,MAAY,EAAE,KAAU,EAAE,GAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,EAAE,MAAM,CAAC,CAAM,EAC7J,MAAM,GAAE,OAAO,CAAC,MAAM,CAAC,GAAG,KAAU,GAClC,MAAM,CAyFR"}
|
package/dist/utils/prettyAst.js
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as color from "@alanscodelog/utils/colors";
|
|
2
|
+
import { isBlank } from "@alanscodelog/utils/isBlank";
|
|
3
|
+
import { unreachable } from "@alanscodelog/utils/unreachable";
|
|
2
4
|
import { ArrayNode } from "../ast/classes/ArrayNode.js";
|
|
3
5
|
import { ConditionNode } from "../ast/classes/ConditionNode.js";
|
|
4
6
|
import { ErrorToken } from "../ast/classes/ErrorToken.js";
|
|
5
7
|
import { ExpressionNode } from "../ast/classes/ExpressionNode.js";
|
|
6
8
|
import { GroupNode } from "../ast/classes/GroupNode.js";
|
|
9
|
+
import "@alanscodelog/utils/crop";
|
|
10
|
+
import "@alanscodelog/utils/indent";
|
|
11
|
+
import "@alanscodelog/utils/pretty";
|
|
7
12
|
import { ValidToken } from "../ast/classes/ValidToken.js";
|
|
8
13
|
import { VariableNode } from "../ast/classes/VariableNode.js";
|
|
9
14
|
import { TOKEN_TYPE } from "../types/ast.js";
|
|
10
15
|
const defaultColors = {
|
|
11
|
-
values:
|
|
12
|
-
info:
|
|
13
|
-
position:
|
|
14
|
-
hint:
|
|
15
|
-
error:
|
|
16
|
-
reset:
|
|
16
|
+
values: color.yellow,
|
|
17
|
+
info: color.cyan,
|
|
18
|
+
position: color.green,
|
|
19
|
+
hint: color.blue,
|
|
20
|
+
error: color.red,
|
|
21
|
+
reset: color.reset
|
|
17
22
|
};
|
|
18
23
|
const disableColors = Object.fromEntries(Object.keys(defaultColors).map((key) => [key, ""]));
|
|
19
24
|
const toRows = (rows, opts) => {
|
|
@@ -23,10 +28,10 @@ const toRows = (rows, opts) => {
|
|
|
23
28
|
`${opts.indent}${opts.last}${rows[rows.length - 1]}`
|
|
24
29
|
];
|
|
25
30
|
};
|
|
26
|
-
function prettyAst(ast, { indent = " ", children = "├╴", last = "└╴", branch = "│", quote = "" } = {},
|
|
31
|
+
function prettyAst(ast, { indent = " ", children = "├╴", last = "└╴", branch = "│", quote = "" } = {}, colors = {}) {
|
|
27
32
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
28
33
|
const opts = { indent, children, last, branch, quote };
|
|
29
|
-
const c =
|
|
34
|
+
const c = colors ? { ...defaultColors, ...colors } : disableColors;
|
|
30
35
|
const pos = `${c.position}(${ast.start}, ${ast.end})${c.reset}`;
|
|
31
36
|
const _ = indent;
|
|
32
37
|
const __ = arguments[3] ?? "";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@witchcraft/expressit",
|
|
3
3
|
"description": "A blazing fast, customizable, error-tolerant expression parser that creates safe to eval expressions + a few other goodies like autocomplete.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.3",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
@@ -13,30 +13,50 @@
|
|
|
13
13
|
"types": "./dist/ast/index.d.ts",
|
|
14
14
|
"import": "./dist/ast/index.js"
|
|
15
15
|
},
|
|
16
|
+
"./ast/*": {
|
|
17
|
+
"types": "./dist/ast/*",
|
|
18
|
+
"import": "./dist/ast/*"
|
|
19
|
+
},
|
|
16
20
|
"./grammar": {
|
|
17
21
|
"types": "./dist/grammar/index.d.ts",
|
|
18
22
|
"import": "./dist/grammar/index.js"
|
|
19
23
|
},
|
|
24
|
+
"./grammar/*": {
|
|
25
|
+
"types": "./dist/grammar/*",
|
|
26
|
+
"import": "./dist/grammar/*"
|
|
27
|
+
},
|
|
20
28
|
"./helpers": {
|
|
21
29
|
"types": "./dist/helpers/index.d.ts",
|
|
22
30
|
"import": "./dist/helpers/index.js"
|
|
23
31
|
},
|
|
32
|
+
"./helpers/*": {
|
|
33
|
+
"types": "./dist/helpers/*",
|
|
34
|
+
"import": "./dist/helpers/*"
|
|
35
|
+
},
|
|
24
36
|
"./methods": {
|
|
25
37
|
"types": "./dist/methods/index.d.ts",
|
|
26
38
|
"import": "./dist/methods/index.js"
|
|
27
39
|
},
|
|
28
|
-
"./
|
|
29
|
-
"types": "./dist/
|
|
30
|
-
"import": "./dist/
|
|
40
|
+
"./methods/*": {
|
|
41
|
+
"types": "./dist/methods/*",
|
|
42
|
+
"import": "./dist/methods/*"
|
|
31
43
|
},
|
|
32
44
|
"./utils": {
|
|
33
45
|
"types": "./dist/utils/index.d.ts",
|
|
34
46
|
"import": "./dist/utils/index.js"
|
|
35
47
|
},
|
|
48
|
+
"./utils/*": {
|
|
49
|
+
"types": "./dist/utils/*",
|
|
50
|
+
"import": "./dist/utils/*"
|
|
51
|
+
},
|
|
36
52
|
"./examples": {
|
|
37
53
|
"types": "./dist/examples/index.d.ts",
|
|
38
54
|
"import": "./dist/examples/index.js"
|
|
39
55
|
},
|
|
56
|
+
"./examples/*": {
|
|
57
|
+
"types": "./dist/examples/*",
|
|
58
|
+
"import": "./dist/examples/*"
|
|
59
|
+
},
|
|
40
60
|
"./*": {
|
|
41
61
|
"types": "./dist/*",
|
|
42
62
|
"import": "./dist/*"
|
|
@@ -71,7 +91,7 @@
|
|
|
71
91
|
"prepare": "husky install && npm run build"
|
|
72
92
|
},
|
|
73
93
|
"dependencies": {
|
|
74
|
-
"@alanscodelog/utils": "
|
|
94
|
+
"@alanscodelog/utils": "4.0.0-beta.15",
|
|
75
95
|
"chevrotain": "^11.0.3"
|
|
76
96
|
},
|
|
77
97
|
"devDependencies": {
|
package/src/ast/classes/index.ts
CHANGED
package/src/ast/index.ts
CHANGED
|
@@ -43,11 +43,11 @@ export class ShortcutContextParser<T extends
|
|
|
43
43
|
}
|
|
44
44
|
return prefix + variable
|
|
45
45
|
},
|
|
46
|
-
valueComparer: (
|
|
47
|
-
if (
|
|
48
|
-
return contextValue.match(
|
|
46
|
+
valueComparer: (condition, contextValue, _context) => {
|
|
47
|
+
if (condition.value instanceof RegExp) {
|
|
48
|
+
return contextValue.match(condition.value) !== null
|
|
49
49
|
}
|
|
50
|
-
return contextValue ===
|
|
50
|
+
return contextValue === condition.value
|
|
51
51
|
},
|
|
52
52
|
valueValidator: (_contextValue, query): T[] | void => {
|
|
53
53
|
let tokens: T[] = []
|
|
@@ -123,6 +123,11 @@ export class ShortcutContextParser<T extends
|
|
|
123
123
|
this._extractKeysFromContext(dummyContext)
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
setContext(context: Record<string, any>): void {
|
|
127
|
+
this.validKeys = []
|
|
128
|
+
this._extractKeysFromContext(context)
|
|
129
|
+
}
|
|
130
|
+
|
|
126
131
|
private _extractKeysFromContext(context: Record<string, any>, prev?: string): void {
|
|
127
132
|
for (const key of Object.keys(context)) {
|
|
128
133
|
if (typeof context[key] === "boolean") {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
2
|
|
|
3
|
-
import { isArray
|
|
3
|
+
import { isArray } from "@alanscodelog/utils/isArray"
|
|
4
|
+
import { unreachable } from "@alanscodelog/utils/unreachable"
|
|
4
5
|
import { EmbeddedActionsParser, EOF, type IToken, tokenMatcher } from "chevrotain"
|
|
5
6
|
|
|
6
7
|
import type { createTokens } from "./createTokens.js"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable camelcase */
|
|
2
|
-
import { escapeRegex
|
|
2
|
+
import { escapeRegex } from "@alanscodelog/utils/escapeRegex"
|
|
3
|
+
import { isBlank } from "@alanscodelog/utils/isBlank"
|
|
3
4
|
import { createToken, Lexer, type TokenType } from "chevrotain"
|
|
4
5
|
|
|
5
6
|
import type { FullParserOptions } from "../types/parser.js"
|
package/src/helpers/errors.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { crop } from "@alanscodelog/utils/crop"
|
|
2
|
+
import { indent } from "@alanscodelog/utils/indent"
|
|
3
|
+
import { pretty } from "@alanscodelog/utils/pretty"
|
|
4
|
+
import type { Keys } from "@alanscodelog/utils/types"
|
|
3
5
|
|
|
4
6
|
// @ts-expect-error todo
|
|
5
7
|
import { repository, version } from "../package.js"
|
package/src/helpers/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { isBlank
|
|
1
|
+
import { isBlank } from "@alanscodelog/utils/isBlank"
|
|
2
|
+
import { pushIfNotIn } from "@alanscodelog/utils/pushIfNotIn"
|
|
2
3
|
|
|
3
4
|
import { ERROR_CODES } from "../../types/errors.js"
|
|
4
5
|
import type { FullParserOptions, ParserOptions } from "../../types/parser.js"
|
|
@@ -19,7 +20,7 @@ export function checkParserOpts<T extends {}>(opts: FullParserOptions<T>, evalua
|
|
|
19
20
|
]
|
|
20
21
|
const extra: string[] = []
|
|
21
22
|
if (opts.expandedPropertySeparator) extra.push(opts.expandedPropertySeparator)
|
|
22
|
-
if (opts.customPropertyOperators) pushIfNotIn(extra,
|
|
23
|
+
if (opts.customPropertyOperators) pushIfNotIn(extra, opts.customPropertyOperators)
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
/* #region Blank Operator Checks */
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DeepPartial } from "@alanscodelog/utils"
|
|
2
|
-
import { unreachable } from "@alanscodelog/utils"
|
|
1
|
+
import type { DeepPartial } from "@alanscodelog/utils/types"
|
|
2
|
+
import { unreachable } from "@alanscodelog/utils/unreachable"
|
|
3
3
|
|
|
4
4
|
import { pos } from "../ast/builders/pos.js"
|
|
5
5
|
import { ArrayNode } from "../ast/classes/ArrayNode.js"
|
package/src/methods/evaluate.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { get } from "@alanscodelog/utils/get"
|
|
2
|
+
import { type AddParameters } from "@alanscodelog/utils/types"
|
|
3
|
+
import { unreachable } from "@alanscodelog/utils/unreachable"
|
|
2
4
|
|
|
3
5
|
import { Condition } from "../ast/classes/Condition.js"
|
|
4
6
|
import { Expression } from "../ast/classes/Expression.js"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-labels */
|
|
2
2
|
|
|
3
|
-
import { type AddParameters
|
|
3
|
+
import { type AddParameters } from "@alanscodelog/utils/types"
|
|
4
|
+
import { unreachable } from "@alanscodelog/utils/unreachable"
|
|
4
5
|
|
|
5
6
|
import { Condition } from "../ast/classes/Condition.js"
|
|
6
7
|
import { Expression } from "../ast/classes/Expression.js"
|
package/src/methods/normalize.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type AddParameters
|
|
1
|
+
import { type AddParameters } from "@alanscodelog/utils/types"
|
|
2
|
+
import { unreachable } from "@alanscodelog/utils/unreachable"
|
|
2
3
|
|
|
3
4
|
import { ArrayNode } from "../ast/classes/ArrayNode.js"
|
|
4
5
|
import { Condition } from "../ast/classes/Condition.js"
|
|
@@ -24,8 +25,6 @@ const OPPOSITE = {
|
|
|
24
25
|
export class NormalizeMixin<T extends {}> {
|
|
25
26
|
/**
|
|
26
27
|
* Normalizes the ast by applying {@link GroupNode GroupNodes} and converting {@link ConditionNode ConditionNodes} to {@link NormalizedConditionNode NormalizedConditionNodes}.
|
|
27
|
-
*
|
|
28
|
-
* To do this, a
|
|
29
28
|
*/
|
|
30
29
|
normalize<TType extends string, TValue>(ast: ParserResults): Condition<TType, TValue> | Expression<TType, TValue> {
|
|
31
30
|
// @ts-expect-error private method
|
package/src/methods/validate.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { get } from "@alanscodelog/utils/get"
|
|
2
|
+
import { isArray } from "@alanscodelog/utils/isArray"
|
|
3
|
+
import { type AddParameters } from "@alanscodelog/utils/types"
|
|
2
4
|
|
|
3
5
|
import { ArrayNode } from "../ast/classes/ArrayNode.js"
|
|
4
6
|
import { ConditionNode } from "../ast/classes/ConditionNode.js"
|
package/src/parser.ts
CHANGED
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
* Docs work like normal (on methods). From the outside, users of the library cannot even tell the class is composed of mixins.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
12
|
+
import { isWhitespace } from "@alanscodelog/utils/isWhitespace"
|
|
13
|
+
import { mixin } from "@alanscodelog/utils/mixin"
|
|
14
|
+
import type { Mixin } from "@alanscodelog/utils/types"
|
|
14
15
|
import { createSyntaxDiagramsCode, type ILexingResult, type Lexer } from "chevrotain"
|
|
15
16
|
|
|
16
17
|
import { token as tokenHandler } from "./ast/handlers.js"
|
package/src/types/ast.ts
CHANGED
package/src/types/errors.ts
CHANGED
package/src/types/parser.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type { DeepRequired, MakeRequired } from "@alanscodelog/utils"
|
|
1
|
+
import type { DeepRequired, MakeRequired } from "@alanscodelog/utils/types"
|
|
2
2
|
|
|
3
3
|
import type { Position, TOKEN_TYPE } from "./ast.js"
|
|
4
4
|
|
|
5
|
-
import type { ArrayNode
|
|
6
|
-
|
|
5
|
+
import type { ArrayNode } from "../ast/classes/ArrayNode.js"
|
|
6
|
+
import type { Condition } from "../ast/classes/Condition.js"
|
|
7
|
+
import type { ConditionNode } from "../ast/classes/ConditionNode.js"
|
|
8
|
+
import type { ValidToken } from "../ast/classes/ValidToken.js"
|
|
9
|
+
import type { VariableNode } from "../ast/classes/VariableNode.js"
|
|
7
10
|
|
|
8
11
|
// #partially-synced
|
|
9
12
|
export type FullParserOptions<T extends {} = {}> = MakeRequired<
|
package/src/utils/prettyAst.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/* eslint-disable prefer-rest-params */
|
|
2
|
-
import
|
|
3
|
-
import { isBlank
|
|
2
|
+
import * as color from "@alanscodelog/utils/colors"
|
|
3
|
+
import { isBlank } from "@alanscodelog/utils/isBlank"
|
|
4
|
+
import { type AddParameters } from "@alanscodelog/utils/types"
|
|
5
|
+
import { unreachable } from "@alanscodelog/utils/unreachable"
|
|
4
6
|
|
|
5
7
|
import { ArrayNode, ConditionNode, ErrorToken, ExpressionNode, GroupNode, ValidToken, VariableNode } from "../ast/classes/index.js"
|
|
6
8
|
import { type AnyToken, type ParserResults, TOKEN_TYPE } from "../types/ast.js"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"advancedValueComparer.d.ts","sourceRoot":"","sources":["../../src/examples/advancedValueComparer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAKpD,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,UAAU,GAAG,OAAO,CAyBzH"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
function valueComparer(contextValue, { operator, prefix, value, isRegex, regexFlags }) {
|
|
2
|
-
let finalValue = value;
|
|
3
|
-
if (prefix) {
|
|
4
|
-
const val = value;
|
|
5
|
-
switch (prefix) {
|
|
6
|
-
case "num":
|
|
7
|
-
finalValue = parseInt(val, 2);
|
|
8
|
-
break;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
if (isRegex) {
|
|
12
|
-
const val = value;
|
|
13
|
-
const regex = new RegExp(val, regexFlags);
|
|
14
|
-
return contextValue.match(regex) !== null;
|
|
15
|
-
}
|
|
16
|
-
if (operator) {
|
|
17
|
-
switch (operator) {
|
|
18
|
-
case ">":
|
|
19
|
-
return contextValue > finalValue;
|
|
20
|
-
case "contains":
|
|
21
|
-
return contextValue.includes(finalValue);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return contextValue === finalValue;
|
|
25
|
-
}
|
|
26
|
-
export {
|
|
27
|
-
valueComparer
|
|
28
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { ValueQuery } from "../types/parser.js"
|
|
2
|
-
|
|
3
|
-
/* TODO TOUPDATE */
|
|
4
|
-
type Operators = ">" | "contains"
|
|
5
|
-
type Prefixes = "num"
|
|
6
|
-
export function valueComparer(contextValue: string, { operator, prefix, value, isRegex, regexFlags }: ValueQuery): boolean {
|
|
7
|
-
let finalValue: any = value
|
|
8
|
-
if (prefix) {
|
|
9
|
-
const val = value as string // it's always a string if prefixed
|
|
10
|
-
switch (prefix as Prefixes) {
|
|
11
|
-
case "num": finalValue = parseInt(val, 2); break
|
|
12
|
-
// ...
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
if (isRegex) {
|
|
16
|
-
const val = value as string // it's always a string and never prefixed if it's a regex
|
|
17
|
-
const regex = new RegExp(val, regexFlags)
|
|
18
|
-
return contextValue.match(regex) !== null
|
|
19
|
-
}
|
|
20
|
-
if (operator) {
|
|
21
|
-
switch (operator as Operators) {
|
|
22
|
-
// custom operators
|
|
23
|
-
case ">": return contextValue > finalValue
|
|
24
|
-
// ...
|
|
25
|
-
// custom expanded operators
|
|
26
|
-
case "contains": return contextValue.includes(finalValue)
|
|
27
|
-
// ...
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return contextValue === finalValue
|
|
31
|
-
}
|