@mojir/lits 2.0.22 → 2.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.
Files changed (206) hide show
  1. package/dist/cli/cli/src/cliDocumentation/getCliType.d.ts +1 -1
  2. package/dist/cli/cli.js +7146 -9278
  3. package/dist/cli/reference/api.d.ts +21 -18
  4. package/dist/cli/reference/categories/array.d.ts +2 -2
  5. package/dist/cli/reference/categories/assert.d.ts +2 -2
  6. package/dist/cli/reference/categories/bitwise.d.ts +2 -2
  7. package/dist/cli/reference/categories/collection.d.ts +2 -2
  8. package/dist/cli/reference/categories/functional.d.ts +2 -2
  9. package/dist/cli/reference/categories/math.d.ts +1 -1
  10. package/dist/cli/reference/categories/misc.d.ts +1 -1
  11. package/dist/cli/reference/categories/object.d.ts +1 -1
  12. package/dist/cli/reference/categories/regularExpression.d.ts +1 -1
  13. package/dist/cli/reference/categories/sequence.d.ts +1 -1
  14. package/dist/cli/reference/categories/specialExpressions.d.ts +3 -3
  15. package/dist/cli/reference/categories/string.d.ts +1 -1
  16. package/dist/cli/reference/index.d.ts +225 -16
  17. package/dist/cli/src/Lits/Cache.d.ts +1 -1
  18. package/dist/cli/src/Lits/Lits.d.ts +15 -15
  19. package/dist/cli/src/builtin/bindingNode.d.ts +4 -0
  20. package/dist/cli/src/builtin/index.d.ts +43 -23
  21. package/dist/cli/src/builtin/interface.d.ts +11 -11
  22. package/dist/cli/src/builtin/specialExpressions/and.d.ts +1 -1
  23. package/dist/cli/src/builtin/specialExpressions/array.d.ts +6 -0
  24. package/dist/cli/src/builtin/specialExpressions/cond.d.ts +1 -1
  25. package/dist/cli/src/builtin/specialExpressions/declared.d.ts +1 -1
  26. package/dist/cli/src/builtin/specialExpressions/def.d.ts +5 -2
  27. package/dist/cli/src/builtin/specialExpressions/do.d.ts +1 -1
  28. package/dist/cli/src/builtin/specialExpressions/functions.d.ts +11 -6
  29. package/dist/cli/src/builtin/specialExpressions/if.d.ts +1 -1
  30. package/dist/cli/src/builtin/specialExpressions/let.d.ts +5 -3
  31. package/dist/cli/src/builtin/specialExpressions/loop.d.ts +2 -2
  32. package/dist/cli/src/builtin/specialExpressions/loops.d.ts +1 -1
  33. package/dist/cli/src/builtin/specialExpressions/object.d.ts +6 -0
  34. package/dist/cli/src/builtin/specialExpressions/or.d.ts +1 -1
  35. package/dist/cli/src/builtin/specialExpressions/qq.d.ts +1 -1
  36. package/dist/cli/src/builtin/specialExpressions/recur.d.ts +1 -1
  37. package/dist/cli/src/builtin/specialExpressions/switch.d.ts +1 -1
  38. package/dist/cli/src/builtin/specialExpressions/throw.d.ts +1 -1
  39. package/dist/cli/src/builtin/specialExpressions/try.d.ts +1 -1
  40. package/dist/cli/src/builtin/specialExpressions/unless.d.ts +1 -1
  41. package/dist/cli/src/builtin/utils.d.ts +5 -14
  42. package/dist/cli/src/cliDocumentation/getCliType.d.ts +1 -1
  43. package/dist/cli/src/constants/constants.d.ts +5 -28
  44. package/dist/cli/src/errors.d.ts +1 -1
  45. package/dist/cli/src/evaluator/ContextStack.d.ts +7 -7
  46. package/dist/cli/src/evaluator/functionExecutors.d.ts +3 -3
  47. package/dist/cli/src/evaluator/index.d.ts +1 -1
  48. package/dist/cli/src/evaluator/interface.d.ts +3 -3
  49. package/dist/cli/src/getUndefinedSymbols/index.d.ts +7 -0
  50. package/dist/cli/src/interface.d.ts +1 -2
  51. package/dist/cli/src/parser/{AlgebraicParser.d.ts → Parser.d.ts} +17 -14
  52. package/dist/cli/src/parser/{interface.d.ts → types.d.ts} +90 -76
  53. package/dist/cli/src/symbolPatterns.d.ts +2 -0
  54. package/dist/cli/src/tokenizer/minifyTokenStream.d.ts +1 -1
  55. package/dist/cli/src/tokenizer/operators.d.ts +12 -0
  56. package/dist/cli/src/tokenizer/reservedNames.d.ts +115 -0
  57. package/dist/cli/src/tokenizer/token.d.ts +85 -0
  58. package/dist/cli/src/tokenizer/tokenize.d.ts +8 -0
  59. package/dist/cli/src/tokenizer/tokenizers.d.ts +12 -0
  60. package/dist/cli/src/transformer/index.d.ts +2 -2
  61. package/dist/cli/src/typeGuards/array.d.ts +1 -1
  62. package/dist/cli/src/typeGuards/astNode.d.ts +2 -2
  63. package/dist/cli/src/typeGuards/index.d.ts +7 -3
  64. package/dist/cli/src/typeGuards/lits.d.ts +2 -2
  65. package/dist/cli/src/typeGuards/litsFunction.d.ts +2 -2
  66. package/dist/cli/src/typeGuards/number.d.ts +1 -1
  67. package/dist/cli/src/typeGuards/string.d.ts +1 -1
  68. package/dist/cli/src/untokenizer/index.d.ts +1 -1
  69. package/dist/cli/src/utils/debug/getCodeMarker.d.ts +1 -1
  70. package/dist/cli/src/utils/debug/getSourceCodeInfo.d.ts +2 -2
  71. package/dist/cli/src/utils/getAssertionError.d.ts +1 -1
  72. package/dist/cli/src/utils/index.d.ts +5 -3
  73. package/dist/index.esm.js +7293 -9419
  74. package/dist/index.esm.js.map +1 -1
  75. package/dist/index.js +7292 -9424
  76. package/dist/index.js.map +1 -1
  77. package/dist/lits.iife.js +7292 -9424
  78. package/dist/lits.iife.js.map +1 -1
  79. package/dist/reference/api.d.ts +21 -18
  80. package/dist/reference/categories/array.d.ts +2 -2
  81. package/dist/reference/categories/assert.d.ts +2 -2
  82. package/dist/reference/categories/bitwise.d.ts +2 -2
  83. package/dist/reference/categories/collection.d.ts +2 -2
  84. package/dist/reference/categories/functional.d.ts +2 -2
  85. package/dist/reference/categories/math.d.ts +1 -1
  86. package/dist/reference/categories/misc.d.ts +1 -1
  87. package/dist/reference/categories/object.d.ts +1 -1
  88. package/dist/reference/categories/regularExpression.d.ts +1 -1
  89. package/dist/reference/categories/sequence.d.ts +1 -1
  90. package/dist/reference/categories/specialExpressions.d.ts +3 -3
  91. package/dist/reference/categories/string.d.ts +1 -1
  92. package/dist/reference/index.d.ts +225 -16
  93. package/dist/src/Lits/Cache.d.ts +1 -1
  94. package/dist/src/Lits/Lits.d.ts +15 -15
  95. package/dist/src/builtin/bindingNode.d.ts +4 -0
  96. package/dist/src/builtin/index.d.ts +43 -23
  97. package/dist/src/builtin/interface.d.ts +11 -11
  98. package/dist/src/builtin/specialExpressions/and.d.ts +1 -1
  99. package/dist/src/builtin/specialExpressions/array.d.ts +6 -0
  100. package/dist/src/builtin/specialExpressions/cond.d.ts +1 -1
  101. package/dist/src/builtin/specialExpressions/declared.d.ts +1 -1
  102. package/dist/src/builtin/specialExpressions/def.d.ts +5 -2
  103. package/dist/src/builtin/specialExpressions/do.d.ts +1 -1
  104. package/dist/src/builtin/specialExpressions/functions.d.ts +11 -6
  105. package/dist/src/builtin/specialExpressions/if.d.ts +1 -1
  106. package/dist/src/builtin/specialExpressions/let.d.ts +5 -3
  107. package/dist/src/builtin/specialExpressions/loop.d.ts +2 -2
  108. package/dist/src/builtin/specialExpressions/loops.d.ts +1 -1
  109. package/dist/src/builtin/specialExpressions/object.d.ts +6 -0
  110. package/dist/src/builtin/specialExpressions/or.d.ts +1 -1
  111. package/dist/src/builtin/specialExpressions/qq.d.ts +1 -1
  112. package/dist/src/builtin/specialExpressions/recur.d.ts +1 -1
  113. package/dist/src/builtin/specialExpressions/switch.d.ts +1 -1
  114. package/dist/src/builtin/specialExpressions/throw.d.ts +1 -1
  115. package/dist/src/builtin/specialExpressions/try.d.ts +1 -1
  116. package/dist/src/builtin/specialExpressions/unless.d.ts +1 -1
  117. package/dist/src/builtin/utils.d.ts +5 -14
  118. package/dist/src/constants/constants.d.ts +5 -28
  119. package/dist/src/errors.d.ts +1 -1
  120. package/dist/src/evaluator/ContextStack.d.ts +7 -7
  121. package/dist/src/evaluator/functionExecutors.d.ts +3 -3
  122. package/dist/src/evaluator/index.d.ts +1 -1
  123. package/dist/src/evaluator/interface.d.ts +3 -3
  124. package/dist/src/getUndefinedSymbols/index.d.ts +7 -0
  125. package/dist/src/index.d.ts +6 -9
  126. package/dist/src/interface.d.ts +1 -2
  127. package/dist/src/parser/{AlgebraicParser.d.ts → Parser.d.ts} +17 -14
  128. package/dist/src/parser/{interface.d.ts → types.d.ts} +90 -76
  129. package/dist/src/symbolPatterns.d.ts +2 -0
  130. package/dist/src/tokenizer/minifyTokenStream.d.ts +1 -1
  131. package/dist/src/tokenizer/operators.d.ts +12 -0
  132. package/dist/src/tokenizer/reservedNames.d.ts +115 -0
  133. package/dist/src/tokenizer/token.d.ts +85 -0
  134. package/dist/src/tokenizer/tokenize.d.ts +8 -0
  135. package/dist/src/tokenizer/tokenizers.d.ts +12 -0
  136. package/dist/src/transformer/index.d.ts +2 -2
  137. package/dist/src/typeGuards/array.d.ts +1 -1
  138. package/dist/src/typeGuards/astNode.d.ts +2 -2
  139. package/dist/src/typeGuards/index.d.ts +7 -3
  140. package/dist/src/typeGuards/lits.d.ts +2 -2
  141. package/dist/src/typeGuards/litsFunction.d.ts +2 -2
  142. package/dist/src/typeGuards/number.d.ts +1 -1
  143. package/dist/src/typeGuards/string.d.ts +1 -1
  144. package/dist/src/untokenizer/index.d.ts +1 -1
  145. package/dist/src/utils/debug/getCodeMarker.d.ts +1 -1
  146. package/dist/src/utils/debug/getSourceCodeInfo.d.ts +2 -2
  147. package/dist/src/utils/getAssertionError.d.ts +1 -1
  148. package/dist/src/utils/index.d.ts +5 -3
  149. package/dist/testFramework.esm.js +3102 -4317
  150. package/dist/testFramework.esm.js.map +1 -1
  151. package/dist/testFramework.js +3102 -4317
  152. package/dist/testFramework.js.map +1 -1
  153. package/package.json +2 -2
  154. package/dist/cli/common/clojureDocs.d.ts +0 -1
  155. package/dist/cli/src/analyze/findUnresolvedIdentifiers.d.ts +0 -2
  156. package/dist/cli/src/analyze/index.d.ts +0 -15
  157. package/dist/cli/src/analyze/utils.d.ts +0 -4
  158. package/dist/cli/src/builtin/specialExpressions/comment.d.ts +0 -5
  159. package/dist/cli/src/builtin/specialExpressions/commonParser.d.ts +0 -4
  160. package/dist/cli/src/identifier.d.ts +0 -4
  161. package/dist/cli/src/index.d.ts +0 -18
  162. package/dist/cli/src/parser/PolishTokenParsers.d.ts +0 -3
  163. package/dist/cli/src/parser/commonTokenParsers.d.ts +0 -7
  164. package/dist/cli/src/parser/index.d.ts +0 -3
  165. package/dist/cli/src/removeCommentNodes/index.d.ts +0 -11
  166. package/dist/cli/src/removeCommentNodes/removeCommentNodesFromSpecialExpression.d.ts +0 -3
  167. package/dist/cli/src/tokenizer/algebraic/algebraicReservedNames.d.ts +0 -107
  168. package/dist/cli/src/tokenizer/algebraic/algebraicTokenizers.d.ts +0 -11
  169. package/dist/cli/src/tokenizer/algebraic/algebraicTokens.d.ts +0 -66
  170. package/dist/cli/src/tokenizer/common/commonTokenizers.d.ts +0 -9
  171. package/dist/cli/src/tokenizer/common/commonTokens.d.ts +0 -43
  172. package/dist/cli/src/tokenizer/index.d.ts +0 -2
  173. package/dist/cli/src/tokenizer/interface.d.ts +0 -22
  174. package/dist/cli/src/tokenizer/polish/polishReservedNames.d.ts +0 -7
  175. package/dist/cli/src/tokenizer/polish/polishTokenizers.d.ts +0 -13
  176. package/dist/cli/src/tokenizer/polish/polishTokens.d.ts +0 -55
  177. package/dist/cli/src/tokenizer/sugar/applyCollectionAccessor.d.ts +0 -2
  178. package/dist/cli/src/tokenizer/sugar/index.d.ts +0 -3
  179. package/dist/cli/src/tokenizer/tokens.d.ts +0 -20
  180. package/dist/cli/src/tokenizer/utils.d.ts +0 -9
  181. package/dist/common/clojureDocs.d.ts +0 -1
  182. package/dist/src/analyze/findUnresolvedIdentifiers.d.ts +0 -2
  183. package/dist/src/analyze/index.d.ts +0 -15
  184. package/dist/src/analyze/utils.d.ts +0 -4
  185. package/dist/src/builtin/specialExpressions/comment.d.ts +0 -5
  186. package/dist/src/builtin/specialExpressions/commonParser.d.ts +0 -4
  187. package/dist/src/identifier.d.ts +0 -4
  188. package/dist/src/parser/PolishTokenParsers.d.ts +0 -3
  189. package/dist/src/parser/commonTokenParsers.d.ts +0 -7
  190. package/dist/src/parser/index.d.ts +0 -3
  191. package/dist/src/removeCommentNodes/index.d.ts +0 -11
  192. package/dist/src/removeCommentNodes/removeCommentNodesFromSpecialExpression.d.ts +0 -3
  193. package/dist/src/tokenizer/algebraic/algebraicReservedNames.d.ts +0 -107
  194. package/dist/src/tokenizer/algebraic/algebraicTokenizers.d.ts +0 -11
  195. package/dist/src/tokenizer/algebraic/algebraicTokens.d.ts +0 -66
  196. package/dist/src/tokenizer/common/commonTokenizers.d.ts +0 -9
  197. package/dist/src/tokenizer/common/commonTokens.d.ts +0 -43
  198. package/dist/src/tokenizer/index.d.ts +0 -2
  199. package/dist/src/tokenizer/interface.d.ts +0 -22
  200. package/dist/src/tokenizer/polish/polishReservedNames.d.ts +0 -7
  201. package/dist/src/tokenizer/polish/polishTokenizers.d.ts +0 -13
  202. package/dist/src/tokenizer/polish/polishTokens.d.ts +0 -55
  203. package/dist/src/tokenizer/sugar/applyCollectionAccessor.d.ts +0 -2
  204. package/dist/src/tokenizer/sugar/index.d.ts +0 -3
  205. package/dist/src/tokenizer/tokens.d.ts +0 -20
  206. package/dist/src/tokenizer/utils.d.ts +0 -9
@@ -1,16 +1,15 @@
1
- import type { FindUnresolvedIdentifiers, UnresolvedIdentifiers } from '../analyze';
1
+ import type { GetUndefinedSymbols, UndefinedSymbols } from '../getUndefinedSymbols';
2
2
  import type { ContextStack } from '../evaluator/ContextStack';
3
3
  import type { EvaluateAstNode, ExecuteFunction } from '../evaluator/interface';
4
4
  import type { Any, Arr } from '../interface';
5
- import type { ParseArgument, ParseBinding, ParseBindings, ParseExpression, ParseState, ParseToken, ParseTokensUntilClosingBracket } from '../parser/interface';
6
- import type { SourceCodeInfo, TokenStream } from '../tokenizer/interface';
7
- import type { Token } from '../tokenizer/tokens';
5
+ import type { ParseArgument, ParseBinding, ParseBindings, ParseExpression, ParseToken, ParseTokensUntilClosingBracket } from '../parser/types';
6
+ import type { SourceCodeInfo } from '../tokenizer/token';
8
7
  import type { BuiltinSpecialExpressions, SpecialExpressionNode } from '.';
9
8
  export type Count = number | {
10
9
  min?: number;
11
10
  max?: number;
12
- even?: boolean;
13
- odd?: boolean;
11
+ even?: true;
12
+ odd?: true;
14
13
  };
15
14
  export type NormalExpressionEvaluator<T> = (params: Arr, sourceCodeInfo: SourceCodeInfo | undefined, contextStack: ContextStack, { executeFunction }: {
16
15
  executeFunction: ExecuteFunction;
@@ -18,6 +17,7 @@ export type NormalExpressionEvaluator<T> = (params: Arr, sourceCodeInfo: SourceC
18
17
  interface BuiltinNormalExpression<T> {
19
18
  evaluate: NormalExpressionEvaluator<T>;
20
19
  paramCount: Count;
20
+ aliases?: string[];
21
21
  }
22
22
  export interface ParserHelpers {
23
23
  parseExpression: ParseExpression;
@@ -28,19 +28,19 @@ export interface ParserHelpers {
28
28
  parseArgument: ParseArgument;
29
29
  }
30
30
  export type BuiltinNormalExpressions = Record<string, BuiltinNormalExpression<Any>>;
31
- interface EvaluateHelpers {
31
+ export interface EvaluateHelpers {
32
32
  evaluateAstNode: EvaluateAstNode;
33
33
  builtin: Builtin;
34
+ getUndefinedSymbols: GetUndefinedSymbols;
34
35
  }
35
36
  export interface BuiltinSpecialExpression<T, N extends SpecialExpressionNode> {
36
- polishParse: (tokenStream: TokenStream, parseState: ParseState, firstToken: Token, parsers: ParserHelpers) => N;
37
37
  evaluate: (node: N, contextStack: ContextStack, helpers: EvaluateHelpers) => T;
38
38
  paramCount: Count;
39
- findUnresolvedIdentifiers: (node: N, contextStack: ContextStack, params: {
40
- findUnresolvedIdentifiers: FindUnresolvedIdentifiers;
39
+ getUndefinedSymbols: (node: N, contextStack: ContextStack, params: {
40
+ getUndefinedSymbols: GetUndefinedSymbols;
41
41
  builtin: Builtin;
42
42
  evaluateAstNode: EvaluateAstNode;
43
- }) => UnresolvedIdentifiers;
43
+ }) => UndefinedSymbols;
44
44
  }
45
45
  export interface Builtin {
46
46
  normalExpressions: BuiltinNormalExpressions;
@@ -1,5 +1,5 @@
1
1
  import type { Any } from '../../interface';
2
- import type { CommonSpecialExpressionNode } from '../../parser/interface';
2
+ import type { CommonSpecialExpressionNode } from '../../parser/types';
3
3
  import type { BuiltinSpecialExpression } from '../interface';
4
4
  export interface AndNode extends CommonSpecialExpressionNode<'&&'> {
5
5
  }
@@ -0,0 +1,6 @@
1
+ import type { Any } from '../../interface';
2
+ import type { CommonSpecialExpressionNode } from '../../parser/types';
3
+ import type { BuiltinSpecialExpression } from '../interface';
4
+ export interface ArrayNode extends CommonSpecialExpressionNode<'array'> {
5
+ }
6
+ export declare const arraySpecialExpression: BuiltinSpecialExpression<Any, ArrayNode>;
@@ -1,5 +1,5 @@
1
1
  import type { Any } from '../../interface';
2
- import type { CommonSpecialExpressionNode } from '../../parser/interface';
2
+ import type { CommonSpecialExpressionNode } from '../../parser/types';
3
3
  import type { BuiltinSpecialExpression } from '../interface';
4
4
  export interface CondNode extends CommonSpecialExpressionNode<'cond'> {
5
5
  }
@@ -1,4 +1,4 @@
1
- import type { CommonSpecialExpressionNode } from '../../parser/interface';
1
+ import type { CommonSpecialExpressionNode } from '../../parser/types';
2
2
  import type { BuiltinSpecialExpression } from '../interface';
3
3
  export interface DeclaredNode extends CommonSpecialExpressionNode<'defined?'> {
4
4
  }
@@ -1,5 +1,8 @@
1
- import type { CommonSpecialExpressionNode } from '../../parser/interface';
1
+ import type { BindingNode, GenericNode } from '../../parser/types';
2
2
  import type { BuiltinSpecialExpression } from '../interface';
3
- export interface DefNode extends CommonSpecialExpressionNode<'def'> {
3
+ export interface DefNode extends GenericNode {
4
+ name: 'def';
5
+ type: 'SpecialExpression';
6
+ bindingNode: BindingNode;
4
7
  }
5
8
  export declare const defSpecialExpression: BuiltinSpecialExpression<null, DefNode>;
@@ -1,5 +1,5 @@
1
1
  import type { Any } from '../../interface';
2
- import type { CommonSpecialExpressionNode } from '../../parser/interface';
2
+ import type { CommonSpecialExpressionNode } from '../../parser/types';
3
3
  import type { BuiltinSpecialExpression } from '../interface';
4
4
  export interface DoNode extends CommonSpecialExpressionNode<'do'> {
5
5
  }
@@ -1,13 +1,18 @@
1
- import type { AstNode, CommonSpecialExpressionNode, LitsFunction, SymbolNode } from '../../parser/interface';
1
+ import type { AstNode, CommonSpecialExpressionNode, LitsFunction, SymbolNode } from '../../parser/types';
2
2
  import type { BuiltinSpecialExpression } from '../interface';
3
- import type { FunctionOverload } from '../utils';
3
+ import type { Function } from '../utils';
4
4
  export interface DefnNode extends CommonSpecialExpressionNode<'defn'> {
5
- f: SymbolNode;
6
- o: FunctionOverload[];
5
+ functionName: SymbolNode;
6
+ function: Function;
7
+ }
8
+ export interface FunctionNode extends CommonSpecialExpressionNode<'function'> {
9
+ functionName: SymbolNode;
10
+ function: Function;
7
11
  }
8
12
  export interface FnNode extends CommonSpecialExpressionNode<'fn'> {
9
- p: AstNode[];
10
- o: FunctionOverload[];
13
+ params: AstNode[];
14
+ function: Function;
11
15
  }
16
+ export declare const functionSpecialExpression: BuiltinSpecialExpression<null, FunctionNode>;
12
17
  export declare const defnSpecialExpression: BuiltinSpecialExpression<null, DefnNode>;
13
18
  export declare const fnSpecialExpression: BuiltinSpecialExpression<LitsFunction, FnNode>;
@@ -1,5 +1,5 @@
1
1
  import type { Any } from '../../interface';
2
- import type { CommonSpecialExpressionNode } from '../../parser/interface';
2
+ import type { CommonSpecialExpressionNode } from '../../parser/types';
3
3
  import type { BuiltinSpecialExpression } from '../interface';
4
4
  export interface IfNode extends CommonSpecialExpressionNode<'if'> {
5
5
  }
@@ -1,7 +1,9 @@
1
1
  import type { Any } from '../../interface';
2
- import type { BindingNode, CommonSpecialExpressionNode } from '../../parser/interface';
2
+ import type { BindingNode, GenericNode } from '../../parser/types';
3
3
  import type { BuiltinSpecialExpression } from '../interface';
4
- export interface LetNode extends CommonSpecialExpressionNode<'let'> {
5
- bs: BindingNode[];
4
+ export interface LetNode extends GenericNode {
5
+ type: 'SpecialExpression';
6
+ bindingNode: BindingNode;
7
+ name: 'let';
6
8
  }
7
9
  export declare const letSpecialExpression: BuiltinSpecialExpression<Any, LetNode>;
@@ -1,7 +1,7 @@
1
1
  import type { Any } from '../../interface';
2
- import type { BindingNode, CommonSpecialExpressionNode } from '../../parser/interface';
2
+ import type { BindingNode, CommonSpecialExpressionNode } from '../../parser/types';
3
3
  import type { BuiltinSpecialExpression } from '../interface';
4
4
  export interface LoopNode extends CommonSpecialExpressionNode<'loop'> {
5
- bs: BindingNode[];
5
+ bindingNodes: BindingNode[];
6
6
  }
7
7
  export declare const loopSpecialExpression: BuiltinSpecialExpression<Any, LoopNode>;
@@ -1,5 +1,5 @@
1
1
  import type { Any } from '../../interface';
2
- import type { AstNode, BindingNode, CommonSpecialExpressionNode } from '../../parser/interface';
2
+ import type { AstNode, BindingNode, CommonSpecialExpressionNode } from '../../parser/types';
3
3
  import type { BuiltinSpecialExpression } from '../interface';
4
4
  export interface ForNode extends CommonSpecialExpressionNode<'for'> {
5
5
  l: LoopBindingNode[];
@@ -0,0 +1,6 @@
1
+ import type { Any } from '../../interface';
2
+ import type { CommonSpecialExpressionNode } from '../../parser/types';
3
+ import type { BuiltinSpecialExpression } from '../interface';
4
+ export interface ObjectNode extends CommonSpecialExpressionNode<'object'> {
5
+ }
6
+ export declare const objectSpecialExpression: BuiltinSpecialExpression<Any, ObjectNode>;
@@ -1,5 +1,5 @@
1
1
  import type { Any } from '../../interface';
2
- import type { CommonSpecialExpressionNode } from '../../parser/interface';
2
+ import type { CommonSpecialExpressionNode } from '../../parser/types';
3
3
  import type { BuiltinSpecialExpression } from '../interface';
4
4
  export interface OrNode extends CommonSpecialExpressionNode<'||'> {
5
5
  }
@@ -1,5 +1,5 @@
1
1
  import type { Any } from '../../interface';
2
- import type { CommonSpecialExpressionNode } from '../../parser/interface';
2
+ import type { CommonSpecialExpressionNode } from '../../parser/types';
3
3
  import type { BuiltinSpecialExpression } from '../interface';
4
4
  export interface QqNode extends CommonSpecialExpressionNode<'??'> {
5
5
  }
@@ -1,4 +1,4 @@
1
- import type { CommonSpecialExpressionNode } from '../../parser/interface';
1
+ import type { CommonSpecialExpressionNode } from '../../parser/types';
2
2
  import type { BuiltinSpecialExpression } from '../interface';
3
3
  export interface RecurNode extends CommonSpecialExpressionNode<'recur'> {
4
4
  }
@@ -1,5 +1,5 @@
1
1
  import type { Any } from '../../interface';
2
- import type { CommonSpecialExpressionNode } from '../../parser/interface';
2
+ import type { CommonSpecialExpressionNode } from '../../parser/types';
3
3
  import type { BuiltinSpecialExpression } from '../interface';
4
4
  export interface SwitchNode extends CommonSpecialExpressionNode<'switch'> {
5
5
  }
@@ -1,4 +1,4 @@
1
- import type { CommonSpecialExpressionNode } from '../../parser/interface';
1
+ import type { CommonSpecialExpressionNode } from '../../parser/types';
2
2
  import type { BuiltinSpecialExpression } from '../interface';
3
3
  export interface ThrowNode extends CommonSpecialExpressionNode<'throw'> {
4
4
  }
@@ -1,5 +1,5 @@
1
1
  import type { Any } from '../../interface';
2
- import type { AstNode, CommonSpecialExpressionNode, SymbolNode } from '../../parser/interface';
2
+ import type { AstNode, CommonSpecialExpressionNode, SymbolNode } from '../../parser/types';
3
3
  import type { BuiltinSpecialExpression } from '../interface';
4
4
  export interface TryNode extends CommonSpecialExpressionNode<'try'> {
5
5
  e: SymbolNode | undefined;
@@ -1,5 +1,5 @@
1
1
  import type { Any } from '../../interface';
2
- import type { CommonSpecialExpressionNode } from '../../parser/interface';
2
+ import type { CommonSpecialExpressionNode } from '../../parser/types';
3
3
  import type { BuiltinSpecialExpression } from '../interface';
4
4
  export interface UnlessNode extends CommonSpecialExpressionNode<'unless'> {
5
5
  }
@@ -1,18 +1,9 @@
1
1
  import type { ContextStack } from '../evaluator/ContextStack';
2
- import type { AstNode, BindingNode } from '../parser/interface';
3
- import type { SourceCodeInfo } from '../tokenizer/interface';
2
+ import type { AstNode, BindingTarget } from '../parser/types';
3
+ import type { SourceCodeInfo } from '../tokenizer/token';
4
4
  import type { Builtin } from './interface';
5
- export type Arity = number | {
6
- min: number;
7
- };
8
- export interface FunctionOverload {
9
- as: FunctionArguments;
10
- a: Arity;
11
- b: AstNode[];
12
- }
13
- export interface FunctionArguments {
14
- m: string[];
15
- r?: string;
16
- b: BindingNode[];
5
+ export interface Function {
6
+ arguments: BindingTarget[];
7
+ body: AstNode[];
17
8
  }
18
9
  export declare function assertNameNotDefined<T>(name: T, contextStack: ContextStack, builtin: Builtin, sourceCodeInfo?: SourceCodeInfo): asserts name is T;
@@ -1,30 +1,7 @@
1
- export declare enum AstNodeType {
2
- Number = 201,
3
- String = 202,
4
- NormalExpression = 203,
5
- SpecialExpression = 204,
6
- Symbol = 205,
7
- Modifier = 206,
8
- ReservedSymbol = 207,
9
- Binding = 208,
10
- Argument = 209,
11
- Partial = 210,
12
- Comment = 211
13
- }
14
- export declare const astNodeTypeName: Map<AstNodeType, string>;
1
+ export declare const astNodeTypeNames: readonly ["Number", "String", "NormalExpression", "SpecialExpression", "Symbol", "Modifier", "ReservedSymbol", "Binding", "Argument", "Partial", "Comment", "Spread"];
2
+ export type AstNodeType = typeof astNodeTypeNames[number];
15
3
  export declare function isAstNodeType(type: unknown): type is AstNodeType;
16
- export declare enum FunctionType {
17
- UserDefined = 301,
18
- Partial = 302,
19
- Comp = 303,
20
- Constantly = 304,
21
- Juxt = 305,
22
- Complement = 306,
23
- EveryPred = 307,
24
- SomePred = 308,
25
- Fnil = 309,
26
- Builtin = 310,
27
- NativeJsFunction = 399
28
- }
29
- export declare const functionTypeName: Map<FunctionType, string>;
4
+ declare const functionTypes: readonly ["UserDefined", "Partial", "Comp", "Constantly", "Juxt", "Complement", "EveryPred", "SomePred", "Fnull", "Builtin", "NativeJsFunction"];
5
+ export type FunctionType = typeof functionTypes[number];
30
6
  export declare function isFunctionType(type: unknown): type is FunctionType;
7
+ export {};
@@ -1,5 +1,5 @@
1
1
  import type { Arr } from './interface';
2
- import type { SourceCodeInfo } from './tokenizer/interface';
2
+ import type { SourceCodeInfo } from './tokenizer/token';
3
3
  export declare class RecurSignal extends Error {
4
4
  params: Arr;
5
5
  constructor(params: Arr);
@@ -1,6 +1,6 @@
1
- import type { ExtraData, NativeJsFunction, SymbolNode } from '../parser/interface';
2
1
  import type { Any } from '../interface';
3
- import type { LazyValue, LitsParams } from '../Lits/Lits';
2
+ import type { ContextParams, LazyValue } from '../Lits/Lits';
3
+ import type { NativeJsFunction, SymbolNode } from '../parser/types';
4
4
  import type { Context, LookUpResult } from './interface';
5
5
  export type ContextStack = ContextStackImpl;
6
6
  export declare class ContextStackImpl {
@@ -15,12 +15,12 @@ export declare class ContextStackImpl {
15
15
  lazyValues?: Record<string, LazyValue>;
16
16
  nativeJsFunctions?: Record<string, NativeJsFunction>;
17
17
  });
18
- create(context: Context, extraData?: ExtraData): ContextStack;
19
- exportValue(name: string, value: Any): void;
20
- addValue(name: string, value: Any): void;
21
- clone(): ContextStack;
18
+ create(context: Context): ContextStack;
19
+ new(context: Context): ContextStack;
20
+ exportValues(values: Record<string, Any>): void;
21
+ addValues(values: Record<string, Any>): void;
22
22
  getValue(name: string): unknown;
23
23
  lookUp(node: SymbolNode): LookUpResult;
24
24
  evaluateName(node: SymbolNode): Any;
25
25
  }
26
- export declare function createContextStack(params?: LitsParams): ContextStack;
26
+ export declare function createContextStack(params?: ContextParams): ContextStack;
@@ -1,8 +1,8 @@
1
1
  import type { Any, Arr } from '../interface';
2
- import type { LitsFunctionType } from '../parser/interface';
3
- import type { SourceCodeInfo } from '../tokenizer/interface';
4
- import type { EvaluateAstNode, ExecuteFunction } from './interface';
2
+ import type { LitsFunctionType } from '../parser/types';
3
+ import type { SourceCodeInfo } from '../tokenizer/token';
5
4
  import type { ContextStack } from './ContextStack';
5
+ import type { EvaluateAstNode, ExecuteFunction } from './interface';
6
6
  type FunctionExecutors = Record<LitsFunctionType, (fn: any, params: Arr, sourceCodeInfo: SourceCodeInfo | undefined, contextStack: ContextStack, helpers: {
7
7
  evaluateAstNode: EvaluateAstNode;
8
8
  executeFunction: ExecuteFunction;
@@ -1,4 +1,4 @@
1
- import type { Ast, AstNode } from '../parser/interface';
1
+ import type { Ast, AstNode } from '../parser/types';
2
2
  import type { Any } from '../interface';
3
3
  import type { ContextStack } from './ContextStack';
4
4
  export declare function evaluate(ast: Ast, contextStack: ContextStack): Any;
@@ -1,6 +1,6 @@
1
1
  import type { Any, Arr } from '../interface';
2
- import type { AstNode, BuiltinFunction } from '../parser/interface';
3
- import type { SourceCodeInfo } from '../tokenizer/interface';
2
+ import type { AstNode, BuiltinFunction } from '../parser/types';
3
+ import type { SourceCodeInfo } from '../tokenizer/token';
4
4
  import type { ContextStack } from './ContextStack';
5
5
  export interface ContextEntry {
6
6
  value: Any;
@@ -8,5 +8,5 @@ export interface ContextEntry {
8
8
  export type Context = Record<string, ContextEntry>;
9
9
  export type EvaluateAstNode = (node: AstNode, contextStack: ContextStack) => Any;
10
10
  export type ExecuteFunction = (fn: Any, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo) => Any;
11
- export type LookUpResult = ContextEntry | BuiltinFunction | 'specialExpression' | null;
11
+ export type LookUpResult = ContextEntry | BuiltinFunction | null;
12
12
  export declare function isContextEntry(value: unknown): value is ContextEntry;
@@ -0,0 +1,7 @@
1
+ import type { Builtin } from '../builtin/interface';
2
+ import type { ContextStack } from '../evaluator/ContextStack';
3
+ import type { EvaluateAstNode } from '../evaluator/interface';
4
+ import type { Ast, AstNode } from '../parser/types';
5
+ export type UndefinedSymbols = Set<string>;
6
+ export declare const getUndefinedSymbols: GetUndefinedSymbols;
7
+ export type GetUndefinedSymbols = (ast: Ast | AstNode[], contextStack: ContextStack, builtin: Builtin, evaluateAstNode: EvaluateAstNode) => UndefinedSymbols;
@@ -1,18 +1,15 @@
1
- export { AstNodeType, FunctionType } from './constants/constants';
2
1
  export { isBuiltinFunction, isLitsFunction, asLitsFunction, assertLitsFunction, isUserDefinedFunction, asUserDefinedFunction, assertUserDefinedFunction, isNativeJsFunction, asNativeJsFunction, assertNativeJsFunction, } from './typeGuards/litsFunction';
3
- export { type LitsFunction, type NativeJsFunction, type ExtraData } from './parser/interface';
2
+ export { type LitsFunction, type NativeJsFunction } from './parser/types';
4
3
  export type { Context } from './evaluator/interface';
5
- export type { Ast } from './parser/interface';
6
- export type { SourceCodeInfo } from './tokenizer/interface';
7
- export type { Token } from './tokenizer/tokens';
4
+ export type { Ast } from './parser/types';
5
+ export type { SourceCodeInfo } from './tokenizer/token';
6
+ export type { Token } from './tokenizer/token';
8
7
  export { normalExpressionKeys, specialExpressionKeys } from './builtin';
9
- export { polishReservedNames } from './tokenizer/polish/polishReservedNames';
10
8
  export { Lits } from './Lits/Lits';
11
9
  export { type LitsError, isLitsError } from './errors';
12
- export type { LitsParams, LitsRuntimeInfo, LazyValue, JsFunction } from './Lits/Lits';
10
+ export type { ContextParams, FilePathParams, MinifyParams, LitsRuntimeInfo, LazyValue, JsFunction } from './Lits/Lits';
13
11
  export { createNativeJsFunction } from './utils';
14
- export { apiReference, isDatatypeReference, isFunctionReference, isNormalExpressionArgument, isShorthandReference, isSpecialExpressionArgument, isTypedValue } from '../reference';
12
+ export { apiReference, isDatatypeReference, isFunctionReference, isShorthandReference } from '../reference';
15
13
  export type { Argument, CommonReference, DatatypeReference, FunctionReference, Reference, ShorthandReference } from '../reference';
16
14
  export type { ApiName, FunctionName, ShorthandName, DatatypeName } from '../reference/api';
17
15
  export { isApiName, isDataType } from '../reference/api';
18
- export { polishIdentifierCharacterClass as identifierCharacterClass, polishIdentifierFirstCharacterClass as identifierFirstCharacterClass } from './identifier';
@@ -1,5 +1,4 @@
1
- import type { RegularExpression } from './parser/interface';
2
- import type { LitsFunction } from '.';
1
+ import type { LitsFunction, RegularExpression } from './parser/types';
3
2
  export type Arr = unknown[];
4
3
  export type Seq = string | Arr;
5
4
  export type Obj = Record<string, unknown>;
@@ -1,13 +1,12 @@
1
1
  import type { CondNode } from '../builtin/specialExpressions/cond';
2
+ import type { FunctionNode } from '../builtin/specialExpressions/functions';
2
3
  import type { IfNode } from '../builtin/specialExpressions/if';
3
- import type { LetNode } from '../builtin/specialExpressions/let';
4
4
  import type { SwitchNode } from '../builtin/specialExpressions/switch';
5
5
  import type { UnlessNode } from '../builtin/specialExpressions/unless';
6
- import type { Arity, FunctionArguments } from '../builtin/utils';
7
- import type { A_ReservedSymbolToken, A_SymbolToken } from '../tokenizer/algebraic/algebraicTokens';
8
- import type { TokenStream } from '../tokenizer/interface';
9
- import type { AstNode, ParseState } from './interface';
10
- export declare class AlgebraicParser {
6
+ import type { TokenStream } from '../tokenizer/tokenize';
7
+ import type { ReservedSymbolToken, SymbolToken } from '../tokenizer/token';
8
+ import type { AstNode, BindingTarget, ParseState } from './types';
9
+ export declare class Parser {
11
10
  private readonly tokenStream;
12
11
  private parseState;
13
12
  constructor(tokenStream: TokenStream, parseState: ParseState);
@@ -22,11 +21,10 @@ export declare class AlgebraicParser {
22
21
  private parseArray;
23
22
  private parseFunctionCall;
24
23
  parseLambdaFunction(): AstNode | null;
25
- parseFunctionArguments(): {
26
- functionArguments: FunctionArguments;
27
- arity: Arity;
28
- };
24
+ parseFunctionArguments(): BindingTarget[];
29
25
  private parseShorthandLamdaFunction;
26
+ private parseOptionalDefaulValue;
27
+ private parseBindingTarget;
30
28
  private parseLet;
31
29
  private parseDo;
32
30
  private parseLoop;
@@ -34,11 +32,16 @@ export declare class AlgebraicParser {
34
32
  private parseForOrDoseq;
35
33
  private parseForLoopBinding;
36
34
  private parseBinding;
37
- parseIfOrUnless(token: A_SymbolToken): IfNode | UnlessNode;
38
- parseCond(token: A_SymbolToken): CondNode;
39
- parseSwitch(token: A_SymbolToken): SwitchNode;
40
- parseFunction(token: A_ReservedSymbolToken<'function'>): LetNode;
35
+ parseIfOrUnless(token: SymbolToken): IfNode | UnlessNode;
36
+ parseCond(token: SymbolToken): CondNode;
37
+ parseSwitch(token: SymbolToken): SwitchNode;
38
+ parseFunction(token: ReservedSymbolToken<'function'>): FunctionNode;
41
39
  private isAtEnd;
42
40
  private isAtExpressionEnd;
43
41
  private parseExport;
42
+ private parseSymbol;
43
+ private parseReservedSymbol;
44
+ private parseNumber;
45
+ private parseString;
46
+ private parseRegexpShorthand;
44
47
  }