@witchcraft/expressit 0.0.2 → 0.1.0
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 +6 -4
- package/dist/Lexer.d.ts +146 -0
- package/dist/Lexer.d.ts.map +1 -0
- package/dist/Lexer.js +960 -0
- package/dist/Parser.d.ts +140 -0
- package/dist/Parser.d.ts.map +1 -0
- package/dist/Parser.js +668 -0
- package/dist/ast/builders/token.js +1 -1
- package/dist/ast/handlers.d.ts +3 -3
- package/dist/ast/handlers.d.ts.map +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 +2 -1
- package/dist/examples/shortcutContextParser.d.ts.map +1 -1
- package/dist/examples/shortcutContextParser.js +9 -5
- 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/helpers/parser/extractPosition.d.ts +2 -6
- package/dist/helpers/parser/extractPosition.d.ts.map +1 -1
- package/dist/helpers/parser/extractPosition.js +3 -3
- package/dist/helpers/parser/getUnclosedRightParenCount.d.ts +2 -3
- package/dist/helpers/parser/getUnclosedRightParenCount.d.ts.map +1 -1
- package/dist/helpers/parser/getUnclosedRightParenCount.js +4 -4
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -5
- package/dist/methods/autocomplete.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 +3 -1
- package/dist/package.json.js +44 -37
- package/dist/types/ast.d.ts +2 -8
- package/dist/types/ast.d.ts.map +1 -1
- package/dist/types/errors.d.ts +5 -17
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +0 -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 +2 -2
- package/dist/utils/getCursorInfo.d.ts.map +1 -1
- package/dist/utils/getCursorInfo.js +3 -2
- package/dist/utils/getOppositeDelimiter.d.ts.map +1 -1
- package/dist/utils/getOppositeDelimiter.js +1 -1
- package/dist/utils/prettyAst.d.ts.map +1 -1
- package/dist/utils/prettyAst.js +15 -9
- package/package.json +42 -37
- package/src/Lexer.ts +704 -0
- package/src/Parser.ts +972 -0
- package/src/ast/builders/array.ts +2 -2
- package/src/ast/builders/condition.ts +1 -1
- package/src/ast/builders/expression.ts +1 -1
- package/src/ast/builders/group.ts +1 -1
- package/src/ast/builders/index.ts +1 -1
- package/src/ast/builders/pos.ts +1 -1
- package/src/ast/builders/token.ts +2 -2
- package/src/ast/builders/type.ts +1 -1
- package/src/ast/builders/variable.ts +1 -1
- package/src/ast/classes/ConditionNode.ts +1 -1
- package/src/ast/classes/ErrorToken.ts +1 -1
- package/src/ast/classes/ValidToken.ts +2 -2
- package/src/ast/classes/index.ts +1 -1
- package/src/ast/handlers.ts +6 -6
- package/src/ast/index.ts +2 -2
- package/src/examples/index.ts +3 -0
- package/src/examples/shortcutContextParser.ts +11 -6
- package/src/helpers/errors.ts +5 -3
- package/src/helpers/general/defaultConditionNormalizer.ts +1 -1
- package/src/helpers/general/index.ts +1 -1
- package/src/helpers/index.ts +3 -2
- package/src/helpers/parser/checkParserOpts.ts +13 -12
- package/src/helpers/parser/extractPosition.ts +4 -8
- package/src/helpers/parser/getUnclosedRightParenCount.ts +6 -6
- package/src/helpers/parser/index.ts +1 -1
- package/src/helpers/parser/parseParserOptions.ts +1 -1
- package/src/index.ts +2 -2
- package/src/methods/autocomplete.ts +5 -5
- package/src/methods/autoreplace.ts +2 -2
- package/src/methods/autosuggest.ts +3 -3
- package/src/methods/evaluate.ts +4 -2
- package/src/methods/getIndexes.ts +2 -1
- package/src/methods/normalize.ts +3 -4
- package/src/methods/validate.ts +4 -2
- package/src/types/ast.ts +2 -9
- package/src/types/errors.ts +12 -22
- package/src/types/parser.ts +6 -4
- package/src/utils/extractTokens.ts +1 -1
- package/src/utils/getCursorInfo.ts +6 -4
- package/src/utils/getOppositeDelimiter.ts +5 -2
- package/src/utils/prettyAst.ts +5 -3
- 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/dist/grammar/ParserBase.d.ts +0 -51
- package/dist/grammar/ParserBase.d.ts.map +0 -1
- package/dist/grammar/ParserBase.js +0 -516
- package/dist/grammar/createTokens.d.ts +0 -56
- package/dist/grammar/createTokens.d.ts.map +0 -1
- package/dist/grammar/createTokens.js +0 -843
- package/dist/grammar/index.d.ts +0 -3
- package/dist/grammar/index.d.ts.map +0 -1
- package/dist/grammar/index.js +0 -6
- package/dist/parser.d.ts +0 -58
- package/dist/parser.d.ts.map +0 -1
- package/dist/parser.js +0 -136
- package/src/examples/advancedValueComparer.ts +0 -31
- package/src/grammar/ParserBase.ts +0 -715
- package/src/grammar/createTokens.ts +0 -512
- package/src/grammar/index.ts +0 -4
- package/src/parser.ts +0 -183
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/ast/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,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"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"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* The validate function will return a list of positions with a list of errors which includes handling invalid or duplicate regex flags.
|
|
9
9
|
*/
|
|
10
|
-
import { Parser } from "../
|
|
10
|
+
import { Parser } from "../Parser.js";
|
|
11
11
|
import type { Position } from "../types/ast.js";
|
|
12
12
|
export declare class ShortcutContextParser<T extends Position & {
|
|
13
13
|
type: ("invalidKey" | "unregexableKey" | "invalidRegexFlag" | "duplicateRegexFlag");
|
|
@@ -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,C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O,CAAC,uBAAuB;CAa/B"}
|
|
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
|
-
import { Parser } from "../
|
|
7
|
+
import { Parser } from "../Parser.js";
|
|
8
8
|
class ShortcutContextParser extends Parser {
|
|
9
9
|
constructor(dummyContext, validRegexFlags = ["i", "u", "m"]) {
|
|
10
10
|
super({
|
|
@@ -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":"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,
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
+
import type { Token } from "../../Lexer.js";
|
|
1
2
|
import type { Position } from "../../types/ast.js";
|
|
2
|
-
type ChevrotainLocation = {
|
|
3
|
-
startOffset?: number;
|
|
4
|
-
endOffset?: number;
|
|
5
|
-
};
|
|
6
3
|
/** @internal */
|
|
7
|
-
export declare function extractPosition(
|
|
8
|
-
export {};
|
|
4
|
+
export declare function extractPosition(pos: Pick<Token, "startOffset" | "endOffset">, shift: number): Position;
|
|
9
5
|
//# sourceMappingURL=extractPosition.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractPosition.d.ts","sourceRoot":"","sources":["../../../src/helpers/parser/extractPosition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"extractPosition.d.ts","sourceRoot":"","sources":["../../../src/helpers/parser/extractPosition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAGlD,gBAAgB;AAChB,wBAAgB,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,aAAa,GAAG,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,CAKtG"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
function extractPosition(
|
|
1
|
+
function extractPosition(pos, shift) {
|
|
2
2
|
return {
|
|
3
|
-
start:
|
|
4
|
-
end:
|
|
3
|
+
start: pos.startOffset - (shift ?? 0),
|
|
4
|
+
end: pos.endOffset + 1 - (shift ?? 0)
|
|
5
5
|
};
|
|
6
6
|
}
|
|
7
7
|
export {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type { createTokens } from "../../grammar/createTokens.js";
|
|
1
|
+
import { type Token } from "../../Lexer.js";
|
|
3
2
|
/** @internal */
|
|
4
|
-
export declare function getUnclosedRightParenCount(tokens:
|
|
3
|
+
export declare function getUnclosedRightParenCount(tokens: Token[]): number;
|
|
5
4
|
//# sourceMappingURL=getUnclosedRightParenCount.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUnclosedRightParenCount.d.ts","sourceRoot":"","sources":["../../../src/helpers/parser/getUnclosedRightParenCount.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"getUnclosedRightParenCount.d.ts","sourceRoot":"","sources":["../../../src/helpers/parser/getUnclosedRightParenCount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAG/C,gBAAgB;AAGhB,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAelE"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
function getUnclosedRightParenCount(tokens
|
|
1
|
+
import { $T } from "../../Lexer.js";
|
|
2
|
+
function getUnclosedRightParenCount(tokens) {
|
|
3
3
|
let open = 0;
|
|
4
4
|
let unclosed = 0;
|
|
5
5
|
for (const token of tokens) {
|
|
6
|
-
if (
|
|
6
|
+
if (token.type === $T.PAREN_R) {
|
|
7
7
|
if (open > 0) {
|
|
8
8
|
open--;
|
|
9
9
|
} else {
|
|
10
10
|
unclosed++;
|
|
11
11
|
}
|
|
12
|
-
} else if (
|
|
12
|
+
} else if (token.type === $T.PAREN_L) {
|
|
13
13
|
open++;
|
|
14
14
|
}
|
|
15
15
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * as ast from "./ast/classes/index.js";
|
|
2
|
-
export
|
|
3
|
-
export { Parser } from "./parser.js";
|
|
2
|
+
export { Parser } from "./Parser.js";
|
|
4
3
|
export * from "./types/index.js";
|
|
5
4
|
export * as utils from "./utils/index.js";
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
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,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,cAAc,kBAAkB,CAAA;AAChC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as index from "./ast/classes/index.js";
|
|
2
|
-
import
|
|
3
|
-
import { Parser } from "./parser.js";
|
|
2
|
+
import { Parser } from "./Parser.js";
|
|
4
3
|
import { AST_TYPE, TOKEN_TYPE } from "./types/ast.js";
|
|
5
4
|
import { SUGGESTION_TYPE } from "./types/autocomplete.js";
|
|
6
5
|
import { ERROR_CODES } from "./types/errors.js";
|
|
7
|
-
import * as index$
|
|
6
|
+
import * as index$1 from "./utils/index.js";
|
|
8
7
|
export {
|
|
9
8
|
AST_TYPE,
|
|
10
9
|
ERROR_CODES,
|
|
@@ -12,6 +11,5 @@ export {
|
|
|
12
11
|
SUGGESTION_TYPE,
|
|
13
12
|
TOKEN_TYPE,
|
|
14
13
|
index as ast,
|
|
15
|
-
index$1 as
|
|
16
|
-
index$2 as utils
|
|
14
|
+
index$1 as utils
|
|
17
15
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../src/methods/autocomplete.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAmB,MAAM,0BAA0B,CAAA;AAC5F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAG3D,qBAAa,iBAAiB,CAAC,CAAC,SAAS,EAAE;IAC1C;;;;;;;;OAQG;IACH,YAAY,CACX,WAAW,EAAE,UAAU,EAAE,EACzB,EACC,MAAW,EAAE,WAAgB,EAAE,SAAc,EAAE,QAAa,EAAE,UAAe,EAAE,yBAA8B,EAAE,uBAA0F,EAAE,QAAsD,EAAE,UAA4B,EAAE,KAAY,GAC7S,GAAE,OAAO,CAAC,MAAM,CAChB,WAAW,GACX,QAAQ,GACR,aAAa,GACb,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,2BAA2B,GAC3B,yBAAyB,EAAE,MAAM,EAAE,CAAC,CAAC,GAAG;
|
|
1
|
+
{"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../src/methods/autocomplete.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAmB,MAAM,0BAA0B,CAAA;AAC5F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAG3D,qBAAa,iBAAiB,CAAC,CAAC,SAAS,EAAE;IAC1C;;;;;;;;OAQG;IACH,YAAY,CACX,WAAW,EAAE,UAAU,EAAE,EACzB,EACC,MAAW,EAAE,WAAgB,EAAE,SAAc,EAAE,QAAa,EAAE,UAAe,EAAE,yBAA8B,EAAE,uBAA0F,EAAE,QAAsD,EAAE,UAA4B,EAAE,KAAY,GAC7S,GAAE,OAAO,CAAC,MAAM,CAChB,WAAW,GACX,QAAQ,GACR,aAAa,GACb,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,2BAA2B,GAC3B,yBAAyB,EAAE,MAAM,EAAE,CAAC,CAAC,GAAG;QACvC,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,QAAQ,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA;KACtC,GACL,UAAU,EAAE;CA4Ff"}
|
|
@@ -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,6 @@
|
|
|
1
|
-
import { get
|
|
1
|
+
import { get } from "@alanscodelog/utils/get";
|
|
2
|
+
import { isArray } from "@alanscodelog/utils/isArray";
|
|
3
|
+
import "@alanscodelog/utils/types";
|
|
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";
|
package/dist/package.json.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
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.1.0";
|
|
4
4
|
const types = "./dist/index.d.ts";
|
|
5
5
|
const type = "module";
|
|
6
|
+
const module = "./dist/index.js";
|
|
6
7
|
const exports = {
|
|
7
8
|
".": {
|
|
8
9
|
types: "./dist/index.d.ts",
|
|
@@ -12,33 +13,45 @@ const exports = {
|
|
|
12
13
|
types: "./dist/ast/index.d.ts",
|
|
13
14
|
"import": "./dist/ast/index.js"
|
|
14
15
|
},
|
|
15
|
-
"./
|
|
16
|
-
types: "./dist/
|
|
17
|
-
"import": "./dist/
|
|
16
|
+
"./ast/*": {
|
|
17
|
+
types: "./dist/ast/*",
|
|
18
|
+
"import": "./dist/ast/*"
|
|
18
19
|
},
|
|
19
20
|
"./helpers": {
|
|
20
21
|
types: "./dist/helpers/index.d.ts",
|
|
21
22
|
"import": "./dist/helpers/index.js"
|
|
22
23
|
},
|
|
24
|
+
"./helpers/*": {
|
|
25
|
+
types: "./dist/helpers/*",
|
|
26
|
+
"import": "./dist/helpers/*"
|
|
27
|
+
},
|
|
23
28
|
"./methods": {
|
|
24
29
|
types: "./dist/methods/index.d.ts",
|
|
25
30
|
"import": "./dist/methods/index.js"
|
|
26
31
|
},
|
|
27
|
-
"./
|
|
28
|
-
types: "./dist/
|
|
29
|
-
"import": "./dist/
|
|
32
|
+
"./methods/*": {
|
|
33
|
+
types: "./dist/methods/*",
|
|
34
|
+
"import": "./dist/methods/*"
|
|
30
35
|
},
|
|
31
36
|
"./utils": {
|
|
32
37
|
types: "./dist/utils/index.d.ts",
|
|
33
38
|
"import": "./dist/utils/index.js"
|
|
34
39
|
},
|
|
40
|
+
"./utils/*": {
|
|
41
|
+
types: "./dist/utils/*",
|
|
42
|
+
"import": "./dist/utils/*"
|
|
43
|
+
},
|
|
35
44
|
"./examples": {
|
|
36
45
|
types: "./dist/examples/index.d.ts",
|
|
37
46
|
"import": "./dist/examples/index.js"
|
|
38
47
|
},
|
|
48
|
+
"./examples/*": {
|
|
49
|
+
types: "./dist/examples/*",
|
|
50
|
+
"import": "./dist/examples/*"
|
|
51
|
+
},
|
|
39
52
|
"./*": {
|
|
40
|
-
types: "./dist/*",
|
|
41
|
-
"import": "./dist/*"
|
|
53
|
+
types: "./dist/types/*",
|
|
54
|
+
"import": "./dist/types/*"
|
|
42
55
|
}
|
|
43
56
|
};
|
|
44
57
|
const scripts = {
|
|
@@ -48,15 +61,15 @@ const scripts = {
|
|
|
48
61
|
"build:watch": "vite build --watch --mode production",
|
|
49
62
|
"build:types": "tsc --emitDeclarationOnly -p tsconfig.types.json && npm run build:types:fix",
|
|
50
63
|
"build:types:fix": "tsc-alias -p tsconfig.types.json --debug",
|
|
51
|
-
"lint:eslint": 'eslint "{src,tests,bin}/**/*.{cjs,js,ts}" "*.{cjs,js,ts}" --max-warnings=
|
|
64
|
+
"lint:eslint": 'eslint "{src,tests,bin}/**/*.{cjs,js,ts}" "*.{cjs,js,ts}" --max-warnings=1 --report-unused-disable-directives',
|
|
52
65
|
"lint:types": "tsc --noEmit --pretty",
|
|
53
66
|
"lint:commits": "commitlint --from $(git rev-list --max-parents=0 HEAD) --to HEAD --verbose",
|
|
54
67
|
"lint:imports": "madge --circular --extensions ts ./src",
|
|
55
68
|
lint: "npm run lint:types && npm run lint:eslint",
|
|
56
|
-
coverage: "vitest --coverage",
|
|
57
|
-
"coverage:dev": "vitest --watch --coverage",
|
|
58
|
-
test: "npm run lint:types && vitest run",
|
|
59
|
-
"test:watch": "vitest --watch",
|
|
69
|
+
coverage: "vitest --exclude '.direnv/**/*' --coverage",
|
|
70
|
+
"coverage:dev": "vitest --exclude '.direnv/**/*' --watch --coverage",
|
|
71
|
+
test: "npm run lint:types && vitest run --exclude '.direnv/**/*'",
|
|
72
|
+
"test:watch": "vitest --watch --exclude '.direnv/**/*'",
|
|
60
73
|
"test:inspect-errors": "cross-env INSPECT_ERRORS=true npm run test",
|
|
61
74
|
doc: "typedoc --options typedoc.config.cjs",
|
|
62
75
|
"doc:watch": 'onchange -i "src/**/*.ts" "typedoc.config.cjs" -- npm run doc',
|
|
@@ -67,45 +80,37 @@ const scripts = {
|
|
|
67
80
|
"demo:build": "cd demo && npm run build",
|
|
68
81
|
"actions:debug": "act -r -v -j build",
|
|
69
82
|
"gen:exports": "indexit update -o '${path}.js' -i **/*.d.ts",
|
|
70
|
-
prepare: "husky
|
|
83
|
+
prepare: "husky && npm run build"
|
|
71
84
|
};
|
|
72
85
|
const dependencies = {
|
|
73
|
-
"@alanscodelog/utils": "
|
|
74
|
-
chevrotain: "^11.0.3"
|
|
86
|
+
"@alanscodelog/utils": "4.0.0-beta.15"
|
|
75
87
|
};
|
|
76
88
|
const devDependencies = {
|
|
77
|
-
"@alanscodelog/commitlint-config": "^
|
|
78
|
-
"@alanscodelog/eslint-config": "
|
|
79
|
-
"@alanscodelog/semantic-release-config": "^
|
|
80
|
-
"@alanscodelog/tsconfigs": "^
|
|
89
|
+
"@alanscodelog/commitlint-config": "^3.0.1",
|
|
90
|
+
"@alanscodelog/eslint-config": "5.0.0-beta.2",
|
|
91
|
+
"@alanscodelog/semantic-release-config": "^4.1.2",
|
|
92
|
+
"@alanscodelog/tsconfigs": "^4.0.1",
|
|
81
93
|
"@knodes/typedoc-plugin-pages": "^0.23.4",
|
|
82
94
|
"@types/node": "^20.4.1",
|
|
83
|
-
"@
|
|
84
|
-
|
|
85
|
-
"@vitest/coverage-c8": "^0.33.0",
|
|
86
|
-
commitlint: "^17.6.6",
|
|
95
|
+
"@vitest/coverage-v8": "^1.6.0",
|
|
96
|
+
commitlint: "^19.3.0",
|
|
87
97
|
concurrently: "^8.2.0",
|
|
88
98
|
"cross-env": "^7.0.3",
|
|
89
|
-
eslint: "^8.44.0",
|
|
90
|
-
"eslint-import-resolver-typescript": "^3.5.5",
|
|
91
|
-
"eslint-plugin-import": "^2.27.5",
|
|
92
|
-
"eslint-plugin-jsdoc": "^46.4.3",
|
|
93
|
-
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
94
99
|
"fast-glob": "^3.3.1",
|
|
95
100
|
"http-server": "^14.1.1",
|
|
96
|
-
husky: "^
|
|
101
|
+
husky: "^9.0.11",
|
|
97
102
|
indexit: "2.1.0-beta.3",
|
|
98
|
-
madge: "^
|
|
103
|
+
madge: "^7.0.0",
|
|
99
104
|
onchange: "^7.1.0",
|
|
100
|
-
"semantic-release": "^
|
|
105
|
+
"semantic-release": "^23.1.1",
|
|
101
106
|
"ts-node": "^10.9.1",
|
|
102
107
|
"tsc-alias": "^1.8.7",
|
|
103
108
|
typedoc: "~0.23.1",
|
|
104
|
-
typescript: "~5.
|
|
105
|
-
vite: "^
|
|
106
|
-
"vite-plugin-externalize-deps": "^0.
|
|
109
|
+
typescript: "~5.4.5",
|
|
110
|
+
vite: "^5.2.11",
|
|
111
|
+
"vite-plugin-externalize-deps": "^0.8.0",
|
|
107
112
|
"vite-tsconfig-paths": "^4.2.0",
|
|
108
|
-
vitest: "^
|
|
113
|
+
vitest: "^1.6.0"
|
|
109
114
|
};
|
|
110
115
|
const author = "Alan <alanscodelog@gmail.com>";
|
|
111
116
|
const repository = "https://github.com/witchcraftjs/expressit";
|
|
@@ -146,6 +151,7 @@ const pkg = {
|
|
|
146
151
|
version,
|
|
147
152
|
types,
|
|
148
153
|
type,
|
|
154
|
+
module,
|
|
149
155
|
exports,
|
|
150
156
|
scripts,
|
|
151
157
|
dependencies,
|
|
@@ -182,6 +188,7 @@ export {
|
|
|
182
188
|
files,
|
|
183
189
|
keywords,
|
|
184
190
|
license,
|
|
191
|
+
module,
|
|
185
192
|
name,
|
|
186
193
|
publishConfig,
|
|
187
194
|
release,
|
package/dist/types/ast.d.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import type { AnyFunction } from "@alanscodelog/utils";
|
|
2
|
-
import type { ArrayNode } from "../ast/classes/
|
|
3
|
-
import type { ConditionNode } from "../ast/classes/ConditionNode.js";
|
|
4
|
-
import type { ErrorToken } from "../ast/classes/ErrorToken.js";
|
|
5
|
-
import type { ExpressionNode } from "../ast/classes/ExpressionNode.js";
|
|
6
|
-
import type { GroupNode } from "../ast/classes/GroupNode.js";
|
|
7
|
-
import type { ValidToken } from "../ast/classes/ValidToken.js";
|
|
8
|
-
import type { VariableNode } from "../ast/classes/VariableNode.js";
|
|
1
|
+
import type { AnyFunction } from "@alanscodelog/utils/types";
|
|
2
|
+
import type { ArrayNode, ConditionNode, ErrorToken, ExpressionNode, GroupNode, ValidToken, VariableNode } from "../ast/classes/index.js";
|
|
9
3
|
export type AddParameters<T extends AnyFunction, TExtra extends any[] = [boolean]> = (...args: [...Parameters<T>, ...TExtra]) => ReturnType<T>;
|
|
10
4
|
export declare enum TOKEN_TYPE {
|
|
11
5
|
VALUE = "VALUE",
|
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"],"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,GAAG,EAAE,MAAM,CAAA;CACX,CAAA;AAED,oBAAY,QAAQ;IACnB,UAAU,eAAe;IACzB,KAAK,UAAU;IACf,KAAK,UAAU;IACf,SAAS,cAAc;IACvB,QAAQ,aAAa;CACrB;AAID;;;;GAIG;AACH,MAAM,MAAM,QAAQ,CACnB,KAAK,SAAS,UAAU,GAAG,UAAU,IAEnC,UAAU,CAAC,KAAK,CAAC,GACjB,UAAU,CAAC,KAAK,CAAC,CAAA;AAEpB,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,aAAa,GAAG,SAAS,GAAG,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;AAIrG,MAAM,MAAM,KAAK,GAAG,cAAc,GAAG,aAAa,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CAAA;AAEzF;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,KAAK,SAAS,UAAU,EAAE,MAAM,SAAS,UAAU,GAAG,KAAK,IAAI;IACzF,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAA;IACrB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IACvB,oEAAoE;IACpE,KAAK,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;CACpC,CAAA"}
|
package/dist/types/errors.d.ts
CHANGED
|
@@ -1,23 +1,11 @@
|
|
|
1
|
-
import type { DeepPartial } from "@alanscodelog/utils";
|
|
2
|
-
import type { ILexingError, IRecognitionException, IToken } from "chevrotain";
|
|
3
1
|
import type { ParserOptions } from "./parser.js";
|
|
4
2
|
export declare enum ERROR_CODES {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"PARSER_OPTION_REQUIRED_ERROR" = "PARSER.OPTIONS.CUSTOM_REQUIRED"
|
|
3
|
+
PARSER_POSITION_ERROR = "PARSER.POSITION",
|
|
4
|
+
PARSER_CONFLICTING_OPTIONS_ERROR = "PARSER.OPTIONS.CONFLICTING",
|
|
5
|
+
PARSER_OPTION_REQUIRED_ERROR = "PARSER.OPTIONS.CUSTOM_REQUIRED"
|
|
9
6
|
}
|
|
10
|
-
export type ErrorInfo<T extends
|
|
11
|
-
export type
|
|
12
|
-
[ERROR_CODES.PARSER_ERROR]: {
|
|
13
|
-
input: string;
|
|
14
|
-
options: DeepPartial<ParserOptions> | undefined;
|
|
15
|
-
"parsed options": ParserOptions;
|
|
16
|
-
error: Error;
|
|
17
|
-
"lexer errors": ILexingError[];
|
|
18
|
-
"lexed tokens": IToken[];
|
|
19
|
-
"parser errors": IRecognitionException[];
|
|
20
|
-
};
|
|
7
|
+
export type ErrorInfo<T extends ERROR_CODES> = T extends ERROR_CODES ? ERROR_Info[T] : never;
|
|
8
|
+
export type ERROR_Info = {
|
|
21
9
|
[ERROR_CODES.PARSER_POSITION_ERROR]: {
|
|
22
10
|
start?: number;
|
|
23
11
|
end?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAGhD,oBAAY,WAAW;IACtB,qBAAqB,oBAAoB;IACzC,gCAAgC,+BAA+B;IAC/D,4BAA4B,mCAAmC;CAC/D;AAGD,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,WAAW,IAC1C,CAAC,SAAS,WAAW,GACnB,UAAU,CAAC,CAAC,CAAC,GACb,KAAK,CAAA;AAGR,MAAM,MAAM,UAAU,GAAG;IACxB,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/errors.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var ERROR_CODES = /* @__PURE__ */ ((ERROR_CODES2) => {
|
|
2
|
-
ERROR_CODES2["PARSER_ERROR"] = "PARSER.ERROR";
|
|
3
2
|
ERROR_CODES2["PARSER_POSITION_ERROR"] = "PARSER.POSITION";
|
|
4
3
|
ERROR_CODES2["PARSER_CONFLICTING_OPTIONS_ERROR"] = "PARSER.OPTIONS.CONFLICTING";
|
|
5
4
|
ERROR_CODES2["PARSER_OPTION_REQUIRED_ERROR"] = "PARSER.OPTIONS.CUSTOM_REQUIRED";
|
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
|
};
|