greybel-interpreter 1.1.7 → 1.1.8

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/.editorconfig +14 -14
  2. package/.eslintrc +47 -47
  3. package/LICENSE +21 -21
  4. package/README.md +2 -2
  5. package/dist/context.d.ts +109 -109
  6. package/dist/context.js +382 -382
  7. package/dist/cps.d.ts +14 -14
  8. package/dist/cps.js +213 -213
  9. package/dist/handler/error.d.ts +6 -6
  10. package/dist/handler/error.js +35 -35
  11. package/dist/handler/output.d.ts +6 -6
  12. package/dist/handler/output.js +35 -35
  13. package/dist/handler/resource.d.ts +12 -12
  14. package/dist/handler/resource.js +51 -51
  15. package/dist/handler-container.d.ts +14 -14
  16. package/dist/handler-container.js +16 -16
  17. package/dist/index.d.ts +44 -44
  18. package/dist/index.js +129 -129
  19. package/dist/interpreter.d.ts +41 -41
  20. package/dist/interpreter.js +315 -315
  21. package/dist/intrinsics-container.d.ts +7 -7
  22. package/dist/intrinsics-container.js +19 -19
  23. package/dist/operations/assign.d.ts +13 -13
  24. package/dist/operations/assign.js +111 -111
  25. package/dist/operations/block.d.ts +12 -12
  26. package/dist/operations/block.js +108 -108
  27. package/dist/operations/break.d.ts +10 -10
  28. package/dist/operations/break.js +41 -41
  29. package/dist/operations/call.d.ts +13 -13
  30. package/dist/operations/call.js +124 -124
  31. package/dist/operations/chunk.d.ts +12 -12
  32. package/dist/operations/chunk.js +85 -85
  33. package/dist/operations/continue.d.ts +10 -10
  34. package/dist/operations/continue.js +41 -41
  35. package/dist/operations/debugger-statement.d.ts +10 -10
  36. package/dist/operations/debugger-statement.js +39 -39
  37. package/dist/operations/evaluate.d.ts +39 -39
  38. package/dist/operations/evaluate.js +366 -366
  39. package/dist/operations/for.d.ts +14 -14
  40. package/dist/operations/for.js +152 -152
  41. package/dist/operations/function-reference.d.ts +12 -12
  42. package/dist/operations/function-reference.js +103 -103
  43. package/dist/operations/function.d.ts +14 -14
  44. package/dist/operations/function.js +200 -200
  45. package/dist/operations/if-statement.d.ts +19 -19
  46. package/dist/operations/if-statement.js +181 -181
  47. package/dist/operations/import.d.ts +17 -17
  48. package/dist/operations/import.js +119 -119
  49. package/dist/operations/include.d.ts +13 -13
  50. package/dist/operations/include.js +95 -95
  51. package/dist/operations/list.d.ts +11 -11
  52. package/dist/operations/list.js +111 -111
  53. package/dist/operations/literal.d.ts +11 -11
  54. package/dist/operations/literal.js +58 -58
  55. package/dist/operations/map.d.ts +11 -11
  56. package/dist/operations/map.js +171 -171
  57. package/dist/operations/negated-binary.d.ts +11 -11
  58. package/dist/operations/negated-binary.js +109 -109
  59. package/dist/operations/new-instance.d.ts +11 -11
  60. package/dist/operations/new-instance.js +100 -100
  61. package/dist/operations/noop.d.ts +9 -9
  62. package/dist/operations/noop.js +36 -36
  63. package/dist/operations/not.d.ts +11 -11
  64. package/dist/operations/not.js +96 -96
  65. package/dist/operations/operation.d.ts +13 -13
  66. package/dist/operations/operation.js +11 -11
  67. package/dist/operations/reference.d.ts +9 -9
  68. package/dist/operations/reference.js +37 -37
  69. package/dist/operations/resolve.d.ts +38 -38
  70. package/dist/operations/resolve.js +330 -330
  71. package/dist/operations/return.d.ts +11 -11
  72. package/dist/operations/return.js +107 -107
  73. package/dist/operations/while.d.ts +13 -13
  74. package/dist/operations/while.js +136 -136
  75. package/dist/types/boolean.d.ts +11 -11
  76. package/dist/types/boolean.js +46 -46
  77. package/dist/types/default.d.ts +11 -11
  78. package/dist/types/default.js +20 -20
  79. package/dist/types/function.d.ts +32 -32
  80. package/dist/types/function.js +174 -174
  81. package/dist/types/generics.d.ts +18 -18
  82. package/dist/types/generics.js +40 -40
  83. package/dist/types/interface.d.ts +23 -23
  84. package/dist/types/interface.js +103 -103
  85. package/dist/types/list.d.ts +31 -31
  86. package/dist/types/list.js +209 -209
  87. package/dist/types/map.d.ts +35 -35
  88. package/dist/types/map.js +287 -287
  89. package/dist/types/nil.d.ts +10 -10
  90. package/dist/types/nil.js +46 -46
  91. package/dist/types/number.d.ts +11 -11
  92. package/dist/types/number.js +46 -46
  93. package/dist/types/string.d.ts +33 -33
  94. package/dist/types/string.js +145 -145
  95. package/dist/utils/path.d.ts +10 -10
  96. package/dist/utils/path.js +59 -59
  97. package/package.json +58 -58
package/.editorconfig CHANGED
@@ -1,15 +1,15 @@
1
- # EditorConfig helps developers define and maintain consistent
2
- # coding styles between different editors and IDEs
3
- # See http://editorconfig.org
4
- root = true
5
-
6
- [*]
7
- end_of_line = lf
8
- insert_final_newline = true
9
- trim_trailing_whitespace = true
10
- indent_style = space
11
- indent_size = 2
12
- charset = utf-8
13
-
14
- [*.md]
1
+ # EditorConfig helps developers define and maintain consistent
2
+ # coding styles between different editors and IDEs
3
+ # See http://editorconfig.org
4
+ root = true
5
+
6
+ [*]
7
+ end_of_line = lf
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+ indent_style = space
11
+ indent_size = 2
12
+ charset = utf-8
13
+
14
+ [*.md]
15
15
  trim_trailing_whitespace = false
package/.eslintrc CHANGED
@@ -1,48 +1,48 @@
1
- {
2
- "parser": "@typescript-eslint/parser",
3
- "plugins": [
4
- "@typescript-eslint",
5
- "promise",
6
- "simple-import-sort",
7
- "jest",
8
- "security",
9
- "prettier"
10
- ],
11
- "env": {
12
- "jest": true,
13
- "node": true
14
- },
15
- "globals": {
16
- "BufferEncoding": true,
17
- "NodeJS": true
18
- },
19
- "extends": [
20
- "eslint:recommended",
21
- "standard",
22
- "plugin:promise/recommended",
23
- "plugin:jest/recommended",
24
- "plugin:security/recommended",
25
- "plugin:prettier/recommended"
26
- ],
27
- "rules": {
28
- "camelcase": "off",
29
- "no-unused-vars": "off",
30
- "no-empty": "off",
31
- "@typescript-eslint/no-unused-vars": [
32
- "error",
33
- { "args": "after-used", "argsIgnorePattern": "^_" }
34
- ],
35
- "@typescript-eslint/no-explicit-any": "warn",
36
- "simple-import-sort/imports": "error",
37
- "simple-import-sort/exports": "error",
38
- "prettier/prettier": ["error", { "singleQuote": true, "trailingComma": "none" }]
39
- },
40
- "overrides": [{
41
- "files": ["**/*.test.ts", "tests/**/*"],
42
- "rules": {
43
- "@typescript-eslint/no-explicit-any": "off",
44
- "security/detect-object-injection": "off",
45
- "security/detect-unsafe-regex": "off"
46
- }
47
- }]
1
+ {
2
+ "parser": "@typescript-eslint/parser",
3
+ "plugins": [
4
+ "@typescript-eslint",
5
+ "promise",
6
+ "simple-import-sort",
7
+ "jest",
8
+ "security",
9
+ "prettier"
10
+ ],
11
+ "env": {
12
+ "jest": true,
13
+ "node": true
14
+ },
15
+ "globals": {
16
+ "BufferEncoding": true,
17
+ "NodeJS": true
18
+ },
19
+ "extends": [
20
+ "eslint:recommended",
21
+ "standard",
22
+ "plugin:promise/recommended",
23
+ "plugin:jest/recommended",
24
+ "plugin:security/recommended",
25
+ "plugin:prettier/recommended"
26
+ ],
27
+ "rules": {
28
+ "camelcase": "off",
29
+ "no-unused-vars": "off",
30
+ "no-empty": "off",
31
+ "@typescript-eslint/no-unused-vars": [
32
+ "error",
33
+ { "args": "after-used", "argsIgnorePattern": "^_" }
34
+ ],
35
+ "@typescript-eslint/no-explicit-any": "warn",
36
+ "simple-import-sort/imports": "error",
37
+ "simple-import-sort/exports": "error",
38
+ "prettier/prettier": ["error", { "singleQuote": true, "trailingComma": "none" }]
39
+ },
40
+ "overrides": [{
41
+ "files": ["**/*.test.ts", "tests/**/*"],
42
+ "rules": {
43
+ "@typescript-eslint/no-explicit-any": "off",
44
+ "security/detect-object-injection": "off",
45
+ "security/detect-unsafe-regex": "off"
46
+ }
47
+ }]
48
48
  }
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 swe
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2021 swe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
- # greybel-interpreter
2
-
1
+ # greybel-interpreter
2
+
3
3
  [![greybel-interpreter](https://circleci.com/gh/ayecue/greybel-interpreter.svg?style=svg)](https://circleci.com/gh/ayecue/greybel-interpreter)
package/dist/context.d.ts CHANGED
@@ -1,109 +1,109 @@
1
- import { ASTBase } from 'greyscript-core';
2
- import CPS from './cps';
3
- import HandlerContainer from './handler-container';
4
- import Operation from './operations/operation';
5
- import { CustomValue } from './types/generics';
6
- import CustomMap from './types/map';
7
- import CustomNil from './types/nil';
8
- import Path from './utils/path';
9
- export declare enum ContextType {
10
- Api = 0,
11
- Global = 1,
12
- Function = 2,
13
- External = 3,
14
- Loop = 4,
15
- Map = 5,
16
- Call = 6
17
- }
18
- export declare enum ContextState {
19
- Temporary = 0,
20
- Default = 1
21
- }
22
- export declare class Scope extends CustomMap {
23
- private readonly context;
24
- constructor(context: OperationContext);
25
- get(path: Path<CustomValue> | CustomValue): CustomValue;
26
- }
27
- export declare class Debugger {
28
- private breakpoint;
29
- private nextStep;
30
- private lastContext;
31
- getLastContext(): OperationContext;
32
- debug(...segments: any[]): CustomNil;
33
- setBreakpoint(breakpoint: boolean): Debugger;
34
- getBreakpoint(_ctx: OperationContext): boolean;
35
- next(): Debugger;
36
- resume(): Promise<void>;
37
- interact(ctx: OperationContext, _ast: ASTBase, _op: Operation): void;
38
- }
39
- export declare class ProcessState {
40
- isExit: boolean;
41
- isPending: boolean;
42
- last: OperationContext;
43
- }
44
- export declare class LoopState {
45
- isBreak: boolean;
46
- isContinue: boolean;
47
- }
48
- export declare class FunctionState {
49
- value: CustomValue;
50
- isReturn: boolean;
51
- }
52
- export interface ContextOptions {
53
- target?: string;
54
- previous?: OperationContext;
55
- type?: ContextType;
56
- state?: ContextState;
57
- isProtected?: boolean;
58
- injected?: boolean;
59
- debugger?: Debugger;
60
- handler?: HandlerContainer;
61
- cps?: CPS;
62
- processState?: ProcessState;
63
- }
64
- export interface ContextForkOptions {
65
- type: ContextType;
66
- state: ContextState;
67
- target?: string;
68
- injected?: boolean;
69
- }
70
- export default class OperationContext {
71
- target: string;
72
- stackItem: ASTBase;
73
- debugger: Debugger;
74
- handler: HandlerContainer;
75
- previous: OperationContext;
76
- readonly type: ContextType;
77
- readonly state: ContextState;
78
- readonly scope: Scope;
79
- readonly cps: CPS;
80
- readonly processState: ProcessState;
81
- loopState: LoopState;
82
- functionState: FunctionState;
83
- isProtected: boolean;
84
- injected: boolean;
85
- readonly api: OperationContext;
86
- readonly locals: OperationContext;
87
- readonly globals: OperationContext;
88
- private static readonly lookupApiType;
89
- private static readonly lookupGlobalsType;
90
- private static readonly lookupLocalsType;
91
- constructor(options?: ContextOptions);
92
- step(op: Operation): Promise<void>;
93
- setLastActive(ctx: OperationContext): OperationContext;
94
- getLastActive(): OperationContext;
95
- isExit(): boolean;
96
- isPending(): boolean;
97
- setPending(pending: boolean): OperationContext;
98
- lookupAllOfType(validate: (type: ContextType) => boolean): OperationContext[];
99
- exit(): Promise<OperationContext>;
100
- lookupType(allowedTypes: Array<ContextType>): OperationContext;
101
- lookupAllScopes(): OperationContext[];
102
- lookupApi(): OperationContext;
103
- lookupGlobals(): OperationContext;
104
- lookupLocals(): OperationContext;
105
- extend(map: Map<CustomValue, CustomValue>): OperationContext;
106
- set(path: Path<CustomValue> | CustomValue, value: CustomValue): void;
107
- get(path: Path<CustomValue> | CustomValue): CustomValue;
108
- fork(options: ContextForkOptions): OperationContext;
109
- }
1
+ import { ASTBase } from 'greyscript-core';
2
+ import CPS from './cps';
3
+ import HandlerContainer from './handler-container';
4
+ import Operation from './operations/operation';
5
+ import { CustomValue } from './types/generics';
6
+ import CustomMap from './types/map';
7
+ import CustomNil from './types/nil';
8
+ import Path from './utils/path';
9
+ export declare enum ContextType {
10
+ Api = 0,
11
+ Global = 1,
12
+ Function = 2,
13
+ External = 3,
14
+ Loop = 4,
15
+ Map = 5,
16
+ Call = 6
17
+ }
18
+ export declare enum ContextState {
19
+ Temporary = 0,
20
+ Default = 1
21
+ }
22
+ export declare class Scope extends CustomMap {
23
+ private readonly context;
24
+ constructor(context: OperationContext);
25
+ get(path: Path<CustomValue> | CustomValue): CustomValue;
26
+ }
27
+ export declare class Debugger {
28
+ private breakpoint;
29
+ private nextStep;
30
+ private lastContext;
31
+ getLastContext(): OperationContext;
32
+ debug(...segments: any[]): CustomNil;
33
+ setBreakpoint(breakpoint: boolean): Debugger;
34
+ getBreakpoint(_ctx: OperationContext): boolean;
35
+ next(): Debugger;
36
+ resume(): Promise<void>;
37
+ interact(ctx: OperationContext, _ast: ASTBase, _op: Operation): void;
38
+ }
39
+ export declare class ProcessState {
40
+ isExit: boolean;
41
+ isPending: boolean;
42
+ last: OperationContext;
43
+ }
44
+ export declare class LoopState {
45
+ isBreak: boolean;
46
+ isContinue: boolean;
47
+ }
48
+ export declare class FunctionState {
49
+ value: CustomValue;
50
+ isReturn: boolean;
51
+ }
52
+ export interface ContextOptions {
53
+ target?: string;
54
+ previous?: OperationContext;
55
+ type?: ContextType;
56
+ state?: ContextState;
57
+ isProtected?: boolean;
58
+ injected?: boolean;
59
+ debugger?: Debugger;
60
+ handler?: HandlerContainer;
61
+ cps?: CPS;
62
+ processState?: ProcessState;
63
+ }
64
+ export interface ContextForkOptions {
65
+ type: ContextType;
66
+ state: ContextState;
67
+ target?: string;
68
+ injected?: boolean;
69
+ }
70
+ export default class OperationContext {
71
+ target: string;
72
+ stackItem: ASTBase;
73
+ debugger: Debugger;
74
+ handler: HandlerContainer;
75
+ previous: OperationContext;
76
+ readonly type: ContextType;
77
+ readonly state: ContextState;
78
+ readonly scope: Scope;
79
+ readonly cps: CPS;
80
+ readonly processState: ProcessState;
81
+ loopState: LoopState;
82
+ functionState: FunctionState;
83
+ isProtected: boolean;
84
+ injected: boolean;
85
+ readonly api: OperationContext;
86
+ readonly locals: OperationContext;
87
+ readonly globals: OperationContext;
88
+ private static readonly lookupApiType;
89
+ private static readonly lookupGlobalsType;
90
+ private static readonly lookupLocalsType;
91
+ constructor(options?: ContextOptions);
92
+ step(op: Operation): Promise<void>;
93
+ setLastActive(ctx: OperationContext): OperationContext;
94
+ getLastActive(): OperationContext;
95
+ isExit(): boolean;
96
+ isPending(): boolean;
97
+ setPending(pending: boolean): OperationContext;
98
+ lookupAllOfType(validate: (type: ContextType) => boolean): OperationContext[];
99
+ exit(): Promise<OperationContext>;
100
+ lookupType(allowedTypes: Array<ContextType>): OperationContext;
101
+ lookupAllScopes(): OperationContext[];
102
+ lookupApi(): OperationContext;
103
+ lookupGlobals(): OperationContext;
104
+ lookupLocals(): OperationContext;
105
+ extend(map: Map<CustomValue, CustomValue>): OperationContext;
106
+ set(path: Path<CustomValue> | CustomValue, value: CustomValue): void;
107
+ get(path: Path<CustomValue> | CustomValue): CustomValue;
108
+ fork(options: ContextForkOptions): OperationContext;
109
+ }