@mojir/lits 2.1.1 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/cli.js +228 -107
- package/dist/cli/reference/api.d.ts +0 -1
- package/dist/cli/src/builtin/bindingNode.d.ts +1 -0
- package/dist/cli/src/builtin/interface.d.ts +1 -0
- package/dist/cli/src/builtin/specialExpressionTypes.d.ts +3 -5
- package/dist/cli/src/builtin/specialExpressions/def.d.ts +1 -1
- package/dist/cli/src/builtin/specialExpressions/functions.d.ts +2 -2
- package/dist/cli/src/constants/constants.d.ts +1 -1
- package/dist/cli/src/evaluator/ContextStack.d.ts +3 -2
- package/dist/cli/src/evaluator/functionExecutors.d.ts +1 -1
- package/dist/cli/src/parser/types.d.ts +6 -1
- package/dist/cli/src/tokenizer/token.d.ts +2 -2
- package/dist/cli/src/typeGuards/astNode.d.ts +1 -6
- package/dist/index.esm.js +249 -125
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +249 -125
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +249 -125
- package/dist/lits.iife.js.map +1 -1
- package/dist/reference/api.d.ts +0 -1
- package/dist/src/builtin/bindingNode.d.ts +1 -0
- package/dist/src/builtin/interface.d.ts +1 -0
- package/dist/src/builtin/specialExpressionTypes.d.ts +3 -5
- package/dist/src/builtin/specialExpressions/def.d.ts +1 -1
- package/dist/src/builtin/specialExpressions/functions.d.ts +2 -2
- package/dist/src/constants/constants.d.ts +1 -1
- package/dist/src/evaluator/ContextStack.d.ts +3 -2
- package/dist/src/evaluator/functionExecutors.d.ts +1 -1
- package/dist/src/parser/types.d.ts +6 -1
- package/dist/src/tokenizer/token.d.ts +2 -2
- package/dist/src/typeGuards/astNode.d.ts +1 -6
- package/dist/testFramework.esm.js +227 -84
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +227 -84
- package/dist/testFramework.js.map +1 -1
- package/package.json +1 -1
|
@@ -9,7 +9,6 @@ export declare const api: {
|
|
|
9
9
|
readonly object: readonly ["dissoc", "keys", "vals", "entries", "find", "merge", "merge-with", "zipmap", "select-keys"];
|
|
10
10
|
readonly predicate: readonly ["boolean?", "null?", "number?", "string?", "function?", "integer?", "array?", "object?", "coll?", "seq?", "regexp?", "zero?", "pos?", "neg?", "even?", "odd?", "finite?", "nan?", "negative-infinity?", "positive-infinity?", "false?", "true?", "empty?", "not-empty?"];
|
|
11
11
|
readonly regularExpression: readonly ["regexp", "match", "replace", "replace-all"];
|
|
12
|
-
readonly specialExpressions: readonly ["&&", "||", "def", "let", "fn", "defn", "function", "try", "throw", "if", "unless", "cond", "switch", "do", "recur", "loop", "doseq", "for", "defined?", "??"];
|
|
13
12
|
readonly string: readonly ["string-repeat", "str", "number", "lower-case", "upper-case", "trim", "trim-left", "trim-right", "pad-left", "pad-right", "split", "split-lines", "template", "to-char-code", "from-char-code", "encode-base64", "decode-base64", "encode-uri-component", "decode-uri-component", "join", "capitalize", "blank?"];
|
|
14
13
|
readonly bitwise: readonly ["<<", ">>", ">>>", "~", "&", "bit-and-not", "|", "^", "bit-flip", "bit-clear", "bit-set", "bit-test"];
|
|
15
14
|
readonly assert: readonly ["assert", "assert=", "assert!=", "assert-gt", "assert-lt", "assert-gte", "assert-lte", "assert-true", "assert-false", "assert-truthy", "assert-falsy", "assert-null", "assert-throws", "assert-throws-error", "assert-not-throws"];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Any } from '../interface';
|
|
2
2
|
import { type BindingTarget, type Node } from '../parser/types';
|
|
3
|
+
export declare function walkDefaults(bindingTarget: BindingTarget, onDefault: (Node: Node) => void): void;
|
|
3
4
|
export declare function evalueateBindingNodeValues(target: BindingTarget, value: Any, evaluate: (Node: Node) => Any): Record<string, Any>;
|
|
4
5
|
export declare function getAllBindingTargetNames(bindingTarget: BindingTarget): Record<string, true>;
|
|
@@ -28,6 +28,7 @@ export interface EvaluateHelpers {
|
|
|
28
28
|
}
|
|
29
29
|
export interface BuiltinSpecialExpression<T, N extends SpecialExpressionNode> {
|
|
30
30
|
evaluate: (node: N, contextStack: ContextStack, helpers: EvaluateHelpers) => T;
|
|
31
|
+
evaluateAsNormalExpression?: NormalExpressionEvaluator<T>;
|
|
31
32
|
paramCount: Count;
|
|
32
33
|
getUndefinedSymbols: (node: N, contextStack: ContextStack, params: {
|
|
33
34
|
getUndefinedSymbols: GetUndefinedSymbols;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import type { SpecialExpressionName, SpecialExpressionType } from '.';
|
|
2
1
|
export declare const specialExpressionTypes: {
|
|
3
2
|
readonly '??': 0;
|
|
4
3
|
readonly '&&': 1;
|
|
5
4
|
readonly '||': 2;
|
|
6
5
|
readonly array: 3;
|
|
7
6
|
readonly cond: 4;
|
|
8
|
-
readonly
|
|
7
|
+
readonly '0_def': 5;
|
|
9
8
|
readonly 'defined?': 6;
|
|
10
|
-
readonly
|
|
9
|
+
readonly '0_defn': 7;
|
|
11
10
|
readonly do: 8;
|
|
12
11
|
readonly doseq: 9;
|
|
13
|
-
readonly
|
|
12
|
+
readonly '0_fn': 10;
|
|
14
13
|
readonly for: 11;
|
|
15
14
|
readonly function: 12;
|
|
16
15
|
readonly if: 13;
|
|
@@ -24,4 +23,3 @@ export declare const specialExpressionTypes: {
|
|
|
24
23
|
readonly unless: 21;
|
|
25
24
|
};
|
|
26
25
|
export type SpecialExpressionTypes = typeof specialExpressionTypes;
|
|
27
|
-
export declare function getNameFromSpecialExpressionType(type: SpecialExpressionType): SpecialExpressionName;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BindingNode, SpecialExpressionNode } from '../../parser/types';
|
|
2
2
|
import type { BuiltinSpecialExpression } from '../interface';
|
|
3
3
|
import type { specialExpressionTypes } from '../specialExpressionTypes';
|
|
4
|
-
export type DefNode = SpecialExpressionNode<[typeof specialExpressionTypes['
|
|
4
|
+
export type DefNode = SpecialExpressionNode<[typeof specialExpressionTypes['0_def'], BindingNode]>;
|
|
5
5
|
export declare const defSpecialExpression: BuiltinSpecialExpression<null, DefNode>;
|
|
@@ -2,9 +2,9 @@ import type { LitsFunction, SpecialExpressionNode, SymbolNode } from '../../pars
|
|
|
2
2
|
import type { BuiltinSpecialExpression } from '../interface';
|
|
3
3
|
import type { Function } from '../utils';
|
|
4
4
|
import type { specialExpressionTypes } from '../specialExpressionTypes';
|
|
5
|
-
export type DefnNode = SpecialExpressionNode<[typeof specialExpressionTypes['
|
|
5
|
+
export type DefnNode = SpecialExpressionNode<[typeof specialExpressionTypes['0_defn'], SymbolNode, Function]>;
|
|
6
6
|
export type FunctionNode = SpecialExpressionNode<[typeof specialExpressionTypes['function'], SymbolNode, Function]>;
|
|
7
|
-
export type FnNode = SpecialExpressionNode<[typeof specialExpressionTypes['
|
|
7
|
+
export type FnNode = SpecialExpressionNode<[typeof specialExpressionTypes['0_fn'], Function]>;
|
|
8
8
|
export declare const functionSpecialExpression: BuiltinSpecialExpression<null, FunctionNode>;
|
|
9
9
|
export declare const defnSpecialExpression: BuiltinSpecialExpression<null, DefnNode>;
|
|
10
10
|
export declare const fnSpecialExpression: BuiltinSpecialExpression<LitsFunction, FnNode>;
|
|
@@ -13,7 +13,7 @@ export declare const NodeTypes: {
|
|
|
13
13
|
export type NodeType = typeof NodeTypes[keyof typeof NodeTypes];
|
|
14
14
|
export declare function getNodeTypeName(type: NodeType): keyof typeof NodeTypes;
|
|
15
15
|
export declare function isNodeType(type: unknown): type is NodeType;
|
|
16
|
-
declare const functionTypes: readonly ["UserDefined", "Partial", "Comp", "Constantly", "Juxt", "Complement", "EveryPred", "SomePred", "Fnull", "Builtin", "NativeJsFunction"];
|
|
16
|
+
declare const functionTypes: readonly ["UserDefined", "Partial", "Comp", "Constantly", "Juxt", "Complement", "EveryPred", "SomePred", "Fnull", "Builtin", "SpecialBuiltin", "NativeJsFunction"];
|
|
17
17
|
export type FunctionType = typeof functionTypes[number];
|
|
18
18
|
export declare function isFunctionType(type: unknown): type is FunctionType;
|
|
19
19
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Any } from '../interface';
|
|
2
2
|
import type { ContextParams, LazyValue } from '../Lits/Lits';
|
|
3
3
|
import type { NativeJsFunction, SymbolNode, UserDefinedSymbolNode } from '../parser/types';
|
|
4
|
+
import type { SourceCodeInfo } from '../tokenizer/token';
|
|
4
5
|
import type { Context, LookUpResult } from './interface';
|
|
5
6
|
export type ContextStack = ContextStackImpl;
|
|
6
7
|
export declare class ContextStackImpl {
|
|
@@ -17,8 +18,8 @@ export declare class ContextStackImpl {
|
|
|
17
18
|
});
|
|
18
19
|
create(context: Context): ContextStack;
|
|
19
20
|
new(context: Context): ContextStack;
|
|
20
|
-
exportValues(values: Record<string, Any
|
|
21
|
-
addValues(values: Record<string, Any
|
|
21
|
+
exportValues(values: Record<string, Any>, sourceCodeInfo: SourceCodeInfo | undefined): void;
|
|
22
|
+
addValues(values: Record<string, Any>, sourceCodeInfo: SourceCodeInfo | undefined): void;
|
|
22
23
|
getValue(name: string): unknown;
|
|
23
24
|
lookUp(node: UserDefinedSymbolNode): LookUpResult;
|
|
24
25
|
evaluateSymbol(node: SymbolNode): Any;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Any, Arr } from '../interface';
|
|
2
|
-
import {
|
|
2
|
+
import type { LitsFunctionType } from '../parser/types';
|
|
3
3
|
import type { SourceCodeInfo } from '../tokenizer/token';
|
|
4
4
|
import type { ContextStack } from './ContextStack';
|
|
5
5
|
import type { EvaluateNode, ExecuteFunction } from './interface';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { JsFunction } from '../Lits/Lits';
|
|
2
2
|
import type { SpecialExpressionType } from '../builtin';
|
|
3
|
+
import type { specialExpressionTypes } from '../builtin/specialExpressionTypes';
|
|
3
4
|
import type { FunctionType, NodeType, NodeTypes } from '../constants/constants';
|
|
4
5
|
import type { Context } from '../evaluator/interface';
|
|
5
6
|
import type { Any, Arr } from '../interface';
|
|
@@ -69,7 +70,11 @@ export interface NormalBuiltinFunction extends GenericLitsFunction {
|
|
|
69
70
|
functionType: 'Builtin';
|
|
70
71
|
normalBuitinSymbolType: number;
|
|
71
72
|
}
|
|
72
|
-
export
|
|
73
|
+
export interface SpecialBuiltinFunction extends GenericLitsFunction {
|
|
74
|
+
functionType: 'SpecialBuiltin';
|
|
75
|
+
specialBuiltinSymbolType: typeof specialExpressionTypes['&&'] | typeof specialExpressionTypes['||'] | typeof specialExpressionTypes['array'] | typeof specialExpressionTypes['object'] | typeof specialExpressionTypes['defined?'] | typeof specialExpressionTypes['recur'] | typeof specialExpressionTypes['throw'] | typeof specialExpressionTypes['??'];
|
|
76
|
+
}
|
|
77
|
+
export type LitsFunction = NativeJsFunction | UserDefinedFunction | NormalBuiltinFunction | SpecialBuiltinFunction | PartialFunction | CompFunction | ConstantlyFunction | JuxtFunction | ComplementFunction | EveryPredFunction | SomePredFunction | FNullFunction;
|
|
73
78
|
export type LitsFunctionType = LitsFunction['functionType'];
|
|
74
79
|
export type DebugData = {
|
|
75
80
|
token: Token;
|
|
@@ -24,11 +24,11 @@ export type WhitespaceToken = GenericToken<'Whitespace'>;
|
|
|
24
24
|
export type Token = LBraceToken | LBracketToken | LParenToken | RBraceToken | RBracketToken | RParenToken | BasePrefixedNumberToken | MultiLineCommentToken | NumberToken | OperatorToken | RegexpShorthandToken | ReservedSymbolToken | SingleLineCommentToken | StringToken | SymbolToken | WhitespaceToken;
|
|
25
25
|
export type TokenDescriptor<T extends Token> = [length: number, token?: T];
|
|
26
26
|
export interface SourceCodeInfo {
|
|
27
|
-
position
|
|
27
|
+
position: {
|
|
28
28
|
line: number;
|
|
29
29
|
column: number;
|
|
30
30
|
};
|
|
31
|
-
code
|
|
31
|
+
code: string;
|
|
32
32
|
filePath?: string;
|
|
33
33
|
}
|
|
34
34
|
export declare function isSymbolToken<T extends string>(token: Token, symbolName?: T): token is SymbolToken<T>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { SpecialExpressionName } from '../builtin';
|
|
2
1
|
import type { ExpressionNode, Node, NormalBuiltinSymbolNode, NormalExpressionNode, NormalExpressionNodeWithName, SpecialBuiltinSymbolNode, SpreadNode, SymbolNode, UserDefinedSymbolNode } from '../parser/types';
|
|
3
2
|
import type { SourceCodeInfo } from '../tokenizer/token';
|
|
4
3
|
export declare function isSymbolNode(node: Node): node is SymbolNode;
|
|
@@ -8,11 +7,7 @@ export declare function isUserDefinedSymbolNode(node: Node): node is UserDefined
|
|
|
8
7
|
export declare function asUserDefinedSymbolNode(node: Node, sourceCodeInfo?: SourceCodeInfo): UserDefinedSymbolNode;
|
|
9
8
|
export declare function assertUserDefinedSymbolNode(node: Node, sourceCodeInfo?: SourceCodeInfo): asserts node is UserDefinedSymbolNode;
|
|
10
9
|
export declare function isNormalBuiltinSymbolNode(node: Node): node is NormalBuiltinSymbolNode;
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function assertNormalBuiltinSymbolNode(node: Node, sourceCodeInfo?: SourceCodeInfo): asserts node is NormalBuiltinSymbolNode;
|
|
13
|
-
export declare function isSpecialBuiltinSymbolNode(node: Node, name?: SpecialExpressionName): node is SpecialBuiltinSymbolNode;
|
|
14
|
-
export declare function asSpecialBuiltinSymbolNode(node: Node, sourceCodeInfo?: SourceCodeInfo): SpecialBuiltinSymbolNode;
|
|
15
|
-
export declare function assertSpecialBuiltinSymbolNode(node: Node, sourceCodeInfo?: SourceCodeInfo): asserts node is SpecialBuiltinSymbolNode;
|
|
10
|
+
export declare function isSpecialBuiltinSymbolNode(node: Node): node is SpecialBuiltinSymbolNode;
|
|
16
11
|
export declare function isNormalExpressionNode(node: Node): node is NormalExpressionNode;
|
|
17
12
|
export declare function asNormalExpressionNode(node: Node, sourceCodeInfo?: SourceCodeInfo): NormalExpressionNode;
|
|
18
13
|
export declare function assertNormalExpressionNode(node: Node, sourceCodeInfo?: SourceCodeInfo): asserts node is NormalExpressionNode;
|