greybel-interpreter 1.3.7 → 1.3.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 (99) 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 +383 -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 +18 -18
  12. package/dist/handler/output.js +52 -52
  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 +45 -45
  18. package/dist/index.js +131 -131
  19. package/dist/interpreter.d.ts +41 -41
  20. package/dist/interpreter.js +312 -312
  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 +41 -39
  38. package/dist/operations/evaluate.js +433 -367
  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 +37 -37
  88. package/dist/types/map.js +366 -366
  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/deep-equal.d.ts +1 -1
  96. package/dist/utils/deep-equal.js +62 -62
  97. package/dist/utils/path.d.ts +10 -10
  98. package/dist/utils/path.js +59 -59
  99. package/package.json +58 -58
@@ -1,40 +1,40 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.CustomObject = exports.CustomValueWithIntrinsics = exports.CustomValue = void 0;
19
- var CustomValue = /** @class */ (function () {
20
- function CustomValue() {
21
- }
22
- return CustomValue;
23
- }());
24
- exports.CustomValue = CustomValue;
25
- var CustomValueWithIntrinsics = /** @class */ (function (_super) {
26
- __extends(CustomValueWithIntrinsics, _super);
27
- function CustomValueWithIntrinsics() {
28
- return _super !== null && _super.apply(this, arguments) || this;
29
- }
30
- return CustomValueWithIntrinsics;
31
- }(CustomValue));
32
- exports.CustomValueWithIntrinsics = CustomValueWithIntrinsics;
33
- var CustomObject = /** @class */ (function (_super) {
34
- __extends(CustomObject, _super);
35
- function CustomObject() {
36
- return _super !== null && _super.apply(this, arguments) || this;
37
- }
38
- return CustomObject;
39
- }(CustomValueWithIntrinsics));
40
- exports.CustomObject = CustomObject;
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.CustomObject = exports.CustomValueWithIntrinsics = exports.CustomValue = void 0;
19
+ var CustomValue = /** @class */ (function () {
20
+ function CustomValue() {
21
+ }
22
+ return CustomValue;
23
+ }());
24
+ exports.CustomValue = CustomValue;
25
+ var CustomValueWithIntrinsics = /** @class */ (function (_super) {
26
+ __extends(CustomValueWithIntrinsics, _super);
27
+ function CustomValueWithIntrinsics() {
28
+ return _super !== null && _super.apply(this, arguments) || this;
29
+ }
30
+ return CustomValueWithIntrinsics;
31
+ }(CustomValue));
32
+ exports.CustomValueWithIntrinsics = CustomValueWithIntrinsics;
33
+ var CustomObject = /** @class */ (function (_super) {
34
+ __extends(CustomObject, _super);
35
+ function CustomObject() {
36
+ return _super !== null && _super.apply(this, arguments) || this;
37
+ }
38
+ return CustomObject;
39
+ }(CustomValueWithIntrinsics));
40
+ exports.CustomObject = CustomObject;
@@ -1,23 +1,23 @@
1
- import Path from '../utils/path';
2
- import CustomFunction from './function';
3
- import { CustomObject, CustomValue } from './generics';
4
- export declare class CustomInterfaceIterator implements Iterator<CustomValue> {
5
- next(): IteratorResult<CustomValue>;
6
- }
7
- export default class CustomInterface extends CustomObject {
8
- private readonly interfaceFns;
9
- private readonly type;
10
- readonly value: Object;
11
- constructor(type: string);
12
- getCustomType(): string;
13
- toString(): string;
14
- fork(): CustomInterface;
15
- toNumber(): number;
16
- toInt(): number;
17
- toTruthy(): boolean;
18
- [Symbol.iterator](): CustomInterfaceIterator;
19
- has(path: Path<CustomValue> | CustomValue): boolean;
20
- set(_path: Path<CustomValue> | CustomValue, _newValue: CustomValue): void;
21
- get(path: Path<CustomValue> | CustomValue): CustomValue;
22
- addFunction(name: string, fn: CustomFunction): CustomInterface;
23
- }
1
+ import Path from '../utils/path';
2
+ import CustomFunction from './function';
3
+ import { CustomObject, CustomValue } from './generics';
4
+ export declare class CustomInterfaceIterator implements Iterator<CustomValue> {
5
+ next(): IteratorResult<CustomValue>;
6
+ }
7
+ export default class CustomInterface extends CustomObject {
8
+ private readonly interfaceFns;
9
+ private readonly type;
10
+ readonly value: Object;
11
+ constructor(type: string);
12
+ getCustomType(): string;
13
+ toString(): string;
14
+ fork(): CustomInterface;
15
+ toNumber(): number;
16
+ toInt(): number;
17
+ toTruthy(): boolean;
18
+ [Symbol.iterator](): CustomInterfaceIterator;
19
+ has(path: Path<CustomValue> | CustomValue): boolean;
20
+ set(_path: Path<CustomValue> | CustomValue, _newValue: CustomValue): void;
21
+ get(path: Path<CustomValue> | CustomValue): CustomValue;
22
+ addFunction(name: string, fn: CustomFunction): CustomInterface;
23
+ }
@@ -1,103 +1,103 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.CustomInterfaceIterator = void 0;
22
- var path_1 = __importDefault(require("../utils/path"));
23
- var default_1 = __importDefault(require("./default"));
24
- var generics_1 = require("./generics");
25
- var CustomInterfaceIterator = /** @class */ (function () {
26
- function CustomInterfaceIterator() {
27
- }
28
- CustomInterfaceIterator.prototype.next = function () {
29
- return {
30
- value: default_1.default.Void,
31
- done: true
32
- };
33
- };
34
- return CustomInterfaceIterator;
35
- }());
36
- exports.CustomInterfaceIterator = CustomInterfaceIterator;
37
- var CustomInterface = /** @class */ (function (_super) {
38
- __extends(CustomInterface, _super);
39
- function CustomInterface(type) {
40
- var _this = _super.call(this) || this;
41
- _this.value = {};
42
- _this.type = type;
43
- _this.interfaceFns = new Map();
44
- return _this;
45
- }
46
- CustomInterface.prototype.getCustomType = function () {
47
- return this.type;
48
- };
49
- CustomInterface.prototype.toString = function () {
50
- return this.type;
51
- };
52
- CustomInterface.prototype.fork = function () {
53
- return this;
54
- };
55
- CustomInterface.prototype.toNumber = function () {
56
- return Number.NaN;
57
- };
58
- CustomInterface.prototype.toInt = function () {
59
- return 0;
60
- };
61
- CustomInterface.prototype.toTruthy = function () {
62
- return true;
63
- };
64
- CustomInterface.prototype[Symbol.iterator] = function () {
65
- return new CustomInterfaceIterator();
66
- };
67
- CustomInterface.prototype.has = function (path) {
68
- if (path instanceof generics_1.CustomValue) {
69
- return this.has(new path_1.default([path]));
70
- }
71
- var traversalPath = path.clone();
72
- var current = traversalPath.next();
73
- if (current !== null) {
74
- return this.interfaceFns.has(current.toString());
75
- }
76
- return false;
77
- };
78
- CustomInterface.prototype.set = function (_path, _newValue) {
79
- throw new Error('Cannot set property on an interface.');
80
- };
81
- CustomInterface.prototype.get = function (path) {
82
- if (path instanceof generics_1.CustomValue) {
83
- return this.get(new path_1.default([path]));
84
- }
85
- if (path.count() === 0) {
86
- return this;
87
- }
88
- var traversalPath = path.clone();
89
- var current = traversalPath.next();
90
- if (current !== null) {
91
- if (this.interfaceFns.has(current.toString())) {
92
- return this.interfaceFns.get(current.toString());
93
- }
94
- }
95
- throw new Error("Unknown path in interface ".concat(path.toString(), "."));
96
- };
97
- CustomInterface.prototype.addFunction = function (name, fn) {
98
- this.interfaceFns.set(name, fn);
99
- return this;
100
- };
101
- return CustomInterface;
102
- }(generics_1.CustomObject));
103
- exports.default = CustomInterface;
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.CustomInterfaceIterator = void 0;
22
+ var path_1 = __importDefault(require("../utils/path"));
23
+ var default_1 = __importDefault(require("./default"));
24
+ var generics_1 = require("./generics");
25
+ var CustomInterfaceIterator = /** @class */ (function () {
26
+ function CustomInterfaceIterator() {
27
+ }
28
+ CustomInterfaceIterator.prototype.next = function () {
29
+ return {
30
+ value: default_1.default.Void,
31
+ done: true
32
+ };
33
+ };
34
+ return CustomInterfaceIterator;
35
+ }());
36
+ exports.CustomInterfaceIterator = CustomInterfaceIterator;
37
+ var CustomInterface = /** @class */ (function (_super) {
38
+ __extends(CustomInterface, _super);
39
+ function CustomInterface(type) {
40
+ var _this = _super.call(this) || this;
41
+ _this.value = {};
42
+ _this.type = type;
43
+ _this.interfaceFns = new Map();
44
+ return _this;
45
+ }
46
+ CustomInterface.prototype.getCustomType = function () {
47
+ return this.type;
48
+ };
49
+ CustomInterface.prototype.toString = function () {
50
+ return this.type;
51
+ };
52
+ CustomInterface.prototype.fork = function () {
53
+ return this;
54
+ };
55
+ CustomInterface.prototype.toNumber = function () {
56
+ return Number.NaN;
57
+ };
58
+ CustomInterface.prototype.toInt = function () {
59
+ return 0;
60
+ };
61
+ CustomInterface.prototype.toTruthy = function () {
62
+ return true;
63
+ };
64
+ CustomInterface.prototype[Symbol.iterator] = function () {
65
+ return new CustomInterfaceIterator();
66
+ };
67
+ CustomInterface.prototype.has = function (path) {
68
+ if (path instanceof generics_1.CustomValue) {
69
+ return this.has(new path_1.default([path]));
70
+ }
71
+ var traversalPath = path.clone();
72
+ var current = traversalPath.next();
73
+ if (current !== null) {
74
+ return this.interfaceFns.has(current.toString());
75
+ }
76
+ return false;
77
+ };
78
+ CustomInterface.prototype.set = function (_path, _newValue) {
79
+ throw new Error('Cannot set property on an interface.');
80
+ };
81
+ CustomInterface.prototype.get = function (path) {
82
+ if (path instanceof generics_1.CustomValue) {
83
+ return this.get(new path_1.default([path]));
84
+ }
85
+ if (path.count() === 0) {
86
+ return this;
87
+ }
88
+ var traversalPath = path.clone();
89
+ var current = traversalPath.next();
90
+ if (current !== null) {
91
+ if (this.interfaceFns.has(current.toString())) {
92
+ return this.interfaceFns.get(current.toString());
93
+ }
94
+ }
95
+ throw new Error("Unknown path in interface ".concat(path.toString(), "."));
96
+ };
97
+ CustomInterface.prototype.addFunction = function (name, fn) {
98
+ this.interfaceFns.set(name, fn);
99
+ return this;
100
+ };
101
+ return CustomInterface;
102
+ }(generics_1.CustomObject));
103
+ exports.default = CustomInterface;
@@ -1,31 +1,31 @@
1
- import IntrinsicsContainer from '../intrinsics-container';
2
- import Path from '../utils/path';
3
- import CustomFunction from './function';
4
- import { CustomObject, CustomValue } from './generics';
5
- export declare class CustomListIterator implements Iterator<CustomValue> {
6
- value: Array<CustomValue>;
7
- index: number;
8
- constructor(value: Array<CustomValue>);
9
- next(): IteratorResult<CustomValue>;
10
- }
11
- export default class CustomList extends CustomObject {
12
- static getItemIndex(item: CustomList, index: number): number;
13
- private static intrinsics;
14
- static getIntrinsics(): IntrinsicsContainer;
15
- static addIntrinsic(name: string, fn: CustomFunction): void;
16
- readonly value: Array<CustomValue>;
17
- constructor(value?: Array<CustomValue>);
18
- getCustomType(): string;
19
- toString(): string;
20
- fork(): CustomList;
21
- toNumber(): number;
22
- toInt(): number;
23
- toTruthy(): boolean;
24
- slice(a: CustomValue, b: CustomValue): CustomList;
25
- extend(list: CustomList | Array<CustomValue>): CustomList;
26
- [Symbol.iterator](): CustomListIterator;
27
- getItemIndex(index: number): number;
28
- has(path: Path<CustomValue> | CustomValue): boolean;
29
- set(path: Path<CustomValue> | CustomValue, newValue: CustomValue): void;
30
- get(path: Path<CustomValue> | CustomValue): CustomValue;
31
- }
1
+ import IntrinsicsContainer from '../intrinsics-container';
2
+ import Path from '../utils/path';
3
+ import CustomFunction from './function';
4
+ import { CustomObject, CustomValue } from './generics';
5
+ export declare class CustomListIterator implements Iterator<CustomValue> {
6
+ value: Array<CustomValue>;
7
+ index: number;
8
+ constructor(value: Array<CustomValue>);
9
+ next(): IteratorResult<CustomValue>;
10
+ }
11
+ export default class CustomList extends CustomObject {
12
+ static getItemIndex(item: CustomList, index: number): number;
13
+ private static intrinsics;
14
+ static getIntrinsics(): IntrinsicsContainer;
15
+ static addIntrinsic(name: string, fn: CustomFunction): void;
16
+ readonly value: Array<CustomValue>;
17
+ constructor(value?: Array<CustomValue>);
18
+ getCustomType(): string;
19
+ toString(): string;
20
+ fork(): CustomList;
21
+ toNumber(): number;
22
+ toInt(): number;
23
+ toTruthy(): boolean;
24
+ slice(a: CustomValue, b: CustomValue): CustomList;
25
+ extend(list: CustomList | Array<CustomValue>): CustomList;
26
+ [Symbol.iterator](): CustomListIterator;
27
+ getItemIndex(index: number): number;
28
+ has(path: Path<CustomValue> | CustomValue): boolean;
29
+ set(path: Path<CustomValue> | CustomValue, newValue: CustomValue): void;
30
+ get(path: Path<CustomValue> | CustomValue): CustomValue;
31
+ }