@mojir/lits 2.0.14 → 2.0.16
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 +1131 -1858
- package/dist/cli/reference/api.d.ts +8 -8
- package/dist/cli/src/analyze/index.d.ts +0 -2
- package/dist/cli/src/builtin/index.d.ts +6 -11
- package/dist/cli/src/builtin/specialExpressions/and.d.ts +1 -1
- package/dist/cli/src/builtin/specialExpressions/declared.d.ts +1 -1
- package/dist/cli/src/builtin/specialExpressions/or.d.ts +1 -1
- package/dist/cli/src/builtin/specialExpressions/{when.d.ts → switch.d.ts} +2 -2
- package/dist/cli/src/builtin/specialExpressions/try.d.ts +1 -1
- package/dist/cli/src/builtin/specialExpressions/{if-not.d.ts → unless.d.ts} +2 -2
- package/dist/cli/src/evaluator/ContextStack.d.ts +2 -0
- package/dist/cli/src/identifier.d.ts +2 -2
- package/dist/cli/src/parser/AlgebraicParser.d.ts +12 -2
- package/dist/cli/src/tokenizer/algebraic/algebraicReservedNames.d.ts +94 -7
- package/dist/cli/src/tokenizer/algebraic/algebraicTokenizers.d.ts +1 -1
- package/dist/cli/src/tokenizer/algebraic/algebraicTokens.d.ts +8 -7
- package/dist/cli/src/tokenizer/polish/polishTokenizers.d.ts +1 -1
- package/dist/cli/src/tokenizer/polish/polishTokens.d.ts +1 -1
- package/dist/cli/src/tokenizer/utils.d.ts +1 -1
- package/dist/cli/src/typeGuards/index.d.ts +1 -0
- package/dist/index.esm.js +1132 -1861
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1132 -1861
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +1132 -1861
- package/dist/lits.iife.js.map +1 -1
- package/dist/reference/api.d.ts +8 -8
- package/dist/src/analyze/index.d.ts +0 -2
- package/dist/src/builtin/index.d.ts +6 -11
- package/dist/src/builtin/specialExpressions/and.d.ts +1 -1
- package/dist/src/builtin/specialExpressions/declared.d.ts +1 -1
- package/dist/src/builtin/specialExpressions/or.d.ts +1 -1
- package/dist/{cli/src/builtin/specialExpressions/time.d.ts → src/builtin/specialExpressions/switch.d.ts} +2 -2
- package/dist/src/builtin/specialExpressions/try.d.ts +1 -1
- package/dist/src/builtin/specialExpressions/{if-not.d.ts → unless.d.ts} +2 -2
- package/dist/src/evaluator/ContextStack.d.ts +2 -0
- package/dist/src/identifier.d.ts +2 -2
- package/dist/src/parser/AlgebraicParser.d.ts +12 -2
- package/dist/src/tokenizer/algebraic/algebraicReservedNames.d.ts +94 -7
- package/dist/src/tokenizer/algebraic/algebraicTokenizers.d.ts +1 -1
- package/dist/src/tokenizer/algebraic/algebraicTokens.d.ts +8 -7
- package/dist/src/tokenizer/polish/polishTokenizers.d.ts +1 -1
- package/dist/src/tokenizer/polish/polishTokens.d.ts +1 -1
- package/dist/src/tokenizer/utils.d.ts +1 -1
- package/dist/src/typeGuards/index.d.ts +1 -0
- package/dist/testFramework.esm.js +772 -1325
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +772 -1325
- package/dist/testFramework.js.map +1 -1
- package/package.json +1 -1
- package/dist/cli/src/analyze/calculateOutcomes/calculateAndOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateCommentOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateCondOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateDeclaredOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateDefOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateDefsOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateDoOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateFunctionOutcomes.d.ts +0 -5
- package/dist/cli/src/analyze/calculateOutcomes/calculateIfLetOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateIfNotOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateIfOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateLetOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateLoopOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateLoopsOutcomes.d.ts +0 -4
- package/dist/cli/src/analyze/calculateOutcomes/calculateOrOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateQqOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateRecurOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateThrowOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateTimeOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateTryOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateWhenFirstOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateWhenLetOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateWhenNotOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateWhenOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/index.d.ts +0 -18
- package/dist/cli/src/analyze/calculateOutcomes/specialExpressionCalculators.d.ts +0 -55
- package/dist/cli/src/builtin/specialExpressions/if-let.d.ts +0 -7
- package/dist/cli/src/builtin/specialExpressions/when-first.d.ts +0 -7
- package/dist/cli/src/builtin/specialExpressions/when-let.d.ts +0 -7
- package/dist/cli/src/builtin/specialExpressions/when-not.d.ts +0 -6
- package/dist/src/analyze/calculateOutcomes/calculateAndOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateCommentOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateCondOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateDeclaredOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateDefOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateDefsOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateDoOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateFunctionOutcomes.d.ts +0 -5
- package/dist/src/analyze/calculateOutcomes/calculateIfLetOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateIfNotOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateIfOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateLetOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateLoopOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateLoopsOutcomes.d.ts +0 -4
- package/dist/src/analyze/calculateOutcomes/calculateOrOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateQqOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateRecurOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateThrowOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateTimeOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateTryOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateWhenFirstOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateWhenLetOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateWhenNotOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateWhenOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/index.d.ts +0 -18
- package/dist/src/analyze/calculateOutcomes/specialExpressionCalculators.d.ts +0 -55
- package/dist/src/builtin/specialExpressions/if-let.d.ts +0 -7
- package/dist/src/builtin/specialExpressions/time.d.ts +0 -6
- package/dist/src/builtin/specialExpressions/when-first.d.ts +0 -7
- package/dist/src/builtin/specialExpressions/when-let.d.ts +0 -7
- package/dist/src/builtin/specialExpressions/when-not.d.ts +0 -6
- package/dist/src/builtin/specialExpressions/when.d.ts +0 -6
package/dist/reference/api.d.ts
CHANGED
|
@@ -2,15 +2,15 @@ export declare const api: {
|
|
|
2
2
|
readonly collection: readonly ["count", "get", "get_in", "contains?", "has?", "has_some?", "has_every?", "assoc", "assoc_in", "concat", "not_empty", "every?", "not_every?", "any?", "not_any?", "update", "update_in"];
|
|
3
3
|
readonly array: readonly ["array", "range", "repeat", "flatten", "mapcat"];
|
|
4
4
|
readonly sequence: readonly ["nth", "push", "pop", "unshift", "shift", "slice", "reductions", "reduce", "reduce_right", "map", "filter", "position", "index_of", "some", "reverse", "first", "second", "last", "rest", "nthrest", "next", "nthnext", "take", "take_last", "take_while", "drop", "drop_last", "drop_while", "sort", "sort_by", "distinct", "remove", "remove_at", "split_at", "split_with", "frequencies", "group_by", "partition", "partition_all", "partition_by"];
|
|
5
|
-
readonly math: readonly ["+", "-", "*", "/", "mod", "
|
|
5
|
+
readonly math: readonly ["+", "-", "*", "/", "mod", "%", "quot", "inc", "dec", "sqrt", "cbrt", "**", "exp", "round", "trunc", "floor", "ceil", "min", "max", "abs", "sign", "positive_infinity", "negative_infinity", "max_safe_integer", "min_safe_integer", "max_value", "min_value", "epsilon", "nan", "e", "pi", "log", "log2", "log10", "sin", "cos", "tan", "asin", "acos", "atan", "sinh", "cosh", "tanh", "asinh", "acosh", "atanh"];
|
|
6
6
|
readonly functional: readonly ["apply", "identity", "partial", "comp", "constantly", "juxt", "complement", "every_pred", "some_pred", "fnil"];
|
|
7
|
-
readonly misc: readonly ["!=", "
|
|
8
|
-
readonly object: readonly ["dissoc", "object", "keys", "vals", "entries", "find", "merge", "
|
|
7
|
+
readonly misc: readonly ["!=", "==", "<", ">", "<=", ">=", "!", "write!", "iso_date>epoch", "epoch>iso_date", "boolean", "compare", "equal?", "json_parse", "json_stringify"];
|
|
8
|
+
readonly object: readonly ["dissoc", "object", "keys", "vals", "entries", "find", "merge", "merge_with", "zipmap", "select_keys"];
|
|
9
9
|
readonly predicate: readonly ["boolean?", "nil?", "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?"];
|
|
10
10
|
readonly regularExpression: readonly ["regexp", "match", "replace"];
|
|
11
|
-
readonly specialExpressions: readonly ["
|
|
12
|
-
readonly string: readonly ["subs", "
|
|
13
|
-
readonly bitwise: readonly ["
|
|
11
|
+
readonly specialExpressions: readonly ["&&", "||", "def", "defs", "let", "fn", "defn", "defns", "try", "throw", "if", "unless", "cond", "switch", "comment", "do", "recur", "loop", "doseq", "for", "defined?", "??"];
|
|
12
|
+
readonly string: readonly ["subs", "string_repeat", "str", "number", "lower_case", "upper_case", "trim", "trim_left", "trim_right", "pad_left", "pad_right", "split", "template", "to_char_code", "from_char_code", "encode_base64", "decode_base64", "encode_uri_component", "decode_uri_component", "join", "++"];
|
|
13
|
+
readonly bitwise: readonly ["<<", ">>", ">>>", "~", "&", "&!", "|", "^", "bit_flip", "bit_clear", "bit_set", "bit_test"];
|
|
14
14
|
readonly assert: readonly ["assert", "assert=", "assert!=", "assert_equal", "assert_not_equal", "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"];
|
|
15
15
|
readonly shorthand: ["-short-regexp", "-short-fn", "-short-string", "-short-dot", "-short-hash"];
|
|
16
16
|
readonly datatype: ["-type-number", "-type-string", "-type-object", "-type-array", "-type-boolean", "-type-function", "-type-integer", "-type-any", "-type-nil", "-type-collection", "-type-sequence", "-type-regexp", "-type-never"];
|
|
@@ -31,7 +31,7 @@ export type AssertApiName = typeof api.assert[number];
|
|
|
31
31
|
export type FunctionName = CollectionApiName | ArrayApiName | SequenceApiName | MathApiName | FunctionalApiName | MiscApiName | ObjectApiName | PredicateApiName | RegularExpressionApiName | SpecialExpressionsApiName | StringApiName | BitwiseApiName | AssertApiName;
|
|
32
32
|
export type ShorthandName = typeof api.shorthand[number];
|
|
33
33
|
export type DatatypeName = typeof api.datatype[number];
|
|
34
|
-
declare const apiNames: readonly ["count", "get", "get_in", "contains?", "has?", "has_some?", "has_every?", "assoc", "assoc_in", "concat", "not_empty", "every?", "not_every?", "any?", "not_any?", "update", "update_in", "array", "range", "repeat", "flatten", "mapcat", "nth", "push", "pop", "unshift", "shift", "slice", "reductions", "reduce", "reduce_right", "map", "filter", "position", "index_of", "some", "reverse", "first", "second", "last", "rest", "nthrest", "next", "nthnext", "take", "take_last", "take_while", "drop", "drop_last", "drop_while", "sort", "sort_by", "distinct", "remove", "remove_at", "split_at", "split_with", "frequencies", "group_by", "partition", "partition_all", "partition_by", "+", "-", "*", "/", "mod", "
|
|
34
|
+
declare const apiNames: readonly ["count", "get", "get_in", "contains?", "has?", "has_some?", "has_every?", "assoc", "assoc_in", "concat", "not_empty", "every?", "not_every?", "any?", "not_any?", "update", "update_in", "array", "range", "repeat", "flatten", "mapcat", "nth", "push", "pop", "unshift", "shift", "slice", "reductions", "reduce", "reduce_right", "map", "filter", "position", "index_of", "some", "reverse", "first", "second", "last", "rest", "nthrest", "next", "nthnext", "take", "take_last", "take_while", "drop", "drop_last", "drop_while", "sort", "sort_by", "distinct", "remove", "remove_at", "split_at", "split_with", "frequencies", "group_by", "partition", "partition_all", "partition_by", "+", "-", "*", "/", "mod", "%", "quot", "inc", "dec", "sqrt", "cbrt", "**", "exp", "round", "trunc", "floor", "ceil", "min", "max", "abs", "sign", "positive_infinity", "negative_infinity", "max_safe_integer", "min_safe_integer", "max_value", "min_value", "epsilon", "nan", "e", "pi", "log", "log2", "log10", "sin", "cos", "tan", "asin", "acos", "atan", "sinh", "cosh", "tanh", "asinh", "acosh", "atanh", "apply", "identity", "partial", "comp", "constantly", "juxt", "complement", "every_pred", "some_pred", "fnil", "!=", "==", "<", ">", "<=", ">=", "!", "write!", "iso_date>epoch", "epoch>iso_date", "boolean", "compare", "equal?", "json_parse", "json_stringify", "dissoc", "object", "keys", "vals", "entries", "find", "merge", "merge_with", "zipmap", "select_keys", "boolean?", "nil?", "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?", "regexp", "match", "replace", "&&", "||", "def", "defs", "let", "fn", "defn", "defns", "try", "throw", "if", "unless", "cond", "switch", "comment", "do", "recur", "loop", "doseq", "for", "defined?", "??", "subs", "string_repeat", "str", "number", "lower_case", "upper_case", "trim", "trim_left", "trim_right", "pad_left", "pad_right", "split", "template", "to_char_code", "from_char_code", "encode_base64", "decode_base64", "encode_uri_component", "decode_uri_component", "join", "++", "<<", ">>", ">>>", "~", "&", "&!", "|", "^", "bit_flip", "bit_clear", "bit_set", "bit_test", "assert", "assert=", "assert!=", "assert_equal", "assert_not_equal", "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", "-short-regexp", "-short-fn", "-short-string", "-short-dot", "-short-hash", "-type-number", "-type-string", "-type-object", "-type-array", "-type-boolean", "-type-function", "-type-integer", "-type-any", "-type-nil", "-type-collection", "-type-sequence", "-type-regexp", "-type-never"];
|
|
35
35
|
export type ApiName = typeof apiNames[number];
|
|
36
36
|
export declare function isApiName(arg: string): arg is ApiName;
|
|
37
37
|
export declare const categoryRecord: {
|
|
@@ -53,7 +53,7 @@ export declare const categoryRecord: {
|
|
|
53
53
|
};
|
|
54
54
|
export type Category = keyof typeof categoryRecord;
|
|
55
55
|
export declare const categories: Category[];
|
|
56
|
-
declare const dataTypes: readonly ["number", "string", "object", "array", "boolean", "function", "integer", "any", "
|
|
56
|
+
declare const dataTypes: readonly ["number", "string", "object", "array", "boolean", "function", "integer", "any", "null", "collection", "sequence", "regexp", "never"];
|
|
57
57
|
export type DataType = typeof dataTypes[number];
|
|
58
58
|
export declare function isDataType(arg: string): arg is DataType;
|
|
59
59
|
export {};
|
|
@@ -8,10 +8,8 @@ export interface UnresolvedIdentifier {
|
|
|
8
8
|
token: Token | undefined;
|
|
9
9
|
}
|
|
10
10
|
export type UnresolvedIdentifiers = Set<UnresolvedIdentifier>;
|
|
11
|
-
export type Outcomes = unknown[];
|
|
12
11
|
export interface Analysis {
|
|
13
12
|
unresolvedIdentifiers: UnresolvedIdentifiers;
|
|
14
|
-
outcomes: Outcomes | null;
|
|
15
13
|
}
|
|
16
14
|
export type FindUnresolvedIdentifiers = (ast: Ast | AstNode[], contextStack: ContextStack, builtin: Builtin) => UnresolvedIdentifiers;
|
|
17
15
|
export declare function analyze(ast: Ast, params: LitsParams): Analysis;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Builtin } from './interface';
|
|
2
2
|
declare const specialExpressions: {
|
|
3
|
-
readonly
|
|
3
|
+
readonly '&&': import("./interface").BuiltinSpecialExpression<import("../interface").Any, import("./specialExpressions/and").AndNode>;
|
|
4
4
|
readonly comment: import("./interface").BuiltinSpecialExpression<null, import("./specialExpressions/comment").CommentExpressionNode>;
|
|
5
5
|
readonly cond: import("./interface").BuiltinSpecialExpression<import("../interface").Any, import("./specialExpressions/cond").CondNode>;
|
|
6
|
+
readonly switch: import("./interface").BuiltinSpecialExpression<import("../interface").Any, import("./specialExpressions/switch").SwitchNode>;
|
|
6
7
|
readonly def: import("./interface").BuiltinSpecialExpression<null, import("./specialExpressions/def").DefNode>;
|
|
7
8
|
readonly defn: import("./interface").BuiltinSpecialExpression<null, import("./specialExpressions/functions").DefnNode>;
|
|
8
9
|
readonly defns: import("./interface").BuiltinSpecialExpression<null, import("./specialExpressions/functions").DefnsNode>;
|
|
@@ -12,24 +13,18 @@ declare const specialExpressions: {
|
|
|
12
13
|
readonly for: import("./interface").BuiltinSpecialExpression<import("../interface").Any, import("./specialExpressions/loops").ForNode>;
|
|
13
14
|
readonly fn: import("./interface").BuiltinSpecialExpression<import("..").LitsFunction, import("./specialExpressions/functions").FnNode>;
|
|
14
15
|
readonly if: import("./interface").BuiltinSpecialExpression<import("../interface").Any, import("./specialExpressions/if").IfNode>;
|
|
15
|
-
readonly
|
|
16
|
-
readonly 'if-not': import("./interface").BuiltinSpecialExpression<import("../interface").Any, import("./specialExpressions/if-not").IfNotNode>;
|
|
16
|
+
readonly unless: import("./interface").BuiltinSpecialExpression<import("../interface").Any, import("./specialExpressions/unless").UnlessNode>;
|
|
17
17
|
readonly let: import("./interface").BuiltinSpecialExpression<import("../interface").Any, import("./specialExpressions/let").LetNode>;
|
|
18
18
|
readonly loop: import("./interface").BuiltinSpecialExpression<import("../interface").Any, import("./specialExpressions/loop").LoopNode>;
|
|
19
|
-
readonly
|
|
19
|
+
readonly '||': import("./interface").BuiltinSpecialExpression<import("../interface").Any, import("./specialExpressions/or").OrNode>;
|
|
20
20
|
readonly recur: import("./interface").BuiltinSpecialExpression<null, import("./specialExpressions/recur").RecurNode>;
|
|
21
21
|
readonly throw: import("./interface").BuiltinSpecialExpression<null, import("./specialExpressions/throw").ThrowNode>;
|
|
22
|
-
readonly 'time!': import("./interface").BuiltinSpecialExpression<import("../interface").Any, import("./specialExpressions/time").TimeNode>;
|
|
23
22
|
readonly try: import("./interface").BuiltinSpecialExpression<import("../interface").Any, import("./specialExpressions/try").TryNode>;
|
|
24
|
-
readonly
|
|
25
|
-
readonly 'when-first': import("./interface").BuiltinSpecialExpression<import("../interface").Any, import("./specialExpressions/when-first").WhenFirstNode>;
|
|
26
|
-
readonly 'when-let': import("./interface").BuiltinSpecialExpression<import("../interface").Any, import("./specialExpressions/when-let").WhenLetNode>;
|
|
27
|
-
readonly 'when-not': import("./interface").BuiltinSpecialExpression<import("../interface").Any, import("./specialExpressions/when-not").WhenNotNode>;
|
|
28
|
-
readonly 'declared?': import("./interface").BuiltinSpecialExpression<boolean, import("./specialExpressions/declared").DeclaredNode>;
|
|
23
|
+
readonly 'defined?': import("./interface").BuiltinSpecialExpression<boolean, import("./specialExpressions/declared").DeclaredNode>;
|
|
29
24
|
readonly '??': import("./interface").BuiltinSpecialExpression<import("../interface").Any, import("./specialExpressions/qq").QqNode>;
|
|
30
25
|
};
|
|
31
26
|
export type SpecialExpressionName = keyof typeof specialExpressions;
|
|
32
|
-
export type CommonSpecialExpressionName = keyof Pick<typeof specialExpressions, '??' | '
|
|
27
|
+
export type CommonSpecialExpressionName = keyof Pick<typeof specialExpressions, '??' | '&&' | 'comment' | 'cond' | 'switch' | 'defined?' | 'do' | 'if' | 'unless' | '||' | 'throw'>;
|
|
33
28
|
export type BuiltinSpecialExpressions = typeof specialExpressions;
|
|
34
29
|
export type BuiltinSpecialExpression = typeof specialExpressions[SpecialExpressionName];
|
|
35
30
|
export type BuiltinCommonSpecialExpression = typeof specialExpressions[CommonSpecialExpressionName];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Any } from '../../interface';
|
|
2
2
|
import type { CommonSpecialExpressionNode } from '../../parser/interface';
|
|
3
3
|
import type { BuiltinSpecialExpression } from '../interface';
|
|
4
|
-
export interface AndNode extends CommonSpecialExpressionNode<'
|
|
4
|
+
export interface AndNode extends CommonSpecialExpressionNode<'&&'> {
|
|
5
5
|
}
|
|
6
6
|
export declare const andSpecialExpression: BuiltinSpecialExpression<Any, AndNode>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CommonSpecialExpressionNode } from '../../parser/interface';
|
|
2
2
|
import type { BuiltinSpecialExpression } from '../interface';
|
|
3
|
-
export interface DeclaredNode extends CommonSpecialExpressionNode<'
|
|
3
|
+
export interface DeclaredNode extends CommonSpecialExpressionNode<'defined?'> {
|
|
4
4
|
}
|
|
5
5
|
export declare const declaredSpecialExpression: BuiltinSpecialExpression<boolean, DeclaredNode>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Any } from '../../interface';
|
|
2
2
|
import type { CommonSpecialExpressionNode } from '../../parser/interface';
|
|
3
3
|
import type { BuiltinSpecialExpression } from '../interface';
|
|
4
|
-
export interface OrNode extends CommonSpecialExpressionNode<'
|
|
4
|
+
export interface OrNode extends CommonSpecialExpressionNode<'||'> {
|
|
5
5
|
}
|
|
6
6
|
export declare const orSpecialExpression: BuiltinSpecialExpression<Any, OrNode>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Any } from '../../interface';
|
|
2
2
|
import type { CommonSpecialExpressionNode } from '../../parser/interface';
|
|
3
3
|
import type { BuiltinSpecialExpression } from '../interface';
|
|
4
|
-
export interface
|
|
4
|
+
export interface SwitchNode extends CommonSpecialExpressionNode<'switch'> {
|
|
5
5
|
}
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const switchSpecialExpression: BuiltinSpecialExpression<Any, SwitchNode>;
|
|
@@ -2,7 +2,7 @@ import type { Any } from '../../interface';
|
|
|
2
2
|
import type { AstNode, CommonSpecialExpressionNode, SymbolNode } from '../../parser/interface';
|
|
3
3
|
import type { BuiltinSpecialExpression } from '../interface';
|
|
4
4
|
export interface TryNode extends CommonSpecialExpressionNode<'try'> {
|
|
5
|
-
e: SymbolNode;
|
|
5
|
+
e: SymbolNode | undefined;
|
|
6
6
|
ce: AstNode;
|
|
7
7
|
}
|
|
8
8
|
export declare const trySpecialExpression: BuiltinSpecialExpression<Any, TryNode>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Any } from '../../interface';
|
|
2
2
|
import type { CommonSpecialExpressionNode } from '../../parser/interface';
|
|
3
3
|
import type { BuiltinSpecialExpression } from '../interface';
|
|
4
|
-
export interface
|
|
4
|
+
export interface UnlessNode extends CommonSpecialExpressionNode<'unless'> {
|
|
5
5
|
}
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const unlessSpecialExpression: BuiltinSpecialExpression<Any, UnlessNode>;
|
|
@@ -16,6 +16,8 @@ export declare class ContextStackImpl {
|
|
|
16
16
|
nativeJsFunctions?: Record<string, NativeJsFunction>;
|
|
17
17
|
});
|
|
18
18
|
create(context: Context, extraData?: ExtraData): ContextStack;
|
|
19
|
+
exportValue(name: string, value: Any): void;
|
|
20
|
+
addValue(name: string, value: Any): void;
|
|
19
21
|
clone(): ContextStack;
|
|
20
22
|
getValue(name: string): unknown;
|
|
21
23
|
lookUp(node: SymbolNode): LookUpResult;
|
package/dist/src/identifier.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const polishIdentifierCharacterClass = "[\\w
|
|
2
|
-
export declare const polishIdentifierFirstCharacterClass = "[a-zA-Z_
|
|
1
|
+
export declare const polishIdentifierCharacterClass = "[\\w@%^?=!$<>+*/:&|~-]";
|
|
2
|
+
export declare const polishIdentifierFirstCharacterClass = "[a-zA-Z_@%^?=!$<>+*/&|~-]";
|
|
3
3
|
export declare const algebraicIdentifierCharacterClass = "[\\w$:!?]";
|
|
4
4
|
export declare const algebraicIdentifierFirstCharacterClass = "[a-zA-Z_$]";
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import type { CondNode } from '../builtin/specialExpressions/cond';
|
|
1
2
|
import type { DefNode } from '../builtin/specialExpressions/def';
|
|
2
3
|
import type { DefnNode } from '../builtin/specialExpressions/functions';
|
|
4
|
+
import type { IfNode } from '../builtin/specialExpressions/if';
|
|
5
|
+
import type { SwitchNode } from '../builtin/specialExpressions/switch';
|
|
6
|
+
import type { UnlessNode } from '../builtin/specialExpressions/unless';
|
|
3
7
|
import type { Arity, FunctionArguments } from '../builtin/utils';
|
|
4
8
|
import type { A_SymbolToken } from '../tokenizer/algebraic/algebraicTokens';
|
|
5
9
|
import type { TokenStream } from '../tokenizer/interface';
|
|
@@ -23,12 +27,18 @@ export declare class AlgebraicParser {
|
|
|
23
27
|
};
|
|
24
28
|
private parseShorthandLamdaFunction;
|
|
25
29
|
private parseLet;
|
|
26
|
-
private
|
|
30
|
+
private parseDo;
|
|
31
|
+
private parseLoop;
|
|
32
|
+
private parseTry;
|
|
33
|
+
private parseForOrDoseq;
|
|
27
34
|
private parseForLoopBinding;
|
|
28
35
|
private parseBinding;
|
|
36
|
+
parseIfOrUnless(token: A_SymbolToken): IfNode | UnlessNode;
|
|
37
|
+
parseCond(token: A_SymbolToken): CondNode;
|
|
38
|
+
parseSwitch(token: A_SymbolToken): SwitchNode;
|
|
29
39
|
parseDef(token: A_SymbolToken): DefNode;
|
|
30
40
|
parseDefn(token: A_SymbolToken): DefnNode;
|
|
31
41
|
private isAtEnd;
|
|
42
|
+
private isAtExpressionEnd;
|
|
32
43
|
private peek;
|
|
33
|
-
private peekAhead;
|
|
34
44
|
}
|
|
@@ -1,8 +1,95 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
declare const validAlgebraicReservedNamesRecord: {
|
|
2
|
+
readonly true: {
|
|
3
|
+
readonly value: true;
|
|
4
|
+
readonly forbidden: false;
|
|
5
|
+
};
|
|
6
|
+
readonly false: {
|
|
7
|
+
readonly value: false;
|
|
8
|
+
readonly forbidden: false;
|
|
9
|
+
};
|
|
10
|
+
readonly nil: {
|
|
11
|
+
readonly value: null;
|
|
12
|
+
readonly forbidden: false;
|
|
13
|
+
};
|
|
14
|
+
readonly null: {
|
|
15
|
+
readonly value: null;
|
|
16
|
+
readonly forbidden: false;
|
|
17
|
+
};
|
|
18
|
+
readonly then: {
|
|
19
|
+
readonly value: null;
|
|
20
|
+
readonly forbidden: false;
|
|
21
|
+
};
|
|
22
|
+
readonly else: {
|
|
23
|
+
readonly value: null;
|
|
24
|
+
readonly forbidden: false;
|
|
25
|
+
};
|
|
26
|
+
readonly end: {
|
|
27
|
+
readonly value: null;
|
|
28
|
+
readonly forbidden: false;
|
|
29
|
+
};
|
|
30
|
+
readonly case: {
|
|
31
|
+
readonly value: null;
|
|
32
|
+
readonly forbidden: false;
|
|
33
|
+
};
|
|
34
|
+
readonly when: {
|
|
35
|
+
readonly value: null;
|
|
36
|
+
readonly forbidden: false;
|
|
37
|
+
};
|
|
38
|
+
readonly while: {
|
|
39
|
+
readonly value: null;
|
|
40
|
+
readonly forbidden: false;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export declare const algebraicReservedNamesRecord: {
|
|
44
|
+
readonly fn: {
|
|
45
|
+
readonly value: null;
|
|
46
|
+
readonly forbidden: true;
|
|
47
|
+
};
|
|
48
|
+
readonly defns: {
|
|
49
|
+
readonly value: null;
|
|
50
|
+
readonly forbidden: true;
|
|
51
|
+
};
|
|
52
|
+
readonly true: {
|
|
53
|
+
readonly value: true;
|
|
54
|
+
readonly forbidden: false;
|
|
55
|
+
};
|
|
56
|
+
readonly false: {
|
|
57
|
+
readonly value: false;
|
|
58
|
+
readonly forbidden: false;
|
|
59
|
+
};
|
|
60
|
+
readonly nil: {
|
|
61
|
+
readonly value: null;
|
|
62
|
+
readonly forbidden: false;
|
|
63
|
+
};
|
|
64
|
+
readonly null: {
|
|
65
|
+
readonly value: null;
|
|
66
|
+
readonly forbidden: false;
|
|
67
|
+
};
|
|
68
|
+
readonly then: {
|
|
69
|
+
readonly value: null;
|
|
70
|
+
readonly forbidden: false;
|
|
71
|
+
};
|
|
72
|
+
readonly else: {
|
|
73
|
+
readonly value: null;
|
|
74
|
+
readonly forbidden: false;
|
|
75
|
+
};
|
|
76
|
+
readonly end: {
|
|
77
|
+
readonly value: null;
|
|
78
|
+
readonly forbidden: false;
|
|
79
|
+
};
|
|
80
|
+
readonly case: {
|
|
81
|
+
readonly value: null;
|
|
82
|
+
readonly forbidden: false;
|
|
83
|
+
};
|
|
84
|
+
readonly when: {
|
|
85
|
+
readonly value: null;
|
|
86
|
+
readonly forbidden: false;
|
|
87
|
+
};
|
|
88
|
+
readonly while: {
|
|
89
|
+
readonly value: null;
|
|
90
|
+
readonly forbidden: false;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
export type ValidAlgebraicReservedName = keyof typeof validAlgebraicReservedNamesRecord;
|
|
94
|
+
export type AlgebraicReservedName = keyof typeof algebraicReservedNamesRecord;
|
|
8
95
|
export {};
|
|
@@ -3,8 +3,8 @@ import type { A_BasePrefixedNumberToken, A_MultiLineCommentToken, A_NumberToken,
|
|
|
3
3
|
export declare const tokenizeA_Whitespace: Tokenizer<A_WhitespaceToken>;
|
|
4
4
|
export declare const tokenizeA_Number: Tokenizer<A_NumberToken>;
|
|
5
5
|
export declare const tokenizeA_BasePrefixedNumber: Tokenizer<A_BasePrefixedNumberToken>;
|
|
6
|
-
export declare const tokenizeA_ReservedSymbolToken: Tokenizer<A_ReservedSymbolToken>;
|
|
7
6
|
export declare const tokenizeA_Symbol: Tokenizer<A_SymbolToken>;
|
|
7
|
+
export declare const tokenizeA_ReservedSymbolToken: Tokenizer<A_ReservedSymbolToken>;
|
|
8
8
|
export declare const tokenizeA_Operator: Tokenizer<A_OperatorToken>;
|
|
9
9
|
export declare const tokenizeA_MultiLineComment: Tokenizer<A_MultiLineCommentToken>;
|
|
10
10
|
export declare const tokenizeA_SingleLineComment: Tokenizer<A_SingleLineCommentToken>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CommonSimpleToken, CommonValueToken, CommonValueTokenType } from '../common/commonTokens';
|
|
2
2
|
import type { Token } from '../tokens';
|
|
3
3
|
import { type TokenDebugData } from '../utils';
|
|
4
|
+
import type { ValidAlgebraicReservedName } from './algebraicReservedNames';
|
|
4
5
|
export declare const algebraicSimpleTokenTypes: readonly ["LBrace", "LBracket", "LParen", "RBrace", "RBracket", "RParen", "AlgNotation", "PolNotation", "EndNotation"];
|
|
5
6
|
export declare const algebraicOnlyValueTokenTypes: ["A_Whitespace", "A_Operator", "A_Symbol", "A_ReservedSymbol", "A_SingleLineComment", "A_MultiLineComment", "A_Number", "A_BasePrefixedNumber"];
|
|
6
7
|
export declare const algebraicValueTokenTypes: readonly ["String", "A_Whitespace", "A_Operator", "A_Symbol", "A_ReservedSymbol", "A_SingleLineComment", "A_MultiLineComment", "A_Number", "A_BasePrefixedNumber"];
|
|
@@ -30,20 +31,20 @@ export type A_NumberToken = GenericAlgebraicValueToken<'A_Number'>;
|
|
|
30
31
|
export type A_BasePrefixedNumberToken = GenericAlgebraicValueToken<'A_BasePrefixedNumber'>;
|
|
31
32
|
export type A_OperatorToken<T extends SymbolicOperator = SymbolicOperator> = GenericAlgebraicValueToken<'A_Operator', T>;
|
|
32
33
|
export type A_SymbolToken<T extends string = string> = GenericAlgebraicValueToken<'A_Symbol', T>;
|
|
33
|
-
export type A_ReservedSymbolToken = GenericAlgebraicValueToken<'A_ReservedSymbol'>;
|
|
34
|
+
export type A_ReservedSymbolToken<T extends ValidAlgebraicReservedName = ValidAlgebraicReservedName> = GenericAlgebraicValueToken<'A_ReservedSymbol', T>;
|
|
34
35
|
export type A_SingleLineCommentToken = GenericAlgebraicValueToken<'A_SingleLineComment'>;
|
|
35
36
|
export type A_MultiLineCommentToken = GenericAlgebraicValueToken<'A_MultiLineComment'>;
|
|
36
37
|
export type AlgebraicOnlyValueToken = A_WhitespaceToken | A_NumberToken | A_BasePrefixedNumberToken | A_OperatorToken | A_SymbolToken | A_ReservedSymbolToken | A_SingleLineCommentToken | A_MultiLineCommentToken;
|
|
37
38
|
export type AlgebraicToken = AlgebraicOnlyValueToken | CommonSimpleToken | CommonValueToken;
|
|
38
|
-
export declare function isA_SymbolToken(token: Token | undefined): token is A_SymbolToken
|
|
39
|
-
export declare function assertA_SymbolToken(token: Token | undefined): asserts token is A_SymbolToken
|
|
40
|
-
export declare function asA_SymbolToken(token: Token | undefined): A_SymbolToken
|
|
39
|
+
export declare function isA_SymbolToken<T extends string>(token: Token | undefined, symbolName?: T): token is A_SymbolToken<T>;
|
|
40
|
+
export declare function assertA_SymbolToken<T extends string>(token: Token | undefined, symbolName?: T): asserts token is A_SymbolToken<T>;
|
|
41
|
+
export declare function asA_SymbolToken<T extends string>(token: Token | undefined, symbolName?: T): A_SymbolToken<T>;
|
|
41
42
|
export declare function isA_BinaryOperatorToken(token: Token | undefined): token is A_OperatorToken<SymbolicBinaryOperator>;
|
|
42
43
|
export declare function assertA_BinaryOperatorToken(token: Token | undefined): asserts token is A_OperatorToken<SymbolicBinaryOperator>;
|
|
43
44
|
export declare function asA_BinaryOperatorToken(token: Token | undefined): A_OperatorToken<SymbolicBinaryOperator>;
|
|
44
|
-
export declare function isA_ReservedSymbolToken(token: Token | undefined): token is A_ReservedSymbolToken
|
|
45
|
-
export declare function assertA_ReservedSymbolToken(token: Token | undefined): asserts token is A_ReservedSymbolToken
|
|
46
|
-
export declare function asA_ReservedSymbolToken(token: Token | undefined): A_ReservedSymbolToken
|
|
45
|
+
export declare function isA_ReservedSymbolToken<T extends ValidAlgebraicReservedName>(token: Token | undefined, symbolName?: T): token is A_ReservedSymbolToken<T>;
|
|
46
|
+
export declare function assertA_ReservedSymbolToken<T extends ValidAlgebraicReservedName>(token: Token | undefined, symbolName?: T): asserts token is A_ReservedSymbolToken<T>;
|
|
47
|
+
export declare function asA_ReservedSymbolToken<T extends ValidAlgebraicReservedName>(token: Token | undefined, symbolName?: T): A_ReservedSymbolToken<T>;
|
|
47
48
|
export declare function isA_CommentToken(token: Token | undefined): token is A_SingleLineCommentToken;
|
|
48
49
|
export declare function assertA_CommentToken(token: Token | undefined): asserts token is A_SingleLineCommentToken;
|
|
49
50
|
export declare function asA_CommentToken(token: Token | undefined): A_SingleLineCommentToken;
|
|
@@ -11,4 +11,4 @@ export declare const tokenizeP_ReservedSymbol: Tokenizer<P_ReservedSymbolToken>;
|
|
|
11
11
|
export declare const tokenizeP_Modifier: Tokenizer<P_ModifierToken>;
|
|
12
12
|
export declare const tokenizeP_CollectionAccessor: Tokenizer<P_CollectionAccessorToken>;
|
|
13
13
|
export declare const tokenizeP_RegexpShorthand: Tokenizer<P_RegexpShorthandToken>;
|
|
14
|
-
export declare const polishTokenizers: [Tokenizer<P_WhitespaceToken>, Tokenizer<P_CommentToken>, Tokenizer<import("../common/commonTokens").PolishNotationToken>, Tokenizer<import("../common/commonTokens").AlgebraicNotationToken>, Tokenizer<import("../common/commonTokens").EndNotationToken>, Tokenizer<import("../common/commonTokens").LParenToken>, Tokenizer<import("../common/commonTokens").RParenToken>, Tokenizer<import("../common/commonTokens").LBracketToken>, Tokenizer<import("../common/commonTokens").RBracketToken>, Tokenizer<import("../common/commonTokens").LBraceToken>, Tokenizer<import("../common/commonTokens").RBraceToken>, Tokenizer<import("../common/commonTokens").StringToken>, Tokenizer<P_StringShorthandToken>, Tokenizer<P_NumberToken>, Tokenizer<P_ReservedSymbolToken>, Tokenizer<
|
|
14
|
+
export declare const polishTokenizers: [Tokenizer<P_WhitespaceToken>, Tokenizer<P_CommentToken>, Tokenizer<import("../common/commonTokens").PolishNotationToken>, Tokenizer<import("../common/commonTokens").AlgebraicNotationToken>, Tokenizer<import("../common/commonTokens").EndNotationToken>, Tokenizer<import("../common/commonTokens").LParenToken>, Tokenizer<import("../common/commonTokens").RParenToken>, Tokenizer<import("../common/commonTokens").LBracketToken>, Tokenizer<import("../common/commonTokens").RBracketToken>, Tokenizer<import("../common/commonTokens").LBraceToken>, Tokenizer<import("../common/commonTokens").RBraceToken>, Tokenizer<import("../common/commonTokens").StringToken>, Tokenizer<P_StringShorthandToken>, Tokenizer<P_NumberToken>, Tokenizer<P_ReservedSymbolToken>, Tokenizer<P_ModifierToken>, Tokenizer<P_SymbolToken>, Tokenizer<P_RegexpShorthandToken>, Tokenizer<P_FnShorthandToken>, Tokenizer<P_CollectionAccessorToken>];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CommonSimpleToken, CommonSimpleTokenType, CommonValueToken, CommonValueTokenType } from '../common/commonTokens';
|
|
2
2
|
import type { Token } from '../tokens';
|
|
3
3
|
import { type TokenDebugData } from '../utils';
|
|
4
|
-
export declare const modifierNames: readonly ["&", "&let", "&when", "&while"];
|
|
4
|
+
export declare const modifierNames: readonly ["&rest", "&let", "&when", "&while"];
|
|
5
5
|
export type ModifierName = typeof modifierNames[number];
|
|
6
6
|
export declare const polishOnlySimpleTokenTypes: ["P_FnShorthand"];
|
|
7
7
|
export declare const polishSimpleTokenTypes: readonly ["LBrace", "LBracket", "LParen", "RBrace", "RBracket", "RParen", "AlgNotation", "PolNotation", "EndNotation", "P_FnShorthand"];
|
|
@@ -6,4 +6,4 @@ export type TokenDebugData = {
|
|
|
6
6
|
export declare function getTokenDebugData(token?: Token): TokenDebugData | undefined;
|
|
7
7
|
export declare function hasTokenDebugData(token?: Token): boolean;
|
|
8
8
|
export declare function addTokenDebugData(token: Token, debugData: TokenDebugData): void;
|
|
9
|
-
export declare function throwUnexpectedToken(expected: TokenType, actual?: Token): never;
|
|
9
|
+
export declare function throwUnexpectedToken(expected: TokenType, expectedValue: string | undefined, actual?: Token): never;
|
|
@@ -6,6 +6,7 @@ type Count = number | {
|
|
|
6
6
|
max?: number;
|
|
7
7
|
};
|
|
8
8
|
export declare function assertEvenNumberOfParams(node: GenericNode): void;
|
|
9
|
+
export declare function assertOddNumberOfParams(node: GenericNode): void;
|
|
9
10
|
export declare function assertNumberOfParams(count: Count, node: GenericNode): void;
|
|
10
11
|
export declare function isNonUndefined<T>(value: T | undefined): value is T;
|
|
11
12
|
export declare function asNonUndefined<T>(value: T | undefined, sourceCodeInfo?: SourceCodeInfo): T;
|