@witchcraft/expressit 0.3.0 → 0.4.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/dist/Lexer.js +14 -19
- package/dist/Parser.js +104 -115
- package/dist/ast/builders/array.js +7 -8
- package/dist/ast/builders/condition.js +1 -1
- package/dist/ast/builders/expression.js +4 -4
- package/dist/ast/builders/group.js +8 -9
- package/dist/ast/builders/token.js +1 -1
- package/dist/ast/builders/variable.js +5 -6
- package/dist/ast/createConditionNode.js +1 -2
- package/dist/ast/handlers.js +22 -25
- package/dist/examples/ParserWithSqlSupport.js +22 -30
- package/dist/examples/ShortcutContextParser.js +2 -5
- package/dist/internal/ExpressitError.js +7 -10
- package/dist/internal/checkParserOpts.js +10 -11
- package/dist/internal/escapeVariableOrPrefix.js +1 -1
- package/dist/internal/parseParserOptions.js +3 -4
- package/dist/package.json.js +1 -1
- package/dist/types/ast.js +1 -1
- package/dist/types/autocomplete.js +1 -1
- package/dist/types/errors.js +1 -1
- package/dist/utils/extractTokens.js +4 -5
- package/dist/utils/generateParentsMap.js +7 -8
- package/dist/utils/getCursorInfo.js +3 -3
- package/dist/utils/getOppositeDelimiter.js +1 -1
- package/dist/utils/getSurroundingErrors.js +2 -3
- package/dist/utils/isBracket.js +1 -1
- package/dist/utils/isDelimiter.js +1 -1
- package/dist/utils/isNode.js +1 -1
- package/dist/utils/isParen.js +1 -1
- package/dist/utils/isQuote.js +1 -1
- package/dist/utils/isToken.js +1 -1
- package/dist/utils/prettyAst.js +10 -11
- package/package.json +20 -33
- package/src/Lexer.ts +3 -3
- package/src/Parser.ts +7 -7
- package/src/ast/builders/token.ts +1 -1
- package/src/examples/ParserWithSqlSupport.ts +1 -1
- package/src/internal/ExpressitError.ts +3 -3
- package/src/internal/checkParserOpts.ts +2 -2
- package/src/internal/escapeVariableOrPrefix.ts +1 -1
- package/src/types/ast.ts +1 -1
- package/src/types/autocomplete.ts +1 -1
- package/src/types/errors.ts +1 -1
- package/src/utils/extractTokens.ts +1 -1
- package/src/utils/getCursorInfo.ts +2 -2
- package/src/utils/getOppositeDelimiter.ts +1 -1
- package/src/utils/prettyAst.ts +3 -3
package/dist/types/errors.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { unreachable } from "@alanscodelog/utils/unreachable
|
|
1
|
+
import { unreachable } from "@alanscodelog/utils/unreachable";
|
|
2
2
|
import { isNode } from "./isNode.js";
|
|
3
3
|
import { isToken } from "./isToken.js";
|
|
4
4
|
import { AST_TYPE } from "../types/ast.js";
|
|
5
5
|
function extractTokens(ast) {
|
|
6
|
-
var _a, _b, _c;
|
|
7
6
|
if (isToken(ast) && !ast.valid) {
|
|
8
7
|
return [ast];
|
|
9
8
|
}
|
|
@@ -11,7 +10,7 @@ function extractTokens(ast) {
|
|
|
11
10
|
const prefix = ast.prefix ? [ast.prefix] : [];
|
|
12
11
|
const quoteR = ast.quote ? [ast.quote.right] : [];
|
|
13
12
|
const quoteL = ast.quote ? [ast.quote.left] : [];
|
|
14
|
-
const quoteFlags =
|
|
13
|
+
const quoteFlags = ast.quote?.flags ? [ast.quote.flags] : [];
|
|
15
14
|
return [...prefix, ...quoteL, ast.value, ...quoteR, ...quoteFlags];
|
|
16
15
|
}
|
|
17
16
|
if (ast.type === AST_TYPE.CONDITION) {
|
|
@@ -19,8 +18,8 @@ function extractTokens(ast) {
|
|
|
19
18
|
const operator = ast.operator ? [ast.operator] : [];
|
|
20
19
|
const property = ast.property ? extractTokens(ast.property) : [];
|
|
21
20
|
const propertyOperator = ast.propertyOperator ? [ast.propertyOperator] : [];
|
|
22
|
-
const sepL =
|
|
23
|
-
const sepR =
|
|
21
|
+
const sepL = ast.sep?.left ? [ast.sep.left] : [];
|
|
22
|
+
const sepR = ast.sep?.right ? [ast.sep.right] : [];
|
|
24
23
|
return [...operator, ...property, ...sepL, ...propertyOperator, ...sepR, ...value];
|
|
25
24
|
}
|
|
26
25
|
if (ast.type === AST_TYPE.GROUP) {
|
|
@@ -2,15 +2,14 @@ import "@alanscodelog/utils/types";
|
|
|
2
2
|
import { isNode } from "./isNode.js";
|
|
3
3
|
import { AST_TYPE } from "../types/ast.js";
|
|
4
4
|
function generateParentsMap(ast) {
|
|
5
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
6
5
|
const recursiveMap = arguments[1];
|
|
7
6
|
const map = recursiveMap ?? /* @__PURE__ */ new Map();
|
|
8
7
|
const self = generateParentsMap;
|
|
9
8
|
if (ast.type === AST_TYPE.VARIABLE) {
|
|
10
9
|
if (ast.prefix) map.set(ast.prefix, ast);
|
|
11
|
-
if (
|
|
12
|
-
if (
|
|
13
|
-
if (
|
|
10
|
+
if (ast.quote?.left) map.set(ast.quote.left, ast);
|
|
11
|
+
if (ast.quote?.right) map.set(ast.quote.right, ast);
|
|
12
|
+
if (ast.quote?.flags) map.set(ast.quote.flags, ast);
|
|
14
13
|
map.set(ast.value, ast);
|
|
15
14
|
} else if (ast.type === AST_TYPE.CONDITION) {
|
|
16
15
|
if (ast.operator) map.set(ast.operator, ast);
|
|
@@ -19,8 +18,8 @@ function generateParentsMap(ast) {
|
|
|
19
18
|
if (isNode(ast.property)) self(ast.property, map);
|
|
20
19
|
}
|
|
21
20
|
if (ast.propertyOperator) map.set(ast.propertyOperator, ast);
|
|
22
|
-
if (
|
|
23
|
-
if (
|
|
21
|
+
if (ast.sep?.left) map.set(ast.sep.left, ast);
|
|
22
|
+
if (ast.sep?.right) map.set(ast.sep.right, ast);
|
|
24
23
|
map.set(ast.value, ast);
|
|
25
24
|
if (isNode(ast.value)) self(ast.value, map);
|
|
26
25
|
} else if (ast.type === AST_TYPE.EXPRESSION) {
|
|
@@ -34,8 +33,8 @@ function generateParentsMap(ast) {
|
|
|
34
33
|
map.set(ast.prefix, ast);
|
|
35
34
|
if (isNode(ast.prefix)) self(ast.prefix, map);
|
|
36
35
|
}
|
|
37
|
-
if (
|
|
38
|
-
if (
|
|
36
|
+
if (ast.paren?.left) map.set(ast.paren.left, ast);
|
|
37
|
+
if (ast.paren?.right) map.set(ast.paren.right, ast);
|
|
39
38
|
map.set(ast.expression, ast);
|
|
40
39
|
if (isNode(ast.expression)) self(ast.expression, map);
|
|
41
40
|
} else if (ast.type === AST_TYPE.ARRAY) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isArray } from "@alanscodelog/utils/isArray
|
|
2
|
-
import { unreachable } from "@alanscodelog/utils/unreachable
|
|
1
|
+
import { isArray } from "@alanscodelog/utils/isArray";
|
|
2
|
+
import { unreachable } from "@alanscodelog/utils/unreachable";
|
|
3
3
|
import { extractTokens } from "./extractTokens.js";
|
|
4
4
|
import "../types/ast.js";
|
|
5
5
|
import "../types/autocomplete.js";
|
|
@@ -39,7 +39,7 @@ function getCursorInfo(input, ast, index) {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
if (token.start >= index) {
|
|
42
|
-
info.next
|
|
42
|
+
info.next ??= token;
|
|
43
43
|
if (token.valid && !info.valid.next) {
|
|
44
44
|
info.valid.next = token;
|
|
45
45
|
break;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TOKEN_TYPE } from "../types/ast.js";
|
|
2
2
|
function getSurroundingErrors(tokens, token) {
|
|
3
|
-
var _a, _b;
|
|
4
3
|
if (token.at) {
|
|
5
4
|
return [];
|
|
6
5
|
}
|
|
@@ -8,11 +7,11 @@ function getSurroundingErrors(tokens, token) {
|
|
|
8
7
|
let iNext = tokens[i] === token.next ? i : i + 1;
|
|
9
8
|
let iPrev = tokens[i] === token.next ? i - 1 : i;
|
|
10
9
|
const errors = [];
|
|
11
|
-
while (
|
|
10
|
+
while (tokens[iNext]?.valid === false) {
|
|
12
11
|
errors.push(tokens[iNext]);
|
|
13
12
|
iNext++;
|
|
14
13
|
}
|
|
15
|
-
while (
|
|
14
|
+
while (tokens[iPrev]?.valid === false) {
|
|
16
15
|
errors.push(tokens[iPrev]);
|
|
17
16
|
iPrev--;
|
|
18
17
|
}
|
package/dist/utils/isBracket.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TOKEN_TYPE } from "../types/ast.js";
|
|
2
2
|
function isBracket(token) {
|
|
3
|
-
return [TOKEN_TYPE.BRACKETL, TOKEN_TYPE.BRACKETR].includes(token
|
|
3
|
+
return [TOKEN_TYPE.BRACKETL, TOKEN_TYPE.BRACKETR].includes(token?.type);
|
|
4
4
|
}
|
|
5
5
|
export {
|
|
6
6
|
isBracket
|
package/dist/utils/isNode.js
CHANGED
package/dist/utils/isParen.js
CHANGED
package/dist/utils/isQuote.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TOKEN_TYPE } from "../types/ast.js";
|
|
2
2
|
function isQuote(token) {
|
|
3
|
-
return [TOKEN_TYPE.BACKTICK, TOKEN_TYPE.DOUBLEQUOTE, TOKEN_TYPE.SINGLEQUOTE, TOKEN_TYPE.REGEX].includes(token
|
|
3
|
+
return [TOKEN_TYPE.BACKTICK, TOKEN_TYPE.DOUBLEQUOTE, TOKEN_TYPE.SINGLEQUOTE, TOKEN_TYPE.REGEX].includes(token?.type);
|
|
4
4
|
}
|
|
5
5
|
export {
|
|
6
6
|
isQuote
|
package/dist/utils/isToken.js
CHANGED
package/dist/utils/prettyAst.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as color from "@alanscodelog/utils/colors
|
|
2
|
-
import { isBlank } from "@alanscodelog/utils/isBlank
|
|
1
|
+
import * as color from "@alanscodelog/utils/colors";
|
|
2
|
+
import { isBlank } from "@alanscodelog/utils/isBlank";
|
|
3
3
|
import "@alanscodelog/utils/types";
|
|
4
|
-
import { unreachable } from "@alanscodelog/utils/unreachable
|
|
4
|
+
import { unreachable } from "@alanscodelog/utils/unreachable";
|
|
5
5
|
import { isToken } from "./isToken.js";
|
|
6
6
|
import { AST_TYPE, TOKEN_TYPE } from "../types/ast.js";
|
|
7
7
|
const defaultColors = {
|
|
@@ -21,7 +21,6 @@ const toRows = (rows, opts) => {
|
|
|
21
21
|
];
|
|
22
22
|
};
|
|
23
23
|
function prettyAst(ast, { indent = " ", children = "├╴", last = "└╴", branch = "│", quote = "" } = {}, colors = {}) {
|
|
24
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
25
24
|
const opts = { indent, children, last, branch, quote };
|
|
26
25
|
const c = colors ? { ...defaultColors, ...colors } : disableColors;
|
|
27
26
|
const pos = `${c.position}(${ast.start}, ${ast.end})${c.reset}`;
|
|
@@ -46,10 +45,10 @@ function prettyAst(ast, { indent = " ", children = "├╴", last = "└╴",
|
|
|
46
45
|
const header = `${c.info}${ast.operator === void 0}${c.reset}`;
|
|
47
46
|
const not = ast.operator ? prettyAst_(ast.operator, opts, c, ___, `(negation)`) : "";
|
|
48
47
|
const property = ast.property ? prettyAst_(ast.property, opts, c, ___, `(property)`) : "";
|
|
49
|
-
const sepL =
|
|
48
|
+
const sepL = ast.sep?.left ? prettyAst_(ast.sep.left, opts, c, ___, `(separator)`) : "";
|
|
50
49
|
const op = ast.propertyOperator ? prettyAst_(ast.propertyOperator, opts, c, ___, `(property operator)`) : "";
|
|
51
|
-
const sepR =
|
|
52
|
-
const isRegex = ast.value.type === AST_TYPE.VARIABLE &&
|
|
50
|
+
const sepR = ast.sep?.right ? prettyAst_(ast.sep.right, opts, c, ___, `(separator)`) : "";
|
|
51
|
+
const isRegex = ast.value.type === AST_TYPE.VARIABLE && ast.value.quote?.left.type === TOKEN_TYPE.REGEX;
|
|
53
52
|
const isArray = ast.value.type === AST_TYPE.ARRAY;
|
|
54
53
|
const variable = prettyAst_(ast.value, opts, c, __L, `(${property ? "value" : "variable/alone"}${isRegex ? " - regex" : isArray ? "- array" : ""})`);
|
|
55
54
|
return [
|
|
@@ -60,10 +59,10 @@ ${__}`);
|
|
|
60
59
|
}
|
|
61
60
|
if (ast.type === AST_TYPE.VARIABLE) {
|
|
62
61
|
const prefix = ast.prefix ? prettyAst_(ast.prefix, opts, c, ___, `(value prefix)`) : "";
|
|
63
|
-
const left =
|
|
64
|
-
const value = prettyAst_(ast.value, opts, c, !ast.quote ? __L : !
|
|
65
|
-
const right =
|
|
66
|
-
const flags =
|
|
62
|
+
const left = ast.quote?.left ? prettyAst_(ast.quote.left, opts, c, ___, "") : "";
|
|
63
|
+
const value = prettyAst_(ast.value, opts, c, !ast.quote ? __L : !ast.quote?.right ? __L : ___, "");
|
|
64
|
+
const right = ast.quote?.right ? prettyAst_(ast.quote.right, opts, c, !ast.quote?.flags ? __L : ___, "") : "";
|
|
65
|
+
const flags = ast.quote?.flags ? prettyAst_(ast.quote.flags, opts, c, __L, "(flags)") : "";
|
|
67
66
|
return [
|
|
68
67
|
`VARIABLE ${pos}${extra}`,
|
|
69
68
|
...toRows([prefix, left, value, right, flags], opts)
|
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.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -16,44 +16,32 @@
|
|
|
16
16
|
"import": "./dist/ast/index.js"
|
|
17
17
|
},
|
|
18
18
|
"./ast/*": {
|
|
19
|
-
"types": "./dist/ast
|
|
20
|
-
"import": "./dist/ast
|
|
21
|
-
},
|
|
22
|
-
"./internal": {
|
|
23
|
-
"types": "./dist/internal/index.d.ts",
|
|
24
|
-
"import": "./dist/internal/index.js"
|
|
19
|
+
"types": "./dist/ast/*.d.ts",
|
|
20
|
+
"import": "./dist/ast/*.js"
|
|
25
21
|
},
|
|
26
22
|
"./internal/*": {
|
|
27
|
-
"types": "./dist/internal
|
|
28
|
-
"import": "./dist/internal
|
|
29
|
-
},
|
|
30
|
-
"./methods": {
|
|
31
|
-
"types": "./dist/methods/index.d.ts",
|
|
32
|
-
"import": "./dist/methods/index.js"
|
|
33
|
-
},
|
|
34
|
-
"./methods/*": {
|
|
35
|
-
"types": "./dist/methods/*",
|
|
36
|
-
"import": "./dist/methods/*"
|
|
23
|
+
"types": "./dist/internal/*.d.ts",
|
|
24
|
+
"import": "./dist/internal/*.js"
|
|
37
25
|
},
|
|
38
26
|
"./utils": {
|
|
39
27
|
"types": "./dist/utils/index.d.ts",
|
|
40
28
|
"import": "./dist/utils/index.js"
|
|
41
29
|
},
|
|
42
30
|
"./utils/*": {
|
|
43
|
-
"types": "./dist/utils
|
|
44
|
-
"import": "./dist/utils
|
|
31
|
+
"types": "./dist/utils/*.d.ts",
|
|
32
|
+
"import": "./dist/utils/*.js"
|
|
45
33
|
},
|
|
46
34
|
"./examples": {
|
|
47
35
|
"types": "./dist/examples/index.d.ts",
|
|
48
36
|
"import": "./dist/examples/index.js"
|
|
49
37
|
},
|
|
50
38
|
"./examples/*": {
|
|
51
|
-
"types": "./dist/examples
|
|
52
|
-
"import": "./dist/examples
|
|
39
|
+
"types": "./dist/examples/*.d.ts",
|
|
40
|
+
"import": "./dist/examples/*.js"
|
|
53
41
|
},
|
|
54
42
|
"./*": {
|
|
55
|
-
"types": "./dist/types
|
|
56
|
-
"import": "./dist/types
|
|
43
|
+
"types": "./dist/types/*.d.ts",
|
|
44
|
+
"import": "./dist/types/*.js"
|
|
57
45
|
}
|
|
58
46
|
},
|
|
59
47
|
"scripts": {
|
|
@@ -64,7 +52,7 @@
|
|
|
64
52
|
"build:types": "tsc --emitDeclarationOnly -p tsconfig.types.json",
|
|
65
53
|
"lint:eslint": "eslint \"{src,tests,bin}/**/*.{cjs,js,ts}\" \"*.{cjs,js,ts}\" --max-warnings=1 --report-unused-disable-directives",
|
|
66
54
|
"lint:types": "tsc --noEmit --pretty",
|
|
67
|
-
"lint:commits": "commitlint --from
|
|
55
|
+
"lint:commits": "commitlint --from-last-tag --to HEAD --verbose",
|
|
68
56
|
"lint:imports": "madge --circular --extensions ts ./src",
|
|
69
57
|
"lint": "npm run lint:types && npm run lint:eslint",
|
|
70
58
|
"coverage": "vitest --exclude '.direnv/**/*' --coverage",
|
|
@@ -85,32 +73,32 @@
|
|
|
85
73
|
"prepare": "husky && npm run build"
|
|
86
74
|
},
|
|
87
75
|
"dependencies": {
|
|
88
|
-
"@alanscodelog/utils": "^
|
|
76
|
+
"@alanscodelog/utils": "^6.0.1"
|
|
89
77
|
},
|
|
90
78
|
"devDependencies": {
|
|
91
79
|
"@alanscodelog/commitlint-config": "^3.0.1",
|
|
92
|
-
"@alanscodelog/eslint-config": "5.0.
|
|
80
|
+
"@alanscodelog/eslint-config": "5.0.4",
|
|
93
81
|
"@alanscodelog/semantic-release-config": "^5.0.4",
|
|
94
82
|
"@alanscodelog/tsconfigs": "^6.0.0",
|
|
95
83
|
"@commitlint/cli": "^19.6.1",
|
|
96
|
-
"@electric-sql/pglite": "^0.
|
|
97
|
-
"@types/node": "^
|
|
84
|
+
"@electric-sql/pglite": "^0.3.4",
|
|
85
|
+
"@types/node": "^24.0.13",
|
|
98
86
|
"@vitest/coverage-v8": "^3.1.1",
|
|
99
87
|
"concurrently": "^9.1.0",
|
|
100
88
|
"cross-env": "^7.0.3",
|
|
101
89
|
"drizzle-kit": "^0.31.0",
|
|
102
|
-
"drizzle-orm": "^0.
|
|
90
|
+
"drizzle-orm": "^0.44.3",
|
|
103
91
|
"fast-glob": "^3.3.1",
|
|
104
92
|
"http-server": "^14.1.1",
|
|
105
93
|
"husky": "^9.1.7",
|
|
106
94
|
"indexit": "2.1.0-beta.3",
|
|
107
95
|
"madge": "^8.0.0",
|
|
108
96
|
"onchange": "^7.1.0",
|
|
109
|
-
"semantic-release": "^24.2.
|
|
97
|
+
"semantic-release": "^24.2.7",
|
|
110
98
|
"ts-node": "^10.9.1",
|
|
111
|
-
"typedoc": "0.28.
|
|
99
|
+
"typedoc": "0.28.7",
|
|
112
100
|
"typescript": "~5.8.3",
|
|
113
|
-
"vite": "^
|
|
101
|
+
"vite": "^7.1.3",
|
|
114
102
|
"vite-plugin-externalize-deps": "^0.9.0",
|
|
115
103
|
"vite-tsconfig-paths": "^5.1.4",
|
|
116
104
|
"vitest": "^3.1.1"
|
|
@@ -148,7 +136,6 @@
|
|
|
148
136
|
"@comments": {
|
|
149
137
|
"scripts": {
|
|
150
138
|
"test": "Runs `lint:types` before (so that flags can be passed to the test command) so that we can test type assertions. See expect_type function in @alanscodelog/utils.",
|
|
151
|
-
"lint:commits": "Lints all unpushed commits in the active branch.",
|
|
152
139
|
"prepare": "Needed so that if we pull the package from git it will get built and installed properly.",
|
|
153
140
|
"actions:debug": "For debugging github build action locally with nektos/act. Requires act and docker. Note: Cache will never work locally because of https://github.com/nektos/act/issues/285"
|
|
154
141
|
}
|
package/src/Lexer.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { EnumLike } from "@alanscodelog/utils"
|
|
2
|
-
import { enumFromArray } from "@alanscodelog/utils/enumFromArray
|
|
3
|
-
import { isBlank } from "@alanscodelog/utils/isBlank
|
|
4
|
-
import { pushIfNotIn } from "@alanscodelog/utils/pushIfNotIn
|
|
2
|
+
import { enumFromArray } from "@alanscodelog/utils/enumFromArray"
|
|
3
|
+
import { isBlank } from "@alanscodelog/utils/isBlank"
|
|
4
|
+
import { pushIfNotIn } from "@alanscodelog/utils/pushIfNotIn"
|
|
5
5
|
|
|
6
6
|
import { checkParserOpts } from "./internal/checkParserOpts.js"
|
|
7
7
|
import { parseParserOptions } from "./internal/parseParserOptions.js"
|
package/src/Parser.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* eslint-disable max-lines */
|
|
2
|
-
import { get } from "@alanscodelog/utils/get
|
|
3
|
-
import { insert } from "@alanscodelog/utils/insert
|
|
4
|
-
import { isArray } from "@alanscodelog/utils/isArray
|
|
5
|
-
import { isWhitespace } from "@alanscodelog/utils/isWhitespace
|
|
6
|
-
import { setReadOnly } from "@alanscodelog/utils/setReadOnly
|
|
2
|
+
import { get } from "@alanscodelog/utils/get"
|
|
3
|
+
import { insert } from "@alanscodelog/utils/insert"
|
|
4
|
+
import { isArray } from "@alanscodelog/utils/isArray"
|
|
5
|
+
import { isWhitespace } from "@alanscodelog/utils/isWhitespace"
|
|
6
|
+
import { setReadOnly } from "@alanscodelog/utils/setReadOnly"
|
|
7
7
|
import type { AddParameters , DeepPartial } from "@alanscodelog/utils/types"
|
|
8
|
-
import { unreachable } from "@alanscodelog/utils/unreachable
|
|
8
|
+
import { unreachable } from "@alanscodelog/utils/unreachable"
|
|
9
9
|
|
|
10
10
|
import { pos } from "./ast/builders/pos.js"
|
|
11
11
|
import { createCondition } from "./ast/createNormalizedCondition.js"
|
|
@@ -296,7 +296,7 @@ export class Parser<T = any> {
|
|
|
296
296
|
this.state.index++
|
|
297
297
|
return this.transformCategoryToken(nextToken, categoryToken) as Token<TType>
|
|
298
298
|
} else {
|
|
299
|
-
|
|
299
|
+
unreachable()
|
|
300
300
|
}
|
|
301
301
|
} else {
|
|
302
302
|
const tokenType = this.getTokenType(type as $TType)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { unreachable } from "@alanscodelog/utils/unreachable
|
|
1
|
+
import { unreachable } from "@alanscodelog/utils/unreachable"
|
|
2
2
|
|
|
3
3
|
import { Parser } from "../Parser.js"
|
|
4
4
|
import { AST_TYPE, type NormalizedCondition, type NormalizedExpression, type Position,TOKEN_TYPE } from "../types/ast.js"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { crop } from "@alanscodelog/utils/crop
|
|
2
|
-
import { indent } from "@alanscodelog/utils/indent
|
|
3
|
-
import { pretty } from "@alanscodelog/utils/pretty
|
|
1
|
+
import { crop } from "@alanscodelog/utils/crop"
|
|
2
|
+
import { indent } from "@alanscodelog/utils/indent"
|
|
3
|
+
import { pretty } from "@alanscodelog/utils/pretty"
|
|
4
4
|
import type { Keys } from "@alanscodelog/utils/types"
|
|
5
5
|
|
|
6
6
|
import packageJson from "../../package.json" with { type: "json" }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isBlank } from "@alanscodelog/utils/isBlank
|
|
2
|
-
import { pushIfNotIn } from "@alanscodelog/utils/pushIfNotIn
|
|
1
|
+
import { isBlank } from "@alanscodelog/utils/isBlank"
|
|
2
|
+
import { pushIfNotIn } from "@alanscodelog/utils/pushIfNotIn"
|
|
3
3
|
|
|
4
4
|
import { ExpressitError } from "./ExpressitError.js"
|
|
5
5
|
|
package/src/types/ast.ts
CHANGED
package/src/types/errors.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isArray } from "@alanscodelog/utils/isArray
|
|
2
|
-
import { unreachable } from "@alanscodelog/utils/unreachable
|
|
1
|
+
import { isArray } from "@alanscodelog/utils/isArray"
|
|
2
|
+
import { unreachable } from "@alanscodelog/utils/unreachable"
|
|
3
3
|
|
|
4
4
|
import { extractTokens } from "./extractTokens.js"
|
|
5
5
|
|
package/src/utils/prettyAst.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable prefer-rest-params */
|
|
2
|
-
import * as color from "@alanscodelog/utils/colors
|
|
3
|
-
import { isBlank } from "@alanscodelog/utils/isBlank
|
|
2
|
+
import * as color from "@alanscodelog/utils/colors"
|
|
3
|
+
import { isBlank } from "@alanscodelog/utils/isBlank"
|
|
4
4
|
import { type AddParameters } from "@alanscodelog/utils/types"
|
|
5
|
-
import { unreachable } from "@alanscodelog/utils/unreachable
|
|
5
|
+
import { unreachable } from "@alanscodelog/utils/unreachable"
|
|
6
6
|
|
|
7
7
|
import { isToken } from "./isToken.js"
|
|
8
8
|
|