@witchcraft/expressit 0.1.2 → 0.2.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.
Files changed (285) hide show
  1. package/README.md +9 -5
  2. package/dist/Lexer.js +2 -2
  3. package/dist/Parser.d.ts +14 -29
  4. package/dist/Parser.d.ts.map +1 -1
  5. package/dist/Parser.js +120 -135
  6. package/dist/ast/builders/array.d.ts +1 -3
  7. package/dist/ast/builders/array.d.ts.map +1 -1
  8. package/dist/ast/builders/array.js +3 -5
  9. package/dist/ast/builders/condition.d.ts +5 -11
  10. package/dist/ast/builders/condition.d.ts.map +1 -1
  11. package/dist/ast/builders/condition.js +2 -3
  12. package/dist/ast/builders/delim.d.ts +1 -1
  13. package/dist/ast/builders/error.d.ts +3 -4
  14. package/dist/ast/builders/error.d.ts.map +1 -1
  15. package/dist/ast/builders/error.js +6 -2
  16. package/dist/ast/builders/expression.d.ts +3 -7
  17. package/dist/ast/builders/expression.d.ts.map +1 -1
  18. package/dist/ast/builders/expression.js +3 -5
  19. package/dist/ast/builders/group.d.ts +3 -8
  20. package/dist/ast/builders/group.d.ts.map +1 -1
  21. package/dist/ast/builders/group.js +3 -3
  22. package/dist/ast/builders/pos.d.ts +1 -2
  23. package/dist/ast/builders/pos.d.ts.map +1 -1
  24. package/dist/ast/builders/token.d.ts +3 -5
  25. package/dist/ast/builders/token.d.ts.map +1 -1
  26. package/dist/ast/builders/token.js +3 -4
  27. package/dist/ast/builders/type.d.ts +1 -1
  28. package/dist/ast/builders/variable.d.ts +3 -5
  29. package/dist/ast/builders/variable.d.ts.map +1 -1
  30. package/dist/ast/builders/variable.js +2 -3
  31. package/dist/ast/createArrayNode.d.ts +3 -0
  32. package/dist/ast/createArrayNode.d.ts.map +1 -0
  33. package/dist/ast/createArrayNode.js +12 -0
  34. package/dist/ast/createConditionNode.d.ts +11 -0
  35. package/dist/ast/createConditionNode.d.ts.map +1 -0
  36. package/dist/ast/createConditionNode.js +18 -0
  37. package/dist/ast/createExpressionNode.d.ts +3 -0
  38. package/dist/ast/createExpressionNode.d.ts.map +1 -0
  39. package/dist/ast/createExpressionNode.js +14 -0
  40. package/dist/ast/createGroupNode.d.ts +5 -0
  41. package/dist/ast/createGroupNode.d.ts.map +1 -0
  42. package/dist/ast/createGroupNode.js +14 -0
  43. package/dist/ast/createNormalizedCondition.d.ts +3 -0
  44. package/dist/ast/createNormalizedCondition.d.ts.map +1 -0
  45. package/dist/ast/createNormalizedCondition.js +10 -0
  46. package/dist/ast/createNormalizedExpression.d.ts +3 -0
  47. package/dist/ast/createNormalizedExpression.d.ts.map +1 -0
  48. package/dist/ast/createNormalizedExpression.js +10 -0
  49. package/dist/ast/createToken.d.ts +6 -0
  50. package/dist/ast/createToken.d.ts.map +1 -0
  51. package/dist/ast/createToken.js +15 -0
  52. package/dist/ast/createVariableNode.d.ts +3 -0
  53. package/dist/ast/createVariableNode.d.ts.map +1 -0
  54. package/dist/ast/createVariableNode.js +12 -0
  55. package/dist/ast/error.d.ts +3 -0
  56. package/dist/ast/error.d.ts.map +1 -0
  57. package/dist/ast/error.js +9 -0
  58. package/dist/ast/handlers.d.ts +5 -12
  59. package/dist/ast/handlers.d.ts.map +1 -1
  60. package/dist/ast/handlers.js +21 -29
  61. package/dist/ast/index.d.ts +9 -1
  62. package/dist/ast/index.d.ts.map +1 -1
  63. package/dist/ast/index.js +18 -2
  64. package/dist/defaults/defaultConditionNormalizer.d.ts +3 -0
  65. package/dist/defaults/defaultConditionNormalizer.d.ts.map +1 -0
  66. package/dist/defaults/defaultKeyParser.d.ts +3 -0
  67. package/dist/defaults/defaultKeyParser.d.ts.map +1 -0
  68. package/dist/defaults/defaultPrefixApplier.d.ts +3 -0
  69. package/dist/defaults/defaultPrefixApplier.d.ts.map +1 -0
  70. package/dist/defaults/defaultValueComparer.d.ts +3 -0
  71. package/dist/defaults/defaultValueComparer.d.ts.map +1 -0
  72. package/dist/{helpers/general → defaults}/index.d.ts +0 -2
  73. package/dist/defaults/index.d.ts.map +1 -0
  74. package/dist/{helpers/general → defaults}/index.js +0 -4
  75. package/dist/index.d.ts +2 -1
  76. package/dist/index.d.ts.map +1 -1
  77. package/dist/index.js +3 -1
  78. package/dist/{helpers/errors.d.ts → internal/ExpressitError.d.ts} +3 -2
  79. package/dist/internal/ExpressitError.d.ts.map +1 -0
  80. package/dist/{helpers/errors.js → internal/ExpressitError.js} +2 -2
  81. package/dist/internal/applyBoolean.d.ts.map +1 -0
  82. package/dist/{helpers/general → internal}/applyPrefix.d.ts +1 -1
  83. package/dist/internal/applyPrefix.d.ts.map +1 -0
  84. package/dist/{helpers/parser → internal}/checkParserOpts.d.ts +2 -1
  85. package/dist/internal/checkParserOpts.d.ts.map +1 -0
  86. package/dist/{helpers/parser → internal}/checkParserOpts.js +14 -14
  87. package/dist/internal/escapeVariableOrPrefix.d.ts +2 -0
  88. package/dist/internal/escapeVariableOrPrefix.d.ts.map +1 -0
  89. package/dist/internal/escapeVariableOrPrefix.js +38 -0
  90. package/dist/internal/extractPosition.d.ts +5 -0
  91. package/dist/internal/extractPosition.d.ts.map +1 -0
  92. package/dist/internal/getUnclosedRightParenCount.d.ts +4 -0
  93. package/dist/internal/getUnclosedRightParenCount.d.ts.map +1 -0
  94. package/dist/{helpers/parser → internal}/getUnclosedRightParenCount.js +1 -1
  95. package/dist/{helpers/parser → internal}/parseParserOptions.d.ts +1 -1
  96. package/dist/internal/parseParserOptions.d.ts.map +1 -0
  97. package/dist/{helpers/parser → internal}/parseParserOptions.js +4 -4
  98. package/dist/internal/unescape.d.ts.map +1 -0
  99. package/dist/package.json.js +7 -7
  100. package/dist/types/ast.d.ts +195 -6
  101. package/dist/types/ast.d.ts.map +1 -1
  102. package/dist/types/ast.js +2 -0
  103. package/dist/types/autocomplete.d.ts +5 -6
  104. package/dist/types/autocomplete.d.ts.map +1 -1
  105. package/dist/types/parser.d.ts +17 -22
  106. package/dist/types/parser.d.ts.map +1 -1
  107. package/dist/utils/extractTokens.d.ts +2 -4
  108. package/dist/utils/extractTokens.d.ts.map +1 -1
  109. package/dist/utils/extractTokens.js +14 -18
  110. package/dist/utils/generateParentsMap.d.ts +10 -0
  111. package/dist/utils/generateParentsMap.d.ts.map +1 -0
  112. package/dist/utils/generateParentsMap.js +73 -0
  113. package/dist/utils/getCursorInfo.d.ts +1 -1
  114. package/dist/utils/getCursorInfo.d.ts.map +1 -1
  115. package/dist/utils/getCursorInfo.js +3 -5
  116. package/dist/utils/getOppositeDelimiter.d.ts +2 -1
  117. package/dist/utils/getOppositeDelimiter.d.ts.map +1 -1
  118. package/dist/utils/getOppositeDelimiter.js +6 -5
  119. package/dist/utils/getParent.d.ts +5 -0
  120. package/dist/utils/getParent.d.ts.map +1 -0
  121. package/dist/utils/getParent.js +6 -0
  122. package/dist/utils/getSurroundingErrors.d.ts +3 -4
  123. package/dist/utils/getSurroundingErrors.d.ts.map +1 -1
  124. package/dist/utils/getSurroundingErrors.js +3 -3
  125. package/dist/utils/index.d.ts +4 -0
  126. package/dist/utils/index.d.ts.map +1 -1
  127. package/dist/utils/index.js +8 -0
  128. package/dist/utils/isNode.d.ts +10 -0
  129. package/dist/utils/isNode.d.ts.map +1 -0
  130. package/dist/utils/isNode.js +6 -0
  131. package/dist/utils/isToken.d.ts +8 -0
  132. package/dist/utils/isToken.d.ts.map +1 -0
  133. package/dist/utils/isToken.js +6 -0
  134. package/dist/utils/prettyAst.d.ts +1 -2
  135. package/dist/utils/prettyAst.d.ts.map +1 -1
  136. package/dist/utils/prettyAst.js +19 -26
  137. package/package.json +7 -7
  138. package/src/Lexer.ts +2 -2
  139. package/src/Parser.ts +158 -165
  140. package/src/ast/builders/array.ts +4 -9
  141. package/src/ast/builders/condition.ts +10 -15
  142. package/src/ast/builders/delim.ts +1 -1
  143. package/src/ast/builders/error.ts +10 -6
  144. package/src/ast/builders/expression.ts +17 -23
  145. package/src/ast/builders/group.ts +7 -11
  146. package/src/ast/builders/pos.ts +2 -3
  147. package/src/ast/builders/token.ts +6 -7
  148. package/src/ast/builders/type.ts +1 -1
  149. package/src/ast/builders/variable.ts +6 -8
  150. package/src/ast/createArrayNode.ts +17 -0
  151. package/src/ast/createConditionNode.ts +58 -0
  152. package/src/ast/createExpressionNode.ts +21 -0
  153. package/src/ast/createGroupNode.ts +46 -0
  154. package/src/ast/createNormalizedCondition.ts +12 -0
  155. package/src/ast/createNormalizedExpression.ts +9 -0
  156. package/src/ast/createToken.ts +26 -0
  157. package/src/ast/createVariableNode.ts +18 -0
  158. package/src/ast/error.ts +9 -0
  159. package/src/ast/handlers.ts +26 -37
  160. package/src/ast/index.ts +9 -1
  161. package/src/{helpers/general → defaults}/defaultConditionNormalizer.ts +1 -1
  162. package/src/{helpers/general → defaults}/defaultKeyParser.ts +1 -1
  163. package/src/{helpers/general → defaults}/defaultPrefixApplier.ts +1 -1
  164. package/src/{helpers/general → defaults}/defaultValueComparer.ts +1 -1
  165. package/src/{helpers/general → defaults}/index.ts +0 -2
  166. package/src/index.ts +2 -1
  167. package/src/{helpers/errors.ts → internal/ExpressitError.ts} +2 -2
  168. package/src/{helpers/general → internal}/applyPrefix.ts +1 -1
  169. package/src/{helpers/parser → internal}/checkParserOpts.ts +16 -15
  170. package/src/internal/escapeVariableOrPrefix.ts +36 -0
  171. package/src/{helpers/parser → internal}/extractPosition.ts +2 -2
  172. package/src/{helpers/parser → internal}/getUnclosedRightParenCount.ts +1 -2
  173. package/src/{helpers/parser → internal}/parseParserOptions.ts +5 -5
  174. package/src/types/ast.ts +292 -7
  175. package/src/types/autocomplete.ts +5 -7
  176. package/src/types/parser.ts +17 -22
  177. package/src/utils/extractTokens.ts +16 -20
  178. package/src/utils/generateParentsMap.ts +60 -0
  179. package/src/utils/getCursorInfo.ts +4 -6
  180. package/src/utils/getOppositeDelimiter.ts +11 -10
  181. package/src/utils/getParent.ts +16 -0
  182. package/src/utils/getSurroundingErrors.ts +10 -9
  183. package/src/utils/index.ts +4 -0
  184. package/src/utils/isNode.ts +12 -0
  185. package/src/utils/isToken.ts +10 -0
  186. package/src/utils/prettyAst.ts +20 -17
  187. package/dist/ast/classes/ArrayNode.d.ts +0 -18
  188. package/dist/ast/classes/ArrayNode.d.ts.map +0 -1
  189. package/dist/ast/classes/ArrayNode.js +0 -55
  190. package/dist/ast/classes/Condition.d.ts +0 -13
  191. package/dist/ast/classes/Condition.d.ts.map +0 -1
  192. package/dist/ast/classes/Condition.js +0 -21
  193. package/dist/ast/classes/ConditionNode.d.ts +0 -73
  194. package/dist/ast/classes/ConditionNode.d.ts.map +0 -1
  195. package/dist/ast/classes/ConditionNode.js +0 -101
  196. package/dist/ast/classes/ErrorToken.d.ts +0 -27
  197. package/dist/ast/classes/ErrorToken.d.ts.map +0 -1
  198. package/dist/ast/classes/ErrorToken.js +0 -47
  199. package/dist/ast/classes/Expression.d.ts +0 -13
  200. package/dist/ast/classes/Expression.d.ts.map +0 -1
  201. package/dist/ast/classes/Expression.js +0 -19
  202. package/dist/ast/classes/ExpressionNode.d.ts +0 -21
  203. package/dist/ast/classes/ExpressionNode.d.ts.map +0 -1
  204. package/dist/ast/classes/ExpressionNode.js +0 -57
  205. package/dist/ast/classes/GroupNode.d.ts +0 -64
  206. package/dist/ast/classes/GroupNode.d.ts.map +0 -1
  207. package/dist/ast/classes/GroupNode.js +0 -69
  208. package/dist/ast/classes/Node.d.ts +0 -22
  209. package/dist/ast/classes/Node.d.ts.map +0 -1
  210. package/dist/ast/classes/Node.js +0 -28
  211. package/dist/ast/classes/Token.d.ts +0 -27
  212. package/dist/ast/classes/Token.d.ts.map +0 -1
  213. package/dist/ast/classes/Token.js +0 -28
  214. package/dist/ast/classes/ValidToken.d.ts +0 -26
  215. package/dist/ast/classes/ValidToken.d.ts.map +0 -1
  216. package/dist/ast/classes/ValidToken.js +0 -49
  217. package/dist/ast/classes/VariableNode.d.ts +0 -33
  218. package/dist/ast/classes/VariableNode.d.ts.map +0 -1
  219. package/dist/ast/classes/VariableNode.js +0 -58
  220. package/dist/ast/classes/index.d.ts +0 -12
  221. package/dist/ast/classes/index.d.ts.map +0 -1
  222. package/dist/ast/classes/index.js +0 -24
  223. package/dist/helpers/errors.d.ts.map +0 -1
  224. package/dist/helpers/general/applyBoolean.d.ts.map +0 -1
  225. package/dist/helpers/general/applyPrefix.d.ts.map +0 -1
  226. package/dist/helpers/general/defaultConditionNormalizer.d.ts +0 -3
  227. package/dist/helpers/general/defaultConditionNormalizer.d.ts.map +0 -1
  228. package/dist/helpers/general/defaultKeyParser.d.ts +0 -3
  229. package/dist/helpers/general/defaultKeyParser.d.ts.map +0 -1
  230. package/dist/helpers/general/defaultPrefixApplier.d.ts +0 -3
  231. package/dist/helpers/general/defaultPrefixApplier.d.ts.map +0 -1
  232. package/dist/helpers/general/defaultValueComparer.d.ts +0 -3
  233. package/dist/helpers/general/defaultValueComparer.d.ts.map +0 -1
  234. package/dist/helpers/general/index.d.ts.map +0 -1
  235. package/dist/helpers/index.d.ts +0 -4
  236. package/dist/helpers/index.d.ts.map +0 -1
  237. package/dist/helpers/index.js +0 -8
  238. package/dist/helpers/parser/assignParents.d.ts +0 -4
  239. package/dist/helpers/parser/assignParents.d.ts.map +0 -1
  240. package/dist/helpers/parser/assignParents.js +0 -71
  241. package/dist/helpers/parser/checkParserOpts.d.ts.map +0 -1
  242. package/dist/helpers/parser/extractPosition.d.ts +0 -5
  243. package/dist/helpers/parser/extractPosition.d.ts.map +0 -1
  244. package/dist/helpers/parser/getUnclosedRightParenCount.d.ts +0 -4
  245. package/dist/helpers/parser/getUnclosedRightParenCount.d.ts.map +0 -1
  246. package/dist/helpers/parser/index.d.ts +0 -9
  247. package/dist/helpers/parser/index.d.ts.map +0 -1
  248. package/dist/helpers/parser/index.js +0 -18
  249. package/dist/helpers/parser/parseParserOptions.d.ts.map +0 -1
  250. package/dist/helpers/parser/seal.d.ts +0 -8
  251. package/dist/helpers/parser/seal.d.ts.map +0 -1
  252. package/dist/helpers/parser/seal.js +0 -10
  253. package/dist/helpers/parser/setParent.d.ts +0 -6
  254. package/dist/helpers/parser/setParent.d.ts.map +0 -1
  255. package/dist/helpers/parser/setParent.js +0 -4
  256. package/dist/helpers/parser/unescape.d.ts.map +0 -1
  257. package/src/ast/classes/ArrayNode.ts +0 -46
  258. package/src/ast/classes/Condition.ts +0 -22
  259. package/src/ast/classes/ConditionNode.ts +0 -141
  260. package/src/ast/classes/ErrorToken.ts +0 -49
  261. package/src/ast/classes/Expression.ts +0 -26
  262. package/src/ast/classes/ExpressionNode.ts +0 -62
  263. package/src/ast/classes/GroupNode.ts +0 -127
  264. package/src/ast/classes/Node.ts +0 -47
  265. package/src/ast/classes/Token.ts +0 -59
  266. package/src/ast/classes/ValidToken.ts +0 -56
  267. package/src/ast/classes/VariableNode.ts +0 -67
  268. package/src/ast/classes/index.ts +0 -13
  269. package/src/helpers/index.ts +0 -6
  270. package/src/helpers/parser/assignParents.ts +0 -51
  271. package/src/helpers/parser/index.ts +0 -10
  272. package/src/helpers/parser/seal.ts +0 -14
  273. package/src/helpers/parser/setParent.ts +0 -5
  274. /package/dist/{helpers/general → defaults}/defaultConditionNormalizer.js +0 -0
  275. /package/dist/{helpers/general → defaults}/defaultKeyParser.js +0 -0
  276. /package/dist/{helpers/general → defaults}/defaultPrefixApplier.js +0 -0
  277. /package/dist/{helpers/general → defaults}/defaultValueComparer.js +0 -0
  278. /package/dist/{helpers/general → internal}/applyBoolean.d.ts +0 -0
  279. /package/dist/{helpers/general → internal}/applyBoolean.js +0 -0
  280. /package/dist/{helpers/general → internal}/applyPrefix.js +0 -0
  281. /package/dist/{helpers/parser → internal}/extractPosition.js +0 -0
  282. /package/dist/{helpers/parser → internal}/unescape.d.ts +0 -0
  283. /package/dist/{helpers/parser → internal}/unescape.js +0 -0
  284. /package/src/{helpers/general → internal}/applyBoolean.ts +0 -0
  285. /package/src/{helpers/parser → internal}/unescape.ts +0 -0
package/dist/Parser.js CHANGED
@@ -11,32 +11,27 @@ import { isWhitespace } from "@alanscodelog/utils/isWhitespace.js";
11
11
  import { setReadOnly } from "@alanscodelog/utils/setReadOnly.js";
12
12
  import { unreachable } from "@alanscodelog/utils/unreachable.js";
13
13
  import { pos } from "./ast/builders/pos.js";
14
- import { ArrayNode } from "./ast/classes/ArrayNode.js";
15
- import { ConditionNode } from "./ast/classes/ConditionNode.js";
16
- import { ErrorToken } from "./ast/classes/ErrorToken.js";
17
- import { ExpressionNode } from "./ast/classes/ExpressionNode.js";
18
- import { GroupNode } from "./ast/classes/GroupNode.js";
19
- import { Condition } from "./ast/classes/Condition.js";
20
- import { Expression } from "./ast/classes/Expression.js";
21
- import "@alanscodelog/utils/crop.js";
22
- import "@alanscodelog/utils/indent.js";
23
- import "@alanscodelog/utils/pretty.js";
24
- import { ValidToken } from "./ast/classes/ValidToken.js";
25
- import { VariableNode } from "./ast/classes/VariableNode.js";
14
+ import { createCondition } from "./ast/createNormalizedCondition.js";
15
+ import { createExpression } from "./ast/createNormalizedExpression.js";
26
16
  import { token, operator, expression, variable, condition, group, array, delimiter } from "./ast/handlers.js";
27
- import { applyBoolean } from "./helpers/general/applyBoolean.js";
28
- import { applyPrefix } from "./helpers/general/applyPrefix.js";
29
- import { checkParserOpts } from "./helpers/parser/checkParserOpts.js";
30
- import { extractPosition } from "./helpers/parser/extractPosition.js";
31
- import { getUnclosedRightParenCount } from "./helpers/parser/getUnclosedRightParenCount.js";
32
- import { parseParserOptions } from "./helpers/parser/parseParserOptions.js";
33
- import { seal } from "./helpers/parser/seal.js";
17
+ import { applyBoolean } from "./internal/applyBoolean.js";
18
+ import { applyPrefix } from "./internal/applyPrefix.js";
19
+ import { checkParserOpts } from "./internal/checkParserOpts.js";
20
+ import { escapeVariableOrPrefix } from "./internal/escapeVariableOrPrefix.js";
21
+ import { extractPosition } from "./internal/extractPosition.js";
22
+ import { getUnclosedRightParenCount } from "./internal/getUnclosedRightParenCount.js";
23
+ import { parseParserOptions } from "./internal/parseParserOptions.js";
24
+ import { unescape } from "./internal/unescape.js";
34
25
  import { Lexer, $C, $T } from "./Lexer.js";
35
- import { TOKEN_TYPE } from "./types/ast.js";
26
+ import { TOKEN_TYPE, AST_TYPE } from "./types/ast.js";
36
27
  import { SUGGESTION_TYPE } from "./types/autocomplete.js";
37
28
  import { extractTokens } from "./utils/extractTokens.js";
29
+ import { generateParentsMap } from "./utils/generateParentsMap.js";
38
30
  import { getCursorInfo } from "./utils/getCursorInfo.js";
31
+ import { getParent } from "./utils/getParent.js";
39
32
  import { getSurroundingErrors } from "./utils/getSurroundingErrors.js";
33
+ import { isNode } from "./utils/isNode.js";
34
+ import { isToken } from "./utils/isToken.js";
40
35
  const OPPOSITE = {
41
36
  [TOKEN_TYPE.AND]: TOKEN_TYPE.OR,
42
37
  [TOKEN_TYPE.OR]: TOKEN_TYPE.AND
@@ -62,10 +57,10 @@ const createDefaultRequires = (partial = {}) => ({
62
57
  group: partial.group ?? false,
63
58
  prefix: partial.prefix ?? false
64
59
  });
65
- const tokenRequiresWhitespace = (validToken, whitespace, wordOps) => {
66
- if (whitespace || validToken === void 0)
60
+ const tokenRequiresWhitespace = (valid, whitespace, wordOps) => {
61
+ if (whitespace || valid === void 0)
67
62
  return false;
68
- return validToken.type === TOKEN_TYPE.VALUE || [TOKEN_TYPE.AND, TOKEN_TYPE.OR, TOKEN_TYPE.NOT].includes(validToken.type) && wordOps.find((_) => _.value === validToken.value) !== void 0;
63
+ return valid.type === TOKEN_TYPE.VALUE || [TOKEN_TYPE.AND, TOKEN_TYPE.OR, TOKEN_TYPE.NOT].includes(valid.type) && wordOps.find((_) => _.value === valid.value) !== void 0;
69
64
  };
70
65
  const tokenVariable = [TOKEN_TYPE.BACKTICK, TOKEN_TYPE.DOUBLEQUOTE, TOKEN_TYPE.SINGLEQUOTE, TOKEN_TYPE.VALUE, TOKEN_TYPE.REGEX];
71
66
  class Parser {
@@ -140,8 +135,6 @@ class Parser {
140
135
  * It can also parse the result from `lex`, but that is really only for internal use.
141
136
  */
142
137
  parse(input) {
143
- var _a;
144
- const doSeal = ((_a = arguments[1]) == null ? void 0 : _a.seal) ?? true;
145
138
  if (typeof input === "string" && isWhitespace(input)) {
146
139
  return token.value(void 0, { start: 0, end: 0 });
147
140
  }
@@ -153,9 +146,6 @@ class Parser {
153
146
  lexedTokens
154
147
  };
155
148
  const res = this.ruleMain();
156
- if (doSeal) {
157
- seal(res);
158
- }
159
149
  this.state = {
160
150
  rawInput: "",
161
151
  shift: 0,
@@ -349,26 +339,26 @@ class Parser {
349
339
  return res;
350
340
  }
351
341
  ruleCondition() {
352
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
342
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
353
343
  const not = this.ruleNot();
354
344
  const property = this.ruleConditionProperty();
355
- const propVal = ((_a = property == null ? void 0 : property.prop) == null ? void 0 : _a.value) === void 0 ? void 0 : property.prop.value instanceof ErrorToken ? "" : property.prop.value.value;
356
- const propOpVal = ((_b = property == null ? void 0 : property.rest) == null ? void 0 : _b.propertyOperator) === void 0 ? void 0 : property.rest.propertyOperator instanceof ErrorToken ? "" : (_c = property.rest.propertyOperator) == null ? void 0 : _c.value;
357
- const isExpanded = (((_d = property == null ? void 0 : property.rest) == null ? void 0 : _d.sepL) ?? ((_e = property == null ? void 0 : property.rest) == null ? void 0 : _e.sepR)) !== void 0;
345
+ const propVal = ((_a = property == null ? void 0 : property.prop) == null ? void 0 : _a.value) === void 0 ? void 0 : !property.prop.value.valid ? "" : property.prop.value.value;
346
+ const propOpVal = ((_b = property == null ? void 0 : property.rest) == null ? void 0 : _b.propertyOperator) === void 0 ? void 0 : !((_c = property.rest.propertyOperator) == null ? void 0 : _c.valid) ? "" : (_d = property.rest.propertyOperator) == null ? void 0 : _d.value;
347
+ const isExpanded = (((_e = property == null ? void 0 : property.rest) == null ? void 0 : _e.sepL) ?? ((_f = property == null ? void 0 : property.rest) == null ? void 0 : _f.sepR)) !== void 0;
358
348
  const convertRegexValues = typeof this.options.regexValues === "function" && !this.options.regexValues(propVal, propOpVal, isExpanded);
359
349
  const convertArrayValues = typeof this.options.arrayValues === "function" && !this.options.arrayValues(propVal, propOpVal, isExpanded);
360
350
  let value = this.ruleConditionValue(property, { convertRegexValues, convertArrayValues });
361
351
  let group$1;
362
- if (!(value instanceof ArrayNode) && !isArray(value) && (!value || this.options.prefixableGroups) && this.isType(this.peek(1), $T.PAREN_L)) {
352
+ if (isNode(value) && !(value.type === AST_TYPE.ARRAY) && !isArray(value) && (!value || this.options.prefixableGroups) && this.isType(this.peek(1), $T.PAREN_L)) {
363
353
  group$1 = this.rulePlainGroup({ onlyValues: property !== void 0, convertRegexValues, convertArrayValues });
364
354
  }
365
355
  if (isArray(value)) {
366
356
  group$1 = value;
367
357
  value = void 0;
368
358
  }
369
- if (convertRegexValues && value instanceof VariableNode && ((_f = value.quote) == null ? void 0 : _f.left.type) === TOKEN_TYPE.REGEX) {
359
+ if (convertRegexValues && isNode(value) && value.type === AST_TYPE.VARIABLE && ((_g = value.quote) == null ? void 0 : _g.left.type) === TOKEN_TYPE.REGEX) {
370
360
  value = variable(void 0, void 0, token.value(
371
- (((_h = (_g = value.quote) == null ? void 0 : _g.left) == null ? void 0 : _h.value) ?? "") + (value.value.value ?? "") + (((_j = (_i = value.quote) == null ? void 0 : _i.right) == null ? void 0 : _j.value) ?? ""),
361
+ (((_i = (_h = value.quote) == null ? void 0 : _h.left) == null ? void 0 : _i.value) ?? "") + (value.value.value ?? "") + (((_k = (_j = value.quote) == null ? void 0 : _j.right) == null ? void 0 : _k.value) ?? ""),
372
362
  pos(value)
373
363
  ), void 0);
374
364
  }
@@ -444,7 +434,7 @@ class Parser {
444
434
  regexValues: convertRegexValues,
445
435
  arrayValues: convertArrayValues
446
436
  }, "One");
447
- const parsed = this.subParserOne.parse(" ".repeat(start) + subInput, { seal: false });
437
+ const parsed = this.subParserOne.parse(" ".repeat(start) + subInput);
448
438
  return [parenL, parsed, parenR];
449
439
  }
450
440
  return [parenL, condition2, parenR];
@@ -481,11 +471,11 @@ class Parser {
481
471
  expandedPropertySeparator: void 0,
482
472
  arrayValues: false
483
473
  }, "Two");
484
- const parsed = this.subParserTwo.parse(" ".repeat(start) + subInput, { seal: false });
485
- if (parsed instanceof ConditionNode) {
474
+ const parsed = this.subParserTwo.parse(" ".repeat(start) + subInput);
475
+ if ("type" in parsed && parsed.type === AST_TYPE.CONDITION) {
486
476
  return parsed.value;
487
477
  }
488
- if (parsed instanceof ErrorToken || parsed instanceof ExpressionNode || parsed instanceof GroupNode) {
478
+ if ("valid" in parsed && !parsed.valid || "type" in parsed && (parsed.type === AST_TYPE.EXPRESSION || parsed.type === AST_TYPE.GROUP)) {
489
479
  unreachable("parsed.value should not be an ErrorToken, ExpressionNode, or GroupNode.");
490
480
  }
491
481
  return parsed;
@@ -689,15 +679,15 @@ class Parser {
689
679
  return void 0;
690
680
  }
691
681
  /**
692
- * Given a list of @see Suggestion entries, the parser options, and a list of variables, prefixes, operators, etc, and the preferred quote type, returns a list of @see Completion entries.
682
+ * Given the ast, a list of {@link Suggestion} entries, the parser options, and a list of variables, prefixes, operators, etc, and the preferred quote type, returns a list of {@link Completion} entries.
693
683
  *
694
684
  * It takes care of suggesting the correct delimiters for fixes, quoting variables/prefixes if it would not be possible to parse them unquoted, and separating symbol from non-symbol (word) operators.
695
685
  *
696
- * Does not add whitespace or group requirements. The suggestion information is still in the completion if you wish to show these. But they should not be added to the completion value if using @see autoreplace which will take care of it.
686
+ * Does not add whitespace or group requirements. The suggestion information is still in the completion if you wish to show these. But they should not be added to the completion value if using {@link autoreplace} which will take care of it.
697
687
  *
698
- * Is not aware of existing values. You will have to use @see getCursorInfo to understand the context in which the suggestion was made, so that, for example, you could filter out used regex flags.
688
+ * Is not aware of existing values. You will have to use {@link getCursorInfo} to understand the context in which the suggestion was made, so that, for example, you could filter out used regex flags.
699
689
  */
700
- autocomplete(suggestions, {
690
+ autocomplete(ast, suggestions, {
701
691
  values = [],
702
692
  arrayValues = [],
703
693
  variables = [],
@@ -709,6 +699,7 @@ class Parser {
709
699
  regexFlags = ["i", "m", "u"],
710
700
  quote = '"'
711
701
  } = {}) {
702
+ const parentMap = generateParentsMap(ast);
712
703
  const self = this;
713
704
  return suggestions.map((suggestion) => {
714
705
  const type = suggestion.type;
@@ -735,7 +726,7 @@ class Parser {
735
726
  return true;
736
727
  }
737
728
  const token2 = suggestion2.cursorInfo;
738
- const flags = token2.at && ((_b = (_a = token2.at.parent) == null ? void 0 : _a.quote) == null ? void 0 : _b.flags) === suggestion2.cursorInfo.at ? token2.at : token2.next && ((_d = (_c = token2.next.parent) == null ? void 0 : _c.quote) == null ? void 0 : _d.flags) === suggestion2.cursorInfo.next ? token2.next : token2.prev && ((_f = (_e = token2.prev.parent) == null ? void 0 : _e.quote) == null ? void 0 : _f.flags) === suggestion2.cursorInfo.prev ? token2.prev : void 0;
729
+ const flags = token2.at && ((_b = (_a = getParent(token2.at, parentMap)) == null ? void 0 : _a.quote) == null ? void 0 : _b.flags) === suggestion2.cursorInfo.at ? token2.at : token2.next && ((_d = (_c = getParent(token2.next, parentMap)) == null ? void 0 : _c.quote) == null ? void 0 : _d.flags) === suggestion2.cursorInfo.next ? token2.next : token2.prev && ((_f = (_e = getParent(token2.prev, parentMap)) == null ? void 0 : _e.quote) == null ? void 0 : _f.flags) === suggestion2.cursorInfo.prev ? token2.prev : void 0;
739
730
  if ((_g = flags == null ? void 0 : flags.value) == null ? void 0 : _g.includes(value)) {
740
731
  return false;
741
732
  }
@@ -767,31 +758,17 @@ class Parser {
767
758
  case SUGGESTION_TYPE.ARRAY_VALUE:
768
759
  case SUGGESTION_TYPE.VARIABLE: {
769
760
  const arr = type === SUGGESTION_TYPE.VARIABLE ? variables : type === SUGGESTION_TYPE.ARRAY_VALUE ? arrayValues : type === SUGGESTION_TYPE.VALUE ? values : unreachable();
770
- return arr.map((variable2) => {
771
- const res = self.parse(variable2);
772
- if (res instanceof ConditionNode && res.operator === void 0 && res.value instanceof VariableNode && res.value.quote === void 0) {
773
- return { suggestion, value: res.value.value.value };
774
- } else {
775
- return { suggestion, value: quote + variable2.replace(new RegExp(quote, "g"), `\\${quote}`) + quote };
776
- }
777
- });
761
+ return arr.map((variable2) => ({ suggestion, value: escapeVariableOrPrefix(variable2, quote) }));
778
762
  }
779
763
  case SUGGESTION_TYPE.PREFIX:
780
- return prefixes.map((prefix) => {
781
- const res = self.parse(prefix);
782
- if (res instanceof ConditionNode && res.operator === void 0 && res.value instanceof VariableNode && res.value.quote === void 0) {
783
- return { suggestion, value: res.value.value.value };
784
- } else {
785
- return { suggestion, value: quote + prefix.replace(new RegExp(quote, "g"), `\\${quote}`) + quote };
786
- }
787
- });
764
+ return prefixes.map((prefix) => ({ suggestion, value: escapeVariableOrPrefix(prefix, quote) }));
788
765
  }
789
766
  }).flat();
790
767
  }
791
768
  /**
792
- * 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.
769
+ * Given the input string and a {@link Completion} consisting of the value of the replacement and a {@link Suggestion} entry, returns the replacement string and the new position of the cursor.
793
770
  *
794
- * The value passed should be escaped if it's needed (or quoted). @see autocomplete already takes care of quoting variables if you're using it.
771
+ * The value passed should be escaped if it's needed (or quoted). {@link autocomplete} already takes care of quoting variables if you're using it.
795
772
  */
796
773
  autoreplace(input, { value, suggestion }) {
797
774
  const isQuotedLeft = ['"', "'", "`"].includes(value[0]);
@@ -819,9 +796,9 @@ class Parser {
819
796
  return { replacement, cursor };
820
797
  }
821
798
  /**
822
- * Returns a list of suggestions ( @see Suggestion ). These are not a list of autocomplete entries (with values), but more a list of entries describing possible suggestions. This list can then be passed to @see Parser["autocomplete"] to build a list to show users, from which you can then pick an entry to pass to @see Parser["autoreplace"] .
799
+ * Returns a list of suggestions ( {@link Suggestion} ). These are not a list of autocomplete entries (with values), but more a list of entries describing possible suggestions. This list can then be passed to {@link Parser}["autocomplete"] to build a list to show users, from which you can then pick an entry to pass to {@link Parser}["autoreplace"] .
823
800
  *
824
- * The list returned is "unsorted", but there is still some logic to the order. Fixes for errors are suggested first, in the order returned by @see getSurroundingErrors. Regular suggestions come after in the following order: prefixes if enabled, variables, boolean symbol operators, then boolean word operators.
801
+ * The list returned is "unsorted", but there is still some logic to the order. Fixes for errors are suggested first, in the order returned by {@link getSurroundingErrors}. Regular suggestions come after in the following order: prefixes if enabled, variables, boolean symbol operators, then boolean word operators.
825
802
  *
826
803
  * When the cursor is between two tokens that have possible suggestions, only suggestion types for the token before are returned. For example:
827
804
  *
@@ -841,7 +818,8 @@ class Parser {
841
818
  * ```
842
819
  */
843
820
  autosuggest(input, ast, index) {
844
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L;
821
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
822
+ const parentMap = generateParentsMap(ast);
845
823
  const opts = this.options;
846
824
  const tokens = extractTokens(ast);
847
825
  const token2 = getCursorInfo(input, tokens, index);
@@ -854,7 +832,7 @@ class Parser {
854
832
  const requiresWhitespacePrevOp = canSuggestOpAfterPrev ? false : requiresWhitespacePrev;
855
833
  const requireWhitespaceNextOp = !canSuggestOpAfterPrev && canSuggestOpBeforeNext ? false : requiresWhitespaceNext;
856
834
  const suggestions = [];
857
- if (ast instanceof ErrorToken) {
835
+ if (isToken(ast) && !ast.valid) {
858
836
  suggestions.push({
859
837
  type: SUGGESTION_TYPE.PREFIX,
860
838
  requires: createDefaultRequires({ group: true }),
@@ -890,8 +868,9 @@ class Parser {
890
868
  case TOKEN_TYPE.SINGLEQUOTE:
891
869
  case TOKEN_TYPE.BACKTICK:
892
870
  {
893
- const isLeft = error.parent.quote.left === error;
894
- const isRight = error.parent.quote.right === error;
871
+ const errorParent = getParent(error, parentMap);
872
+ const isLeft = errorParent.quote.left === error;
873
+ const isRight = errorParent.quote.right === error;
895
874
  suggestions.push({
896
875
  ...errorSuggestion,
897
876
  type,
@@ -939,8 +918,9 @@ class Parser {
939
918
  });
940
919
  break;
941
920
  case TOKEN_TYPE.VALUE: {
942
- const prefixedValue = error.parent instanceof VariableNode ? (_d = (_c = error.parent) == null ? void 0 : _c.prefix) == null ? void 0 : _d.value : false;
943
- const isRegexValue = error.parent instanceof VariableNode && (((_e = error.parent.quote) == null ? void 0 : _e.left.type) === TOKEN_TYPE.REGEX || ((_f = error.parent.quote) == null ? void 0 : _f.right.type) === TOKEN_TYPE.REGEX);
921
+ const errorParent = getParent(error, parentMap);
922
+ const prefixedValue = (errorParent == null ? void 0 : errorParent.type) === AST_TYPE.VARIABLE ? (_d = (_c = getParent(error, parentMap)) == null ? void 0 : _c.prefix) == null ? void 0 : _d.value : false;
923
+ const isRegexValue = (errorParent == null ? void 0 : errorParent.type) === AST_TYPE.VARIABLE && (((_e = errorParent.quote) == null ? void 0 : _e.left.type) === TOKEN_TYPE.REGEX || ((_f = errorParent.quote) == null ? void 0 : _f.right.type) === TOKEN_TYPE.REGEX);
944
924
  if (!isRegexValue) {
945
925
  if (!prefixedValue && opts.prefixableGroups) {
946
926
  suggestions.push({
@@ -1005,41 +985,42 @@ class Parser {
1005
985
  }
1006
986
  }
1007
987
  }
1008
- const prevVar = (_g = token2.valid.prev) == null ? void 0 : _g.parent;
1009
- const nextVar = (_h = token2.valid.next) == null ? void 0 : _h.parent;
1010
- const prevCondition = prevVar == null ? void 0 : prevVar.parent;
1011
- const nextCondition = nextVar == null ? void 0 : nextVar.parent;
1012
- const atVar = (_i = token2.at) == null ? void 0 : _i.parent;
1013
- const atCondition = atVar == null ? void 0 : atVar.parent;
1014
- const isVarPrev = !token2.whitespace.prev && ((_j = token2.valid.prev) == null ? void 0 : _j.type) !== TOKEN_TYPE.REGEX && prevVar instanceof VariableNode && (prevCondition instanceof ConditionNode && prevCondition.value === prevVar && (((_k = prevVar.quote) == null ? void 0 : _k.right) === token2.valid.prev || prevVar.value === token2.valid.prev) || prevCondition instanceof ArrayNode);
1015
- const isVarNext = !token2.whitespace.next && ((_l = token2.valid.next) == null ? void 0 : _l.type) !== TOKEN_TYPE.REGEX && nextVar instanceof VariableNode && (nextCondition instanceof ConditionNode && nextCondition.value === nextVar && (((_m = nextVar.quote) == null ? void 0 : _m.left) === token2.valid.next || nextVar.value === token2.valid.next) || nextCondition instanceof ArrayNode);
1016
- const isVarAt = atVar instanceof VariableNode && atCondition instanceof ConditionNode || prevVar instanceof VariableNode && token2.valid.prev === ((_n = prevVar == null ? void 0 : prevVar.quote) == null ? void 0 : _n.left) || nextVar instanceof VariableNode && token2.valid.next === ((_o = nextVar == null ? void 0 : nextVar.quote) == null ? void 0 : _o.right);
1017
- const isPropertyPrev = prevCondition instanceof ConditionNode && prevVar !== void 0 && prevVar === (prevCondition == null ? void 0 : prevCondition.property);
1018
- const isPropertyNext = nextCondition instanceof ConditionNode && nextVar !== void 0 && nextVar === (nextCondition == null ? void 0 : nextCondition.property);
1019
- const isPropertyAt = atCondition instanceof ConditionNode && atVar !== void 0 && atVar === (atCondition == null ? void 0 : atCondition.property);
1020
- const isPropertyOperatorPrev = prevVar instanceof ConditionNode && token2.valid.prev === (prevVar == null ? void 0 : prevVar.propertyOperator);
1021
- const isPropertyOperatorNext = nextVar instanceof ConditionNode && token2.valid.next === (nextVar == null ? void 0 : nextVar.propertyOperator);
1022
- const isPropertyOperatorAt = atVar instanceof ConditionNode && token2.at === (atVar == null ? void 0 : atVar.propertyOperator);
1023
- const noArrayValuesTarget = ((_p = token2.valid.prev) == null ? void 0 : _p.type) === TOKEN_TYPE.BRACKETL && (token2.valid.next === void 0 || ((_q = token2.valid.next) == null ? void 0 : _q.type) === TOKEN_TYPE.BRACKETR);
988
+ const prevVar = getParent(token2.valid.prev, parentMap);
989
+ const nextVar = getParent(token2.valid.next, parentMap);
990
+ const prevCondition = getParent(prevVar, parentMap);
991
+ const nextCondition = getParent(nextVar, parentMap);
992
+ const atVar = getParent(token2.at, parentMap);
993
+ const atCondition = getParent(atVar, parentMap);
994
+ const isVarPrev = !token2.whitespace.prev && ((_g = token2.valid.prev) == null ? void 0 : _g.type) !== TOKEN_TYPE.REGEX && (prevVar == null ? void 0 : prevVar.type) === AST_TYPE.VARIABLE && ((prevCondition == null ? void 0 : prevCondition.type) === AST_TYPE.CONDITION && prevCondition.value === prevVar && (((_h = prevVar.quote) == null ? void 0 : _h.right) === token2.valid.prev || prevVar.value === token2.valid.prev) || (prevCondition == null ? void 0 : prevCondition.type) === AST_TYPE.ARRAY);
995
+ const isVarNext = !token2.whitespace.next && ((_i = token2.valid.next) == null ? void 0 : _i.type) !== TOKEN_TYPE.REGEX && (nextVar == null ? void 0 : nextVar.type) === AST_TYPE.VARIABLE && ((nextCondition == null ? void 0 : nextCondition.type) === AST_TYPE.CONDITION && nextCondition.value === nextVar && (((_j = nextVar.quote) == null ? void 0 : _j.left) === token2.valid.next || nextVar.value === token2.valid.next) || (nextCondition == null ? void 0 : nextCondition.type) === AST_TYPE.ARRAY);
996
+ const isVarAt = (atVar == null ? void 0 : atVar.type) === AST_TYPE.VARIABLE && (atCondition == null ? void 0 : atCondition.type) === AST_TYPE.CONDITION || (prevVar == null ? void 0 : prevVar.type) === AST_TYPE.VARIABLE && token2.valid.prev === ((_k = prevVar == null ? void 0 : prevVar.quote) == null ? void 0 : _k.left) || (nextVar == null ? void 0 : nextVar.type) === AST_TYPE.VARIABLE && token2.valid.next === ((_l = nextVar == null ? void 0 : nextVar.quote) == null ? void 0 : _l.right);
997
+ const isPropertyPrev = (prevCondition == null ? void 0 : prevCondition.type) === AST_TYPE.CONDITION && prevVar !== void 0 && prevVar === (prevCondition == null ? void 0 : prevCondition.property);
998
+ const isPropertyNext = (nextCondition == null ? void 0 : nextCondition.type) === AST_TYPE.CONDITION && nextVar !== void 0 && nextVar === (nextCondition == null ? void 0 : nextCondition.property);
999
+ const isPropertyAt = (atCondition == null ? void 0 : atCondition.type) === AST_TYPE.CONDITION && atVar !== void 0 && atVar === (atCondition == null ? void 0 : atCondition.property);
1000
+ const isPropertyOperatorPrev = (prevVar == null ? void 0 : prevVar.type) === AST_TYPE.CONDITION && token2.valid.prev === (prevVar == null ? void 0 : prevVar.propertyOperator);
1001
+ const isPropertyOperatorNext = (nextVar == null ? void 0 : nextVar.type) === AST_TYPE.CONDITION && token2.valid.next === (nextVar == null ? void 0 : nextVar.propertyOperator);
1002
+ const isPropertyOperatorAt = (atVar == null ? void 0 : atVar.type) === AST_TYPE.CONDITION && token2.at === (atVar == null ? void 0 : atVar.propertyOperator);
1003
+ const noArrayValuesTarget = ((_m = token2.valid.prev) == null ? void 0 : _m.type) === TOKEN_TYPE.BRACKETL && (token2.valid.next === void 0 || ((_n = token2.valid.next) == null ? void 0 : _n.type) === TOKEN_TYPE.BRACKETR);
1024
1004
  const target = isVarPrev ? token2.valid.prev : !noArrayValuesTarget && !isPropertyPrev && !isPropertyOperatorPrev && isVarNext ? token2.valid.next : isVarAt ? token2.at : void 0;
1025
1005
  const propertyTarget = isPropertyPrev ? token2.valid.prev : !noArrayValuesTarget && !isVarPrev && !isPropertyOperatorPrev && isPropertyNext ? token2.valid.next : isPropertyAt ? token2.at : void 0;
1026
1006
  const propOpTarget = isPropertyOperatorPrev ? token2.valid.prev : !noArrayValuesTarget && !isVarPrev && !isPropertyPrev && isPropertyOperatorNext ? token2.valid.next : isPropertyOperatorAt ? token2.at : void 0;
1027
1007
  if (target) {
1028
- const parent = target.parent;
1029
- if (parent instanceof VariableNode) {
1008
+ const parent = getParent(target, parentMap);
1009
+ if (parent && parent.type === AST_TYPE.VARIABLE) {
1030
1010
  const range = pos(parent);
1031
- const condition2 = parent == null ? void 0 : parent.parent;
1011
+ const parentParent = getParent(parent, parentMap);
1012
+ const condition2 = parentParent;
1032
1013
  const isValue = condition2.propertyOperator !== void 0 && condition2.value === parent;
1033
- const maybeGroup = (_r = parent == null ? void 0 : parent.parent) == null ? void 0 : _r.parent;
1034
- const isPrefix = maybeGroup instanceof GroupNode && maybeGroup.prefix === condition2;
1014
+ const maybeGroup = getParent(parentParent, parentMap);
1015
+ const isPrefix = (maybeGroup == null ? void 0 : maybeGroup.type) === AST_TYPE.GROUP && maybeGroup.prefix === condition2;
1035
1016
  const varStart = getCursorInfo(input, ast, parent.start);
1036
1017
  const varEnd = getCursorInfo(input, ast, parent.end);
1037
1018
  const targetRequiresWhitespacePrev = tokenRequiresWhitespace(varStart.valid.prev, varStart.whitespace.prev, wordOps);
1038
1019
  const targetRequiresWhitespaceNext = tokenRequiresWhitespace(varEnd.valid.next, varEnd.whitespace.next, wordOps);
1039
- const prefixedValue = target.parent instanceof VariableNode ? (_t = (_s = target.parent) == null ? void 0 : _s.prefix) == null ? void 0 : _t.value : false;
1040
- const isSepPrev = ((_u = token2.prev) == null ? void 0 : _u.type) === TOKEN_TYPE.OP_EXPANDED_SEP;
1041
- const arrayValue = ((_v = target.parent) == null ? void 0 : _v.parent) instanceof ArrayNode;
1042
- const isRegexFlag = target === ((_w = parent.quote) == null ? void 0 : _w.flags);
1020
+ const prefixedValue = parent.type === AST_TYPE.VARIABLE ? (_o = parent == null ? void 0 : parent.prefix) == null ? void 0 : _o.value : false;
1021
+ const isSepPrev = ((_p = token2.prev) == null ? void 0 : _p.type) === TOKEN_TYPE.OP_EXPANDED_SEP;
1022
+ const arrayValue = (parentParent == null ? void 0 : parentParent.type) === AST_TYPE.ARRAY;
1023
+ const isRegexFlag = target === ((_q = parent.quote) == null ? void 0 : _q.flags);
1043
1024
  if (!isRegexFlag && !isSepPrev && !isValue && !arrayValue && !prefixedValue && opts.prefixableGroups) {
1044
1025
  suggestions.push({
1045
1026
  ...baseSuggestion,
@@ -1088,16 +1069,17 @@ class Parser {
1088
1069
  });
1089
1070
  }
1090
1071
  if (propOpTarget) {
1072
+ const propOpTargetParent = getParent(propOpTarget, parentMap);
1091
1073
  suggestions.push({
1092
1074
  ...baseSuggestion,
1093
- type: propOpTarget.parent.sep ? SUGGESTION_TYPE.EXPANDED_PROPERTY_OPERATOR : SUGGESTION_TYPE.CUSTOM_PROPERTY_OPERATOR,
1075
+ type: propOpTargetParent.sep ? SUGGESTION_TYPE.EXPANDED_PROPERTY_OPERATOR : SUGGESTION_TYPE.CUSTOM_PROPERTY_OPERATOR,
1094
1076
  requires: createDefaultRequires(),
1095
1077
  range: pos(propOpTarget)
1096
1078
  });
1097
1079
  }
1098
- const canSuggestValue = token2.whitespace.next && (token2.whitespace.prev || ((_x = token2.prev) == null ? void 0 : _x.type) === TOKEN_TYPE.BRACKETL || ((_y = token2.prev) == null ? void 0 : _y.type) === TOKEN_TYPE.PARENL) || token2.whitespace.prev && (token2.whitespace.next || ((_z = token2.next) == null ? void 0 : _z.type) === TOKEN_TYPE.BRACKETR || ((_A = token2.next) == null ? void 0 : _A.type) === TOKEN_TYPE.PARENR);
1080
+ const canSuggestValue = token2.whitespace.next && (token2.whitespace.prev || ((_r = token2.prev) == null ? void 0 : _r.type) === TOKEN_TYPE.BRACKETL || ((_s = token2.prev) == null ? void 0 : _s.type) === TOKEN_TYPE.PARENL) || token2.whitespace.prev && (token2.whitespace.next || ((_t = token2.next) == null ? void 0 : _t.type) === TOKEN_TYPE.BRACKETR || ((_u = token2.next) == null ? void 0 : _u.type) === TOKEN_TYPE.PARENR);
1099
1081
  if (canSuggestValue) {
1100
- const inArrayNode = [nextCondition, prevCondition, nextVar, prevVar].find((_) => _ instanceof ArrayNode) !== void 0;
1082
+ const inArrayNode = [nextCondition, prevCondition, nextVar, prevVar].find((_) => (_ == null ? void 0 : _.type) === AST_TYPE.ARRAY) !== void 0;
1101
1083
  const opsNotNeeded = ["and", "or"].includes(opts.onMissingBooleanOperator);
1102
1084
  if (inArrayNode || opsNotNeeded) {
1103
1085
  suggestions.push({
@@ -1118,10 +1100,13 @@ class Parser {
1118
1100
  });
1119
1101
  }
1120
1102
  }
1103
+ const tokenAtParent = getParent(token2.at, parentMap);
1104
+ const tokenValidPrevParent = getParent(token2.valid.prev, parentMap);
1105
+ const tokenValidNextParent = getParent(token2.valid.next, parentMap);
1121
1106
  const canSuggestRegexFlags = (
1122
1107
  // has existing flags before/after
1123
- token2.at && token2.at === ((_D = (_C = (_B = token2.at) == null ? void 0 : _B.parent) == null ? void 0 : _C.quote) == null ? void 0 : _D.flags) || token2.valid.prev && token2.valid.prev === ((_G = (_F = (_E = token2.valid.prev) == null ? void 0 : _E.parent) == null ? void 0 : _F.quote) == null ? void 0 : _G.flags) || token2.valid.next && token2.valid.next === ((_J = (_I = (_H = token2.valid.next) == null ? void 0 : _H.parent) == null ? void 0 : _I.quote) == null ? void 0 : _J.flags) || // no flags
1124
- ((_K = token2.valid.prev) == null ? void 0 : _K.type) === TOKEN_TYPE.REGEX && token2.valid.prev === ((_L = token2.valid.prev.parent.quote) == null ? void 0 : _L.right)
1108
+ token2.at && token2.at === ((_v = tokenAtParent == null ? void 0 : tokenAtParent.quote) == null ? void 0 : _v.flags) || token2.valid.prev && token2.valid.prev === ((_w = tokenValidPrevParent == null ? void 0 : tokenValidPrevParent.quote) == null ? void 0 : _w.flags) || token2.valid.next && token2.valid.next === ((_x = tokenValidNextParent == null ? void 0 : tokenValidNextParent.quote) == null ? void 0 : _x.flags) || // no flags
1109
+ ((_y = token2.valid.prev) == null ? void 0 : _y.type) === TOKEN_TYPE.REGEX && token2.valid.prev === ((_z = tokenValidPrevParent.quote) == null ? void 0 : _z.right)
1125
1110
  );
1126
1111
  if (canSuggestRegexFlags) {
1127
1112
  suggestions.push({
@@ -1162,12 +1147,12 @@ class Parser {
1162
1147
  evaluate(ast, context) {
1163
1148
  this._checkEvaluationOptions();
1164
1149
  const opts = this.options;
1165
- if (ast instanceof Condition) {
1150
+ if (ast.type === AST_TYPE.NORMALIZED_CONDITION) {
1166
1151
  const contextValue = get(context, ast.property);
1167
- const res = opts.valueComparer({ property: ast.property, value: ast.value, operator: ast.operator }, contextValue, context);
1152
+ const res = opts.valueComparer(ast, contextValue, context);
1168
1153
  return ast.negate ? !res : res;
1169
1154
  }
1170
- if (ast instanceof Expression) {
1155
+ if (ast.type === AST_TYPE.NORMALIZED_EXPRESSION) {
1171
1156
  const left = this.evaluate(ast.left, context);
1172
1157
  const right = this.evaluate(ast.right, context);
1173
1158
  return ast.operator === TOKEN_TYPE.AND ? left && right : left || right;
@@ -1234,10 +1219,10 @@ class Parser {
1234
1219
  * Queries like `(a || b) && (a || c)` would require all the variables to be indexed `[Set(a), Set(b), Set(c)]`.
1235
1220
  */
1236
1221
  getIndexes(ast) {
1237
- if (ast instanceof Condition) {
1222
+ if (ast.type === AST_TYPE.NORMALIZED_CONDITION) {
1238
1223
  return [new Set(ast.property.join("."))];
1239
1224
  }
1240
- if (ast instanceof Expression) {
1225
+ if (ast.type === AST_TYPE.NORMALIZED_EXPRESSION) {
1241
1226
  const left = this.getIndexes(ast.left);
1242
1227
  const right = this.getIndexes(ast.right);
1243
1228
  if (ast.operator === TOKEN_TYPE.AND) {
@@ -1304,20 +1289,20 @@ class Parser {
1304
1289
  * Normalizes the ast by applying {@link GroupNode GroupNodes} and converting {@link ConditionNode ConditionNodes} to {@link NormalizedConditionNode NormalizedConditionNodes}.
1305
1290
  */
1306
1291
  normalize(ast) {
1307
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1292
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
1308
1293
  this._checkEvaluationOptions();
1309
1294
  const opts = this.options;
1310
- if (ast instanceof ErrorToken || !ast.valid) {
1295
+ if (!ast.valid) {
1311
1296
  throw new Error("AST node must be valid.");
1312
1297
  }
1313
1298
  const prefix = arguments[1];
1314
1299
  const groupValue = arguments[2];
1315
1300
  let operator2 = arguments[3];
1316
1301
  const self_ = this;
1317
- if (ast instanceof ConditionNode) {
1318
- if (!(ast.value instanceof GroupNode)) {
1319
- const isValue = ast.value instanceof ArrayNode || ((_b = (_a = ast.value) == null ? void 0 : _a.quote) == null ? void 0 : _b.left.type) === TOKEN_TYPE.REGEX;
1320
- let name = ast.property ? unescape(ast.property.value.value) : isValue ? void 0 : unescape((_c = ast.value) == null ? void 0 : _c.value.value);
1302
+ if (ast.type === AST_TYPE.CONDITION) {
1303
+ if (!(ast.value.type === AST_TYPE.GROUP)) {
1304
+ const isValue = ast.value.type === AST_TYPE.ARRAY || ((_b = (_a = ast.value) == null ? void 0 : _a.quote) == null ? void 0 : _b.left.type) === TOKEN_TYPE.REGEX;
1305
+ let name = ((_d = (_c = ast.property) == null ? void 0 : _c.value) == null ? void 0 : _d.value) ? unescape(ast.property.value.value) : isValue ? void 0 : unescape(ast.value.value.value);
1321
1306
  const isNested = operator2 !== void 0;
1322
1307
  if (prefix !== void 0 && !isNested) {
1323
1308
  name = name ? applyPrefix(prefix, name, opts.prefixApplier) : prefix;
@@ -1327,16 +1312,16 @@ class Parser {
1327
1312
  value = name ?? true;
1328
1313
  name = prefix;
1329
1314
  } else {
1330
- value = ast.value instanceof ArrayNode ? ast.value.values.map((val) => unescape(val.value.value)) : ((_e = (_d = ast.value) == null ? void 0 : _d.quote) == null ? void 0 : _e.left.type) === TOKEN_TYPE.REGEX ? ast.value.value.value : ast.property && ast.value instanceof VariableNode ? unescape(ast.value.value.value) : true;
1315
+ value = ast.value.type === AST_TYPE.ARRAY ? ast.value.values.map((val) => unescape(val.value.value)) : ((_f = (_e = ast.value) == null ? void 0 : _e.quote) == null ? void 0 : _f.left.type) === TOKEN_TYPE.REGEX ? (_g = ast.value.value) == null ? void 0 : _g.value : ast.property && ast.value.type === AST_TYPE.VARIABLE ? unescape(ast.value.value.value) : true;
1331
1316
  }
1332
1317
  const propertyKeys = name ? opts.keyParser(name) : [];
1333
1318
  const boolValue = applyBoolean(groupValue, ast.operator === void 0);
1334
- const valuePrefix = ast.value instanceof VariableNode && ast.value.prefix ? unescape(ast.value.prefix.value) : void 0;
1335
- operator2 ?? (operator2 = (_f = ast.propertyOperator) == null ? void 0 : _f.value);
1336
- const isRegex = ((_h = (_g = ast.value) == null ? void 0 : _g.quote) == null ? void 0 : _h.left.type) === TOKEN_TYPE.REGEX;
1337
- const isQuoted = ((_i = ast.value) == null ? void 0 : _i.quote) !== void 0;
1319
+ const valuePrefix = ast.value.type === AST_TYPE.VARIABLE && ast.value.prefix ? unescape(ast.value.prefix.value) : void 0;
1320
+ operator2 ?? (operator2 = (_h = ast.propertyOperator) == null ? void 0 : _h.value);
1321
+ const isRegex = ((_j = (_i = ast.value) == null ? void 0 : _i.quote) == null ? void 0 : _j.left.type) === TOKEN_TYPE.REGEX;
1322
+ const isQuoted = ((_k = ast.value) == null ? void 0 : _k.quote) !== void 0;
1338
1323
  const isExpanded = ast.sep !== void 0;
1339
- const regexFlags = (_l = (_k = (_j = ast.value) == null ? void 0 : _j.quote) == null ? void 0 : _k.flags) == null ? void 0 : _l.value;
1324
+ const regexFlags = (_n = (_m = (_l = ast.value) == null ? void 0 : _l.quote) == null ? void 0 : _m.flags) == null ? void 0 : _n.value;
1340
1325
  const query = {
1341
1326
  value,
1342
1327
  operator: operator2,
@@ -1350,28 +1335,28 @@ class Parser {
1350
1335
  condition: ast
1351
1336
  };
1352
1337
  const res = opts.conditionNormalizer(query);
1353
- return new Condition({ property: propertyKeys, ...res });
1338
+ return createCondition({ property: propertyKeys, ...res });
1354
1339
  } else {
1355
1340
  let name = unescape(ast.property.value.value);
1356
1341
  if (prefix !== void 0) {
1357
1342
  name = applyPrefix(prefix, name, opts.prefixApplier);
1358
1343
  }
1359
1344
  const boolValue = applyBoolean(groupValue, ast.operator === void 0);
1360
- const operator22 = (_m = ast.propertyOperator) == null ? void 0 : _m.value;
1345
+ const operator22 = (_o = ast.propertyOperator) == null ? void 0 : _o.value;
1361
1346
  return self_.normalize(ast.value, name, boolValue, operator22);
1362
1347
  }
1363
1348
  }
1364
- if (ast instanceof GroupNode) {
1365
- const _prefix = ast.prefix instanceof ConditionNode && ast.prefix.value instanceof VariableNode ? unescape(ast.prefix.value.value.value) : void 0;
1366
- const _groupValue = ast.prefix instanceof ConditionNode ? ast.prefix.operator === void 0 : !(ast.prefix instanceof ValidToken);
1349
+ if (ast.type === AST_TYPE.GROUP) {
1350
+ const _prefix = ((_p = ast.prefix) == null ? void 0 : _p.type) === AST_TYPE.CONDITION && ((_q = ast.prefix) == null ? void 0 : _q.value.type) === AST_TYPE.VARIABLE ? unescape(ast.prefix.value.value.value) : void 0;
1351
+ const _groupValue = ((_r = ast.prefix) == null ? void 0 : _r.type) === AST_TYPE.CONDITION ? ast.prefix.operator === void 0 : !(((_s = ast.prefix) == null ? void 0 : _s.valid) === true);
1367
1352
  const applied = applyPrefix(prefix, _prefix ?? "", opts.prefixApplier);
1368
1353
  return self_.normalize(ast.expression, applied, applyBoolean(groupValue, _groupValue), operator2);
1369
1354
  }
1370
- if (ast instanceof ExpressionNode) {
1355
+ if (ast.type === AST_TYPE.EXPRESSION) {
1371
1356
  const left = self_.normalize(ast.left, prefix, groupValue, operator2);
1372
1357
  const right = self_.normalize(ast.right, prefix, groupValue, operator2);
1373
1358
  const type = groupValue === false ? OPPOSITE[ast.operator.type] : ast.operator.type;
1374
- return new Expression({ operator: type, left, right });
1359
+ return createExpression({ operator: type, left, right });
1375
1360
  }
1376
1361
  return unreachable();
1377
1362
  }
@@ -1382,11 +1367,11 @@ class Parser {
1382
1367
  * The context does not need to be passed. If it's not passed, the function will not attempt to get the values (so it will not error) and the contextValue param of the valueValidator will be undefined.
1383
1368
  */
1384
1369
  validate(ast, context) {
1385
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1370
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
1386
1371
  const self = this;
1387
1372
  self._checkValidationOptions();
1388
1373
  const opts = self.options;
1389
- if (ast instanceof ErrorToken || !ast.valid) {
1374
+ if (!ast.valid) {
1390
1375
  throw new Error("AST node must be valid.");
1391
1376
  }
1392
1377
  const prefix = arguments[2];
@@ -1395,9 +1380,9 @@ class Parser {
1395
1380
  const prefixes = arguments[5] ?? [];
1396
1381
  let operator2 = arguments[6];
1397
1382
  const self_ = this;
1398
- if (ast instanceof ConditionNode) {
1399
- if (!(ast.value instanceof GroupNode)) {
1400
- const isValue = ast.value instanceof ArrayNode || ((_b = (_a = ast.value) == null ? void 0 : _a.quote) == null ? void 0 : _b.left.type) === TOKEN_TYPE.REGEX;
1383
+ if (ast.type === AST_TYPE.CONDITION) {
1384
+ if (!(ast.value.type === AST_TYPE.GROUP)) {
1385
+ const isValue = ast.value.type === AST_TYPE.ARRAY || ((_b = (_a = ast.value) == null ? void 0 : _a.quote) == null ? void 0 : _b.left.type) === TOKEN_TYPE.REGEX;
1401
1386
  const nameNode = ast.property ? ast.property : isValue ? void 0 : ast.value;
1402
1387
  let name = nameNode ? unescape(nameNode.value.value) : void 0;
1403
1388
  const isNested = operator2 !== void 0;
@@ -1412,12 +1397,12 @@ class Parser {
1412
1397
  propertyNodes = [...prefixes];
1413
1398
  } else {
1414
1399
  propertyNodes = [...prefixes, ...nameNode ? [nameNode] : []];
1415
- value = ast.value instanceof ArrayNode ? ast.value.values : ((_d = (_c = ast.value) == null ? void 0 : _c.quote) == null ? void 0 : _d.left.type) === TOKEN_TYPE.REGEX ? ast.value : ast.property && ast.value instanceof VariableNode ? ast.value : true;
1400
+ value = ast.value.type === AST_TYPE.ARRAY ? ast.value.values : ((_d = (_c = ast.value) == null ? void 0 : _c.quote) == null ? void 0 : _d.left.type) === TOKEN_TYPE.REGEX ? ast.value : ast.property && ast.value.type === AST_TYPE.VARIABLE ? ast.value : true;
1416
1401
  }
1417
1402
  const propertyKeys = name ? opts.keyParser(name) : [];
1418
1403
  const contextValue = context !== void 0 ? get(context, propertyKeys) : void 0;
1419
1404
  const boolValue = applyBoolean(groupValue, ast.operator === void 0);
1420
- const valuePrefix = ast.value instanceof VariableNode && ast.value.prefix ? ast.value.prefix : void 0;
1405
+ const valuePrefix = ast.value.type === AST_TYPE.VARIABLE && ast.value.prefix ? ast.value.prefix : void 0;
1421
1406
  operator2 ?? (operator2 = ast.propertyOperator);
1422
1407
  const isRegex = ((_f = (_e = ast.value) == null ? void 0 : _e.quote) == null ? void 0 : _f.left.type) === TOKEN_TYPE.REGEX;
1423
1408
  const isQuoted = ((_g = ast.value) == null ? void 0 : _g.quote) !== void 0;
@@ -1457,14 +1442,14 @@ class Parser {
1457
1442
  self_.validate(ast.value, context, name, boolValue, results, prefixes, operator22);
1458
1443
  }
1459
1444
  }
1460
- if (ast instanceof GroupNode) {
1461
- const _prefix = ast.prefix instanceof ConditionNode && ast.prefix.value instanceof VariableNode ? ast.prefix.value : void 0;
1445
+ if (ast.type === AST_TYPE.GROUP) {
1446
+ const _prefix = ((_j = ast.prefix) == null ? void 0 : _j.type) === AST_TYPE.CONDITION && ast.prefix.value.type === AST_TYPE.VARIABLE ? ast.prefix.value : void 0;
1462
1447
  if (_prefix)
1463
1448
  prefixes.push(_prefix);
1464
- const _groupValue = ast.prefix instanceof ConditionNode ? ast.prefix.operator === void 0 : !(ast.prefix instanceof ValidToken);
1449
+ const _groupValue = ((_k = ast.prefix) == null ? void 0 : _k.type) === AST_TYPE.CONDITION ? ast.prefix.operator === void 0 : !(((_l = ast.prefix) == null ? void 0 : _l.valid) === true);
1465
1450
  self_.validate(ast.expression, context, applyPrefix(prefix, (_prefix == null ? void 0 : _prefix.value.value) ?? "", opts.prefixApplier), applyBoolean(groupValue, _groupValue), results, prefixes, operator2);
1466
1451
  }
1467
- if (ast instanceof ExpressionNode) {
1452
+ if (ast.type === AST_TYPE.EXPRESSION) {
1468
1453
  self_.validate(ast.left, context, prefix, groupValue, results, [...prefixes], operator2);
1469
1454
  self_.validate(ast.right, context, prefix, groupValue, results, [...prefixes], operator2);
1470
1455
  }
@@ -1,6 +1,4 @@
1
- import { type Position } from "../../types/ast.js";
2
- import { ArrayNode } from "../classes/ArrayNode.js";
3
- import type { VariableNode } from "../classes/VariableNode.js";
1
+ import { type ArrayNode, type Position, type VariableNode } from "../../types/ast.js";
4
2
  export declare function array(values: VariableNode[], bracket?: {
5
3
  left?: boolean;
6
4
  right?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../src/ast/builders/array.ts"],"names":[],"mappings":"AAIA,OAAO,EAAY,KAAK,QAAQ,EAAc,MAAM,oBAAoB,CAAA;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAG9D,wBAAgB,KAAK,CACpB,MAAM,EAAE,YAAY,EAAE,EACtB,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAgC,EAC1E,YAAY,CAAC,EAAE,QAAQ,EACvB,aAAa,CAAC,EAAE,QAAQ,GACtB,SAAS,CA8BX"}
1
+ {"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../src/ast/builders/array.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAkB,KAAK,QAAQ,EAAc,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAIjH,wBAAgB,KAAK,CACpB,MAAM,EAAE,YAAY,EAAE,EACtB,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAgC,EAC1E,YAAY,CAAC,EAAE,QAAQ,EACvB,aAAa,CAAC,EAAE,QAAQ,GACtB,SAAS,CA4BX"}
@@ -1,10 +1,9 @@
1
1
  import { token } from "./token.js";
2
- import { AST_TYPE, TOKEN_TYPE } from "../../types/ast.js";
3
- import { ArrayNode } from "../classes/ArrayNode.js";
2
+ import { TOKEN_TYPE } from "../../types/ast.js";
3
+ import { createArrayNode } from "../createArrayNode.js";
4
4
  function array(values, bracket = { right: true, left: true }, parenLeftPos, parenRightPos) {
5
5
  var _a, _b, _c, _d, _e, _f;
6
6
  const node = {
7
- type: AST_TYPE.ARRAY,
8
7
  values
9
8
  };
10
9
  node.bracket = {};
@@ -23,8 +22,7 @@ function array(values, bracket = { right: true, left: true }, parenLeftPos, pare
23
22
  }
24
23
  node.start = ((_c = node.bracket.left) == null ? void 0 : _c.start) ?? start ?? ((_d = node.bracket) == null ? void 0 : _d.right.start);
25
24
  node.end = ((_f = (_e = node.bracket) == null ? void 0 : _e.right) == null ? void 0 : _f.end) ?? end ?? node.bracket.left.end;
26
- const instance = new ArrayNode(node);
27
- return instance;
25
+ return createArrayNode(node);
28
26
  }
29
27
  export {
30
28
  array