greybel-interpreter 1.5.7 → 1.5.9

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 (101) 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 +112 -112
  6. package/dist/context.js +308 -308
  7. package/dist/cps.d.ts +14 -14
  8. package/dist/cps.js +161 -161
  9. package/dist/handler/error.d.ts +6 -6
  10. package/dist/handler/error.js +12 -12
  11. package/dist/handler/output.d.ts +18 -18
  12. package/dist/handler/output.js +29 -29
  13. package/dist/handler/resource.d.ts +12 -12
  14. package/dist/handler/resource.js +28 -28
  15. package/dist/handler-container.d.ts +14 -14
  16. package/dist/handler-container.js +14 -14
  17. package/dist/index.d.ts +46 -46
  18. package/dist/index.js +132 -132
  19. package/dist/interpreter.d.ts +42 -42
  20. package/dist/interpreter.js +218 -218
  21. package/dist/operations/assign.d.ts +13 -13
  22. package/dist/operations/assign.js +46 -46
  23. package/dist/operations/block.d.ts +12 -12
  24. package/dist/operations/block.js +47 -47
  25. package/dist/operations/break.d.ts +10 -10
  26. package/dist/operations/break.js +23 -23
  27. package/dist/operations/call.d.ts +13 -13
  28. package/dist/operations/call.js +55 -55
  29. package/dist/operations/chunk.d.ts +12 -12
  30. package/dist/operations/chunk.js +35 -35
  31. package/dist/operations/continue.d.ts +10 -10
  32. package/dist/operations/continue.js +23 -23
  33. package/dist/operations/debugger-statement.d.ts +10 -10
  34. package/dist/operations/debugger-statement.js +21 -21
  35. package/dist/operations/evaluate.d.ts +40 -40
  36. package/dist/operations/evaluate.js +339 -339
  37. package/dist/operations/for.d.ts +14 -14
  38. package/dist/operations/for.js +81 -81
  39. package/dist/operations/function-reference.d.ts +12 -12
  40. package/dist/operations/function-reference.js +44 -44
  41. package/dist/operations/function.d.ts +15 -15
  42. package/dist/operations/function.js +81 -81
  43. package/dist/operations/if-statement.d.ts +19 -19
  44. package/dist/operations/if-statement.js +85 -85
  45. package/dist/operations/import.d.ts +17 -17
  46. package/dist/operations/import.js +57 -57
  47. package/dist/operations/include.d.ts +13 -13
  48. package/dist/operations/include.js +41 -41
  49. package/dist/operations/list.d.ts +11 -11
  50. package/dist/operations/list.js +42 -42
  51. package/dist/operations/literal.d.ts +11 -11
  52. package/dist/operations/literal.js +40 -40
  53. package/dist/operations/map.d.ts +11 -11
  54. package/dist/operations/map.js +44 -44
  55. package/dist/operations/negated-binary.d.ts +11 -11
  56. package/dist/operations/negated-binary.js +42 -42
  57. package/dist/operations/new-instance.d.ts +11 -11
  58. package/dist/operations/new-instance.js +39 -39
  59. package/dist/operations/noop.d.ts +9 -9
  60. package/dist/operations/noop.js +19 -19
  61. package/dist/operations/not.d.ts +11 -11
  62. package/dist/operations/not.js +35 -35
  63. package/dist/operations/operation.d.ts +13 -13
  64. package/dist/operations/operation.js +9 -9
  65. package/dist/operations/reference.d.ts +9 -9
  66. package/dist/operations/reference.js +19 -19
  67. package/dist/operations/resolve.d.ts +52 -52
  68. package/dist/operations/resolve.js +241 -241
  69. package/dist/operations/return.d.ts +11 -11
  70. package/dist/operations/return.js +45 -45
  71. package/dist/operations/while.d.ts +13 -13
  72. package/dist/operations/while.js +65 -65
  73. package/dist/types/base.d.ts +10 -10
  74. package/dist/types/base.js +5 -5
  75. package/dist/types/boolean.d.ts +14 -14
  76. package/dist/types/boolean.js +37 -37
  77. package/dist/types/default.d.ts +8 -8
  78. package/dist/types/default.js +14 -14
  79. package/dist/types/function.d.ts +34 -34
  80. package/dist/types/function.js +109 -109
  81. package/dist/types/interface.d.ts +25 -25
  82. package/dist/types/interface.js +86 -86
  83. package/dist/types/list.d.ts +30 -30
  84. package/dist/types/list.js +161 -161
  85. package/dist/types/map.d.ts +36 -36
  86. package/dist/types/map.js +195 -195
  87. package/dist/types/nil.d.ts +12 -12
  88. package/dist/types/nil.js +36 -36
  89. package/dist/types/number.d.ts +26 -26
  90. package/dist/types/number.js +72 -72
  91. package/dist/types/string.d.ts +32 -32
  92. package/dist/types/string.js +124 -124
  93. package/dist/types/with-intrinsics.d.ts +15 -15
  94. package/dist/types/with-intrinsics.js +19 -19
  95. package/dist/utils/deep-equal.d.ts +1 -1
  96. package/dist/utils/deep-equal.js +37 -37
  97. package/dist/utils/object-value.d.ts +7 -7
  98. package/dist/utils/object-value.js +42 -42
  99. package/dist/utils/path.d.ts +10 -10
  100. package/dist/utils/path.js +32 -32
  101. 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,112 +1,112 @@
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/base';
6
- import CustomMap from './types/map';
7
- import CustomNil from './types/nil';
8
- import ObjectValue from './utils/object-value';
9
- import Path from './utils/path';
10
- export declare enum ContextType {
11
- Api = 0,
12
- Global = 1,
13
- Function = 2,
14
- External = 3,
15
- Loop = 4,
16
- Map = 5,
17
- Call = 6
18
- }
19
- export declare enum ContextState {
20
- Temporary = 0,
21
- Default = 1
22
- }
23
- export declare class Scope extends CustomMap {
24
- private readonly context;
25
- constructor(context: OperationContext);
26
- get(path: Path<CustomValue> | CustomValue): CustomValue;
27
- }
28
- export declare class Debugger {
29
- private breakpoint;
30
- private nextStep;
31
- private lastContext;
32
- getLastContext(): OperationContext;
33
- debug(...segments: any[]): CustomNil;
34
- setBreakpoint(breakpoint: boolean): Debugger;
35
- getBreakpoint(_ctx: OperationContext): boolean;
36
- next(): Debugger;
37
- resume(): Promise<void>;
38
- interact(ctx: OperationContext, _ast: ASTBase, _op: Operation): void;
39
- }
40
- export declare class ProcessState {
41
- isExit: boolean;
42
- isPending: boolean;
43
- last: OperationContext;
44
- }
45
- export declare class LoopState {
46
- isBreak: boolean;
47
- isContinue: boolean;
48
- }
49
- export declare class FunctionState {
50
- value: CustomValue;
51
- isReturn: boolean;
52
- context: CustomValue;
53
- super: CustomValue;
54
- }
55
- export interface ContextOptions {
56
- target?: string;
57
- previous?: OperationContext;
58
- type?: ContextType;
59
- state?: ContextState;
60
- isProtected?: boolean;
61
- injected?: boolean;
62
- debugger?: Debugger;
63
- handler?: HandlerContainer;
64
- cps?: CPS;
65
- processState?: ProcessState;
66
- }
67
- export interface ContextForkOptions {
68
- type: ContextType;
69
- state: ContextState;
70
- target?: string;
71
- injected?: boolean;
72
- }
73
- export default class OperationContext {
74
- target: string;
75
- stackItem: ASTBase;
76
- debugger: Debugger;
77
- handler: HandlerContainer;
78
- previous: OperationContext;
79
- readonly type: ContextType;
80
- readonly state: ContextState;
81
- readonly scope: Scope;
82
- readonly cps: CPS;
83
- readonly processState: ProcessState;
84
- loopState: LoopState;
85
- functionState: FunctionState;
86
- isProtected: boolean;
87
- injected: boolean;
88
- readonly api: OperationContext;
89
- readonly locals: OperationContext;
90
- readonly globals: OperationContext;
91
- private static readonly lookupApiType;
92
- private static readonly lookupGlobalsType;
93
- private static readonly lookupLocalsType;
94
- constructor(options?: ContextOptions);
95
- step(op: Operation): Promise<void>;
96
- setLastActive(ctx: OperationContext): OperationContext;
97
- getLastActive(): OperationContext;
98
- isExit(): boolean;
99
- isPending(): boolean;
100
- setPending(pending: boolean): OperationContext;
101
- lookupAllOfType(validate: (type: ContextType) => boolean): OperationContext[];
102
- exit(): Promise<OperationContext>;
103
- lookupType(allowedTypes: Array<ContextType>): OperationContext;
104
- lookupAllScopes(): OperationContext[];
105
- lookupApi(): OperationContext;
106
- lookupGlobals(): OperationContext;
107
- lookupLocals(): OperationContext;
108
- extend(map: ObjectValue): OperationContext;
109
- set(path: Path<CustomValue> | CustomValue, value: CustomValue): void;
110
- get(path: Path<CustomValue> | CustomValue): CustomValue;
111
- fork(options: ContextForkOptions): OperationContext;
112
- }
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/base';
6
+ import CustomMap from './types/map';
7
+ import CustomNil from './types/nil';
8
+ import ObjectValue from './utils/object-value';
9
+ import Path from './utils/path';
10
+ export declare enum ContextType {
11
+ Api = 0,
12
+ Global = 1,
13
+ Function = 2,
14
+ External = 3,
15
+ Loop = 4,
16
+ Map = 5,
17
+ Call = 6
18
+ }
19
+ export declare enum ContextState {
20
+ Temporary = 0,
21
+ Default = 1
22
+ }
23
+ export declare class Scope extends CustomMap {
24
+ private readonly context;
25
+ constructor(context: OperationContext);
26
+ get(path: Path<CustomValue> | CustomValue): CustomValue;
27
+ }
28
+ export declare class Debugger {
29
+ private breakpoint;
30
+ private nextStep;
31
+ private lastContext;
32
+ getLastContext(): OperationContext;
33
+ debug(...segments: any[]): CustomNil;
34
+ setBreakpoint(breakpoint: boolean): Debugger;
35
+ getBreakpoint(_ctx: OperationContext): boolean;
36
+ next(): Debugger;
37
+ resume(): Promise<void>;
38
+ interact(ctx: OperationContext, _ast: ASTBase, _op: Operation): void;
39
+ }
40
+ export declare class ProcessState {
41
+ isExit: boolean;
42
+ isPending: boolean;
43
+ last: OperationContext;
44
+ }
45
+ export declare class LoopState {
46
+ isBreak: boolean;
47
+ isContinue: boolean;
48
+ }
49
+ export declare class FunctionState {
50
+ value: CustomValue;
51
+ isReturn: boolean;
52
+ context: CustomValue;
53
+ super: CustomValue;
54
+ }
55
+ export interface ContextOptions {
56
+ target?: string;
57
+ previous?: OperationContext;
58
+ type?: ContextType;
59
+ state?: ContextState;
60
+ isProtected?: boolean;
61
+ injected?: boolean;
62
+ debugger?: Debugger;
63
+ handler?: HandlerContainer;
64
+ cps?: CPS;
65
+ processState?: ProcessState;
66
+ }
67
+ export interface ContextForkOptions {
68
+ type: ContextType;
69
+ state: ContextState;
70
+ target?: string;
71
+ injected?: boolean;
72
+ }
73
+ export default class OperationContext {
74
+ target: string;
75
+ stackItem: ASTBase;
76
+ debugger: Debugger;
77
+ handler: HandlerContainer;
78
+ previous: OperationContext;
79
+ readonly type: ContextType;
80
+ readonly state: ContextState;
81
+ readonly scope: Scope;
82
+ readonly cps: CPS;
83
+ readonly processState: ProcessState;
84
+ loopState: LoopState;
85
+ functionState: FunctionState;
86
+ isProtected: boolean;
87
+ injected: boolean;
88
+ readonly api: OperationContext;
89
+ readonly locals: OperationContext;
90
+ readonly globals: OperationContext;
91
+ private static readonly lookupApiType;
92
+ private static readonly lookupGlobalsType;
93
+ private static readonly lookupLocalsType;
94
+ constructor(options?: ContextOptions);
95
+ step(op: Operation): Promise<void>;
96
+ setLastActive(ctx: OperationContext): OperationContext;
97
+ getLastActive(): OperationContext;
98
+ isExit(): boolean;
99
+ isPending(): boolean;
100
+ setPending(pending: boolean): OperationContext;
101
+ lookupAllOfType(validate: (type: ContextType) => boolean): OperationContext[];
102
+ exit(): Promise<OperationContext>;
103
+ lookupType(allowedTypes: Array<ContextType>): OperationContext;
104
+ lookupAllScopes(): OperationContext[];
105
+ lookupApi(): OperationContext;
106
+ lookupGlobals(): OperationContext;
107
+ lookupLocals(): OperationContext;
108
+ extend(map: ObjectValue): OperationContext;
109
+ set(path: Path<CustomValue> | CustomValue, value: CustomValue): void;
110
+ get(path: Path<CustomValue> | CustomValue): CustomValue;
111
+ fork(options: ContextForkOptions): OperationContext;
112
+ }