@mojir/lits 1.3.0 → 2.0.2

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 (97) hide show
  1. package/README.md +2 -1
  2. package/dist/cli/cli.js +2661 -1980
  3. package/dist/cli/reference/api.d.ts +2 -2
  4. package/dist/cli/src/Lits/Lits.d.ts +5 -1
  5. package/dist/cli/src/analyze/index.d.ts +1 -1
  6. package/dist/cli/src/builtin/index.d.ts +1 -1
  7. package/dist/cli/src/builtin/interface.d.ts +4 -3
  8. package/dist/cli/src/builtin/specialExpressions/functions.d.ts +2 -2
  9. package/dist/cli/src/builtin/specialExpressions/if-let.d.ts +1 -4
  10. package/dist/cli/src/builtin/specialExpressions/let.d.ts +1 -4
  11. package/dist/cli/src/builtin/specialExpressions/try.d.ts +2 -2
  12. package/dist/cli/src/constants/constants.d.ts +2 -17
  13. package/dist/cli/src/errors.d.ts +1 -1
  14. package/dist/cli/src/evaluator/ContextStack.d.ts +3 -3
  15. package/dist/cli/src/identifier.d.ts +4 -0
  16. package/dist/cli/src/index.d.ts +12 -6
  17. package/dist/cli/src/parser/AlgebraicParser.d.ts +17 -0
  18. package/dist/cli/src/parser/PolishTokenParsers.d.ts +3 -0
  19. package/dist/cli/src/parser/commonTokenParsers.d.ts +6 -0
  20. package/dist/cli/src/parser/index.d.ts +2 -1
  21. package/dist/cli/src/parser/interface.d.ts +26 -20
  22. package/dist/cli/src/removeCommentNodes/index.d.ts +1 -1
  23. package/dist/cli/src/tokenizer/algebraic/algebraicReservedNames.d.ts +8 -0
  24. package/dist/cli/src/tokenizer/algebraic/algebraicTokenizers.d.ts +10 -0
  25. package/dist/cli/src/tokenizer/algebraic/algebraicTokens.d.ts +47 -0
  26. package/dist/cli/src/tokenizer/common/commonTokenizers.d.ts +8 -0
  27. package/dist/cli/src/tokenizer/common/commonTokens.d.ts +51 -0
  28. package/dist/cli/src/tokenizer/index.d.ts +1 -8
  29. package/dist/cli/src/tokenizer/interface.d.ts +5 -18
  30. package/dist/cli/src/tokenizer/polish/polishReservedNames.d.ts +7 -0
  31. package/dist/cli/src/tokenizer/polish/polishTokenizers.d.ts +13 -0
  32. package/dist/cli/src/tokenizer/polish/polishTokens.d.ts +59 -0
  33. package/dist/cli/src/tokenizer/tokens.d.ts +20 -0
  34. package/dist/cli/src/tokenizer/utils.d.ts +9 -0
  35. package/dist/cli/src/transformer/index.d.ts +2 -0
  36. package/dist/cli/src/typeGuards/astNode.d.ts +4 -4
  37. package/dist/cli/src/typeGuards/index.d.ts +0 -1
  38. package/dist/cli/src/untokenizer/index.d.ts +2 -0
  39. package/dist/cli/src/utils/debug/debugTools.d.ts +0 -2
  40. package/dist/cli/src/utils/debug/getCodeMarker.d.ts +2 -0
  41. package/dist/index.esm.js +9078 -1569
  42. package/dist/index.esm.js.map +1 -1
  43. package/dist/index.js +9089 -1569
  44. package/dist/index.js.map +1 -1
  45. package/dist/lits.iife.js +9089 -1569
  46. package/dist/lits.iife.js.map +1 -1
  47. package/dist/reference/api.d.ts +2 -2
  48. package/dist/src/Lits/Lits.d.ts +5 -1
  49. package/dist/src/analyze/index.d.ts +1 -1
  50. package/dist/src/builtin/index.d.ts +1 -1
  51. package/dist/src/builtin/interface.d.ts +4 -3
  52. package/dist/src/builtin/specialExpressions/functions.d.ts +2 -2
  53. package/dist/src/builtin/specialExpressions/if-let.d.ts +1 -4
  54. package/dist/src/builtin/specialExpressions/let.d.ts +1 -4
  55. package/dist/src/builtin/specialExpressions/try.d.ts +2 -2
  56. package/dist/src/constants/constants.d.ts +2 -17
  57. package/dist/src/errors.d.ts +1 -1
  58. package/dist/src/evaluator/ContextStack.d.ts +3 -3
  59. package/dist/src/identifier.d.ts +4 -0
  60. package/dist/src/index.d.ts +12 -6
  61. package/dist/src/parser/AlgebraicParser.d.ts +17 -0
  62. package/dist/src/parser/PolishTokenParsers.d.ts +3 -0
  63. package/dist/src/parser/commonTokenParsers.d.ts +6 -0
  64. package/dist/src/parser/index.d.ts +2 -1
  65. package/dist/src/parser/interface.d.ts +26 -20
  66. package/dist/src/removeCommentNodes/index.d.ts +1 -1
  67. package/dist/src/tokenizer/algebraic/algebraicReservedNames.d.ts +8 -0
  68. package/dist/src/tokenizer/algebraic/algebraicTokenizers.d.ts +10 -0
  69. package/dist/src/tokenizer/algebraic/algebraicTokens.d.ts +47 -0
  70. package/dist/src/tokenizer/common/commonTokenizers.d.ts +8 -0
  71. package/dist/src/tokenizer/common/commonTokens.d.ts +51 -0
  72. package/dist/src/tokenizer/index.d.ts +1 -8
  73. package/dist/src/tokenizer/interface.d.ts +5 -18
  74. package/dist/src/tokenizer/polish/polishReservedNames.d.ts +7 -0
  75. package/dist/src/tokenizer/polish/polishTokenizers.d.ts +13 -0
  76. package/dist/src/tokenizer/polish/polishTokens.d.ts +59 -0
  77. package/dist/src/tokenizer/tokens.d.ts +20 -0
  78. package/dist/src/tokenizer/utils.d.ts +9 -0
  79. package/dist/src/transformer/index.d.ts +2 -0
  80. package/dist/src/typeGuards/astNode.d.ts +4 -4
  81. package/dist/src/typeGuards/index.d.ts +0 -1
  82. package/dist/src/untokenizer/index.d.ts +2 -0
  83. package/dist/src/utils/debug/debugTools.d.ts +0 -2
  84. package/dist/src/utils/debug/getCodeMarker.d.ts +2 -0
  85. package/dist/testFramework.esm.js +2196 -1539
  86. package/dist/testFramework.esm.js.map +1 -1
  87. package/dist/testFramework.js +2196 -1539
  88. package/dist/testFramework.js.map +1 -1
  89. package/package.json +6 -5
  90. package/dist/cli/src/parser/parsers.d.ts +0 -4
  91. package/dist/cli/src/reservedNames.d.ts +0 -7
  92. package/dist/cli/src/tokenizer/tokenizers.d.ts +0 -20
  93. package/dist/cli/src/typeGuards/token.d.ts +0 -13
  94. package/dist/src/parser/parsers.d.ts +0 -4
  95. package/dist/src/reservedNames.d.ts +0 -7
  96. package/dist/src/tokenizer/tokenizers.d.ts +0 -20
  97. package/dist/src/typeGuards/token.d.ts +0 -13
@@ -0,0 +1,13 @@
1
+ import type { Tokenizer } from '../interface';
2
+ import type { P_CollectionAccessorToken, P_CommentToken, P_FnShorthandToken, P_ModifierToken, P_NumberToken, P_RegexpShorthandToken, P_ReservedSymbolToken, P_StringShorthandToken, P_SymbolToken, P_WhitespaceToken } from './polishTokens';
3
+ export declare const tokenizeP_Comment: Tokenizer<P_CommentToken>;
4
+ export declare const tokenizeP_Whitespace: Tokenizer<P_WhitespaceToken>;
5
+ export declare const tokenizeP_Number: Tokenizer<P_NumberToken>;
6
+ export declare const P_symbolRegExp: RegExp;
7
+ export declare const tokenizeP_Symbol: Tokenizer<P_SymbolToken>;
8
+ export declare const tokenizeP_FnShorthand: Tokenizer<P_FnShorthandToken>;
9
+ export declare const tokenizeP_ReservedSymbol: Tokenizer<P_ReservedSymbolToken>;
10
+ export declare const tokenizeP_Modifier: Tokenizer<P_ModifierToken>;
11
+ export declare const tokenizeP_CollectionAccessor: Tokenizer<P_CollectionAccessorToken>;
12
+ export declare const tokenizeP_RegexpShorthand: Tokenizer<P_RegexpShorthandToken>;
13
+ 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_SymbolToken>, Tokenizer<P_ModifierToken>, Tokenizer<P_RegexpShorthandToken>, Tokenizer<P_FnShorthandToken>, Tokenizer<P_CollectionAccessorToken>];
@@ -0,0 +1,59 @@
1
+ import type { CommonSimpleToken, CommonSimpleTokenType, CommonValueToken, CommonValueTokenType } from '../common/commonTokens';
2
+ import type { Token } from '../tokens';
3
+ import { type TokenDebugData } from '../utils';
4
+ export declare const modifierNames: readonly ["&", "&let", "&when", "&while"];
5
+ export type ModifierName = typeof modifierNames[number];
6
+ export declare const polishOnlySimpleTokenTypes: ["P_FnShorthand"];
7
+ export declare const polishSimpleTokenTypes: readonly ["LBrace", "LBracket", "LParen", "RBrace", "RBracket", "RParen", "AlgNotation", "PolNotation", "EndNotation", "P_FnShorthand"];
8
+ export declare const polishOnlyValueTokenTypes: ["P_Modifier", "P_StringShorthand", "P_Symbol", "P_ReservedSymbol", "P_RegexpShorthand", "P_CollectionAccessor", "P_Comment", "P_Whitespace", "P_Number"];
9
+ export declare const polishValueTokenTypes: readonly ["String", "P_Modifier", "P_StringShorthand", "P_Symbol", "P_ReservedSymbol", "P_RegexpShorthand", "P_CollectionAccessor", "P_Comment", "P_Whitespace", "P_Number"];
10
+ export declare const polishTokenTypes: readonly ["LBrace", "LBracket", "LParen", "RBrace", "RBracket", "RParen", "AlgNotation", "PolNotation", "EndNotation", "P_FnShorthand", "String", "P_Modifier", "P_StringShorthand", "P_Symbol", "P_ReservedSymbol", "P_RegexpShorthand", "P_CollectionAccessor", "P_Comment", "P_Whitespace", "P_Number"];
11
+ export type PolishSimpleTokenType = typeof polishSimpleTokenTypes[number];
12
+ export type PolishValueTokenType = typeof polishValueTokenTypes[number];
13
+ export type PolishTokenType = typeof polishTokenTypes[number];
14
+ type GenericPolishSimpleToken<T extends Exclude<PolishSimpleTokenType, CommonSimpleTokenType>> = [T] | [T, TokenDebugData];
15
+ type GenericPolishValueToken<T extends Exclude<PolishValueTokenType, CommonValueTokenType>, V extends string = string> = [T, V] | [T, V, TokenDebugData];
16
+ export type P_FnShorthandToken = GenericPolishSimpleToken<'P_FnShorthand'>;
17
+ export type P_ModifierToken = GenericPolishValueToken<'P_Modifier', ModifierName>;
18
+ export type P_StringShorthandToken = GenericPolishValueToken<'P_StringShorthand'>;
19
+ export type P_SymbolToken = GenericPolishValueToken<'P_Symbol'>;
20
+ export type P_ReservedSymbolToken = GenericPolishValueToken<'P_ReservedSymbol'>;
21
+ export type P_RegexpShorthandToken = GenericPolishValueToken<'P_RegexpShorthand'>;
22
+ export type P_CollectionAccessorToken = GenericPolishValueToken<'P_CollectionAccessor', '.' | '#'>;
23
+ export type P_CommentToken = GenericPolishValueToken<'P_Comment'>;
24
+ export type P_WhitespaceToken = GenericPolishValueToken<'P_Whitespace'>;
25
+ export type P_NumberToken = GenericPolishValueToken<'P_Number'>;
26
+ export type PolishOnlySimpleToken = P_FnShorthandToken;
27
+ export type PolishOnlyValueToken = P_ModifierToken | P_StringShorthandToken | P_SymbolToken | P_ReservedSymbolToken | P_RegexpShorthandToken | P_CollectionAccessorToken | P_CommentToken | P_WhitespaceToken | P_NumberToken;
28
+ export type PolishToken = PolishOnlySimpleToken | PolishOnlyValueToken | CommonSimpleToken | CommonValueToken;
29
+ export declare function isP_StringShorthandToken(token?: Token): token is P_StringShorthandToken;
30
+ export declare function assertP_StringShorthandToken(token?: Token): asserts token is P_StringShorthandToken;
31
+ export declare function asP_StringShorthandToken(token?: Token): P_StringShorthandToken;
32
+ export declare function isP_SymbolToken(token?: Token): token is P_SymbolToken;
33
+ export declare function assertP_SymbolToken(token?: Token): asserts token is P_SymbolToken;
34
+ export declare function asP_SymbolToken(token?: Token): P_SymbolToken;
35
+ export declare function isP_ReservedSymbolToken(token?: Token): token is P_ReservedSymbolToken;
36
+ export declare function assertP_ReservedSymbolToken(token?: Token): asserts token is P_ReservedSymbolToken;
37
+ export declare function asP_ReservedSymbolToken(token?: Token): P_ReservedSymbolToken;
38
+ export declare function isP_ModifierToken(token?: Token): token is P_ModifierToken;
39
+ export declare function assertP_ModifierToken(token?: Token): asserts token is P_ModifierToken;
40
+ export declare function asP_ModifierToken(token?: Token): P_ModifierToken;
41
+ export declare function isP_RegexpShorthandToken(token?: Token): token is P_RegexpShorthandToken;
42
+ export declare function assertP_RegexpShorthandToken(token?: Token): asserts token is P_RegexpShorthandToken;
43
+ export declare function asP_RegexpShorthandToken(token?: Token): P_RegexpShorthandToken;
44
+ export declare function isP_FnShorthandToken(token?: Token): token is P_FnShorthandToken;
45
+ export declare function assertP_FnShorthandToken(token?: Token): asserts token is P_FnShorthandToken;
46
+ export declare function asP_FnShorthandToken(token?: Token): P_FnShorthandToken;
47
+ export declare function isP_CollectionAccessorToken(token?: Token): token is P_CollectionAccessorToken;
48
+ export declare function assertP_CollectionAccessorToken(token?: Token): asserts token is P_CollectionAccessorToken;
49
+ export declare function asP_CollectionAccessorToken(token?: Token): P_CollectionAccessorToken;
50
+ export declare function isP_CommentToken(token?: Token): token is P_CommentToken;
51
+ export declare function assertP_CommentToken(token?: Token): asserts token is P_CommentToken;
52
+ export declare function asP_CommentToken(token?: Token): P_CommentToken;
53
+ export declare function isP_WhitespaceToken(token?: Token): token is P_WhitespaceToken;
54
+ export declare function assertP_WhitespaceToken(token?: Token): asserts token is P_WhitespaceToken;
55
+ export declare function asP_WhitespaceToken(token?: Token): P_WhitespaceToken;
56
+ export declare function isP_NumberToken(token?: Token): token is P_NumberToken;
57
+ export declare function assertP_NumberToken(token?: Token): asserts token is P_NumberToken;
58
+ export declare function asP_NumberToken(token?: Token): P_NumberToken;
59
+ export {};
@@ -0,0 +1,20 @@
1
+ import type { CommonSimpleToken, CommonValueToken } from './common/commonTokens';
2
+ import type { AlgebraicOnlyValueToken } from './algebraic/algebraicTokens';
3
+ import type { PolishOnlySimpleToken, PolishOnlyValueToken } from './polish/polishTokens';
4
+ export declare const simpleTokenTypes: readonly ["LBrace", "LBracket", "LParen", "RBrace", "RBracket", "RParen", "AlgNotation", "PolNotation", "EndNotation", "P_FnShorthand"];
5
+ export declare const valueTokenTypes: readonly ["String", "A_Whitespace", "A_Operator", "A_Symbol", "A_ReservedSymbol", "A_SingleLineComment", "A_MultiLineComment", "A_Number", "P_Modifier", "P_StringShorthand", "P_Symbol", "P_ReservedSymbol", "P_RegexpShorthand", "P_CollectionAccessor", "P_Comment", "P_Whitespace", "P_Number"];
6
+ export declare const tokenTypes: readonly ["LBrace", "LBracket", "LParen", "RBrace", "RBracket", "RParen", "AlgNotation", "PolNotation", "EndNotation", "P_FnShorthand", "String", "A_Whitespace", "A_Operator", "A_Symbol", "A_ReservedSymbol", "A_SingleLineComment", "A_MultiLineComment", "A_Number", "P_Modifier", "P_StringShorthand", "P_Symbol", "P_ReservedSymbol", "P_RegexpShorthand", "P_CollectionAccessor", "P_Comment", "P_Whitespace", "P_Number"];
7
+ export type TokenType = typeof tokenTypes[number];
8
+ export type SimpleToken = CommonSimpleToken | PolishOnlySimpleToken;
9
+ export type ValueToken = CommonValueToken | AlgebraicOnlyValueToken | PolishOnlyValueToken;
10
+ export type Token = SimpleToken | ValueToken;
11
+ export declare function isTokenType(type: string): type is TokenType;
12
+ export declare function isToken(token?: Token): token is Token;
13
+ export declare function assertToken(token?: Token): asserts token is Token;
14
+ export declare function asToken(token?: Token): Token;
15
+ export declare function isSimpleToken(token?: Token): token is SimpleToken;
16
+ export declare function assertSimpleToken(token?: Token): asserts token is SimpleToken;
17
+ export declare function asSimpleToken(token?: Token): SimpleToken;
18
+ export declare function isValueToken(token?: Token): token is ValueToken;
19
+ export declare function assertValueToken(token?: Token): asserts token is ValueToken;
20
+ export declare function asValueToken(token?: Token): ValueToken;
@@ -0,0 +1,9 @@
1
+ import type { SourceCodeInfo } from './interface';
2
+ import type { Token, TokenType } from './tokens';
3
+ export type TokenDebugData = {
4
+ sourceCodeInfo: SourceCodeInfo;
5
+ };
6
+ export declare function getTokenDebugData(token?: Token): TokenDebugData | undefined;
7
+ export declare function hasTokenDebugData(token?: Token): boolean;
8
+ export declare function addTokenDebugData(token: Token, debugData: TokenDebugData): void;
9
+ export declare function throwUnexpectedToken(expected: TokenType, actual?: Token): never;
@@ -0,0 +1,2 @@
1
+ import type { TokenStream } from '../tokenizer/interface';
2
+ export declare function transformTokens(tokenStram: TokenStream, transformer: (name: string) => string): TokenStream;
@@ -1,11 +1,11 @@
1
- import type { AstNode, ExpressionNode, NameNode, NormalExpressionNode, NormalExpressionNodeWithName } from '../parser/interface';
1
+ import type { AstNode, ExpressionNode, NormalExpressionNode, NormalExpressionNodeWithName, SymbolNode } from '../parser/interface';
2
2
  import type { SourceCodeInfo } from '../tokenizer/interface';
3
3
  export declare function isAstNode(value: unknown): value is AstNode;
4
4
  export declare function asAstNode(value: unknown, sourceCodeInfo?: SourceCodeInfo): AstNode;
5
5
  export declare function assertAstNode(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is AstNode;
6
- export declare function isNameNode(value: unknown): value is NameNode;
7
- export declare function asNameNode(value: unknown, sourceCodeInfo?: SourceCodeInfo): NameNode;
8
- export declare function assertNameNode(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is NameNode;
6
+ export declare function isSymbolNode(value: unknown): value is SymbolNode;
7
+ export declare function asSymbolNode(value: unknown, sourceCodeInfo?: SourceCodeInfo): SymbolNode;
8
+ export declare function assertSymbolNode(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is SymbolNode;
9
9
  export declare function isNormalExpressionNode(value: unknown): value is NormalExpressionNode;
10
10
  export declare function asNormalExpressionNode(value: unknown, sourceCodeInfo?: SourceCodeInfo): NormalExpressionNode;
11
11
  export declare function assertNormalExpressionNode(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is NormalExpressionNode;
@@ -10,7 +10,6 @@ export declare function assertNumberOfParams(count: Count, node: GenericNode): v
10
10
  export declare function isNonUndefined<T>(value: T | undefined): value is T;
11
11
  export declare function asNonUndefined<T>(value: T | undefined, sourceCodeInfo?: SourceCodeInfo): T;
12
12
  export declare function assertNonUndefined<T>(value: T | undefined, sourceCodeInfo?: SourceCodeInfo): asserts value is T;
13
- export declare function assertUnreachable(_: never): never;
14
13
  export declare function isUnknownRecord(value: unknown): value is Record<string, unknown>;
15
14
  export declare function assertUnknownRecord(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is UnknownRecord;
16
15
  export declare function asUnknownRecord(value: unknown, sourceCodeInfo?: SourceCodeInfo): UnknownRecord;
@@ -0,0 +1,2 @@
1
+ import type { TokenStream } from '../tokenizer/interface';
2
+ export declare function untokenize(tokenStream: TokenStream): string;
@@ -1,3 +1 @@
1
- import type { SourceCodeInfo } from '../../tokenizer/interface';
2
1
  export declare function valueToString(value: unknown): string;
3
- export declare function getCodeMarker(sourceCodeInfo: SourceCodeInfo): string;
@@ -0,0 +1,2 @@
1
+ import type { SourceCodeInfo } from '../../tokenizer/interface';
2
+ export declare function getCodeMarker(sourceCodeInfo: SourceCodeInfo): string;