greybel-interpreter 0.7.2 → 1.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.
- package/.editorconfig +15 -0
- package/.eslintrc +48 -0
- package/LICENSE +21 -21
- package/README.md +2 -2
- package/dist/context.d.ts +109 -98
- package/dist/context.js +378 -456
- package/dist/cps.d.ts +15 -17
- package/dist/cps.js +220 -872
- package/dist/handler/error.d.ts +6 -0
- package/dist/{operations/debugger.js → handler/error.js} +35 -32
- package/dist/handler/output.d.ts +6 -0
- package/dist/{operations/if.js → handler/output.js} +35 -31
- package/dist/handler/resource.d.ts +12 -0
- package/dist/handler/resource.js +51 -0
- package/dist/handler-container.d.ts +14 -0
- package/dist/handler-container.js +16 -0
- package/dist/index.d.ts +44 -36
- package/dist/index.js +129 -93
- package/dist/interpreter.d.ts +39 -29
- package/dist/interpreter.js +292 -210
- package/dist/intrinsics-container.d.ts +7 -0
- package/dist/intrinsics-container.js +19 -0
- package/dist/operations/assign.d.ts +13 -0
- package/dist/operations/assign.js +111 -0
- package/dist/operations/block.d.ts +12 -0
- package/dist/operations/{body.js → block.js} +108 -140
- package/dist/operations/break.d.ts +10 -7
- package/dist/operations/break.js +41 -34
- package/dist/operations/call.d.ts +13 -0
- package/dist/operations/call.js +124 -0
- package/dist/operations/chunk.d.ts +12 -0
- package/dist/operations/chunk.js +85 -0
- package/dist/operations/continue.d.ts +10 -7
- package/dist/operations/continue.js +41 -34
- package/dist/operations/debugger-statement.d.ts +10 -0
- package/dist/operations/{else-if.js → debugger-statement.js} +39 -31
- package/dist/operations/evaluate.d.ts +39 -0
- package/dist/operations/evaluate.js +366 -0
- package/dist/operations/for.d.ts +15 -16
- package/dist/operations/for.js +146 -143
- package/dist/operations/function-reference.d.ts +12 -0
- package/dist/operations/function-reference.js +103 -0
- package/dist/operations/function.d.ts +12 -26
- package/dist/operations/function.js +198 -145
- package/dist/operations/if-statement.d.ts +19 -8
- package/dist/operations/if-statement.js +181 -169
- package/dist/operations/import.d.ts +14 -0
- package/dist/{expressions/include.js → operations/import.js} +115 -132
- package/dist/operations/include.d.ts +13 -0
- package/dist/operations/include.js +95 -0
- package/dist/operations/list.d.ts +11 -0
- package/dist/{expressions → operations}/list.js +111 -142
- package/dist/operations/literal.d.ts +11 -0
- package/dist/operations/literal.js +58 -0
- package/dist/operations/map.d.ts +11 -0
- package/dist/operations/{argument.js → map.js} +167 -145
- package/dist/operations/negated-binary.d.ts +11 -0
- package/dist/{expressions/binary-negated-expression.js → operations/negated-binary.js} +109 -127
- package/dist/operations/new-instance.d.ts +11 -0
- package/dist/operations/{new.js → new-instance.js} +100 -97
- package/dist/operations/noop.d.ts +9 -0
- package/dist/operations/{else.js → noop.js} +36 -30
- package/dist/operations/not.d.ts +11 -11
- package/dist/operations/not.js +96 -96
- package/dist/operations/operation.d.ts +13 -0
- package/dist/operations/operation.js +11 -0
- package/dist/operations/reference.d.ts +9 -11
- package/dist/operations/reference.js +37 -103
- package/dist/operations/resolve.d.ts +38 -0
- package/dist/operations/resolve.js +330 -0
- package/dist/operations/return.d.ts +11 -11
- package/dist/operations/return.js +107 -106
- package/dist/operations/while.d.ts +13 -14
- package/dist/operations/while.js +129 -145
- package/dist/types/boolean.d.ts +11 -0
- package/dist/{custom-types → types}/boolean.js +46 -47
- package/dist/types/default.d.ts +11 -0
- package/dist/types/default.js +20 -0
- package/dist/types/function.d.ts +32 -0
- package/dist/types/function.js +174 -0
- package/dist/types/generics.d.ts +17 -0
- package/dist/types/{operation.js → generics.js} +40 -38
- package/dist/types/interface.d.ts +22 -0
- package/dist/types/interface.js +102 -0
- package/dist/types/list.d.ts +31 -0
- package/dist/types/list.js +227 -0
- package/dist/types/map.d.ts +30 -0
- package/dist/types/map.js +224 -0
- package/dist/types/nil.d.ts +9 -0
- package/dist/{custom-types → types}/nil.js +44 -44
- package/dist/types/number.d.ts +11 -0
- package/dist/{custom-types → types}/number.js +46 -47
- package/dist/types/string.d.ts +33 -0
- package/dist/types/string.js +149 -0
- package/dist/utils/path.d.ts +10 -0
- package/dist/utils/path.js +59 -0
- package/package.json +58 -44
- package/dist/custom-types/boolean.d.ts +0 -12
- package/dist/custom-types/list.d.ts +0 -26
- package/dist/custom-types/list.js +0 -236
- package/dist/custom-types/map.d.ts +0 -26
- package/dist/custom-types/map.js +0 -245
- package/dist/custom-types/nil.d.ts +0 -10
- package/dist/custom-types/number.d.ts +0 -12
- package/dist/custom-types/string.d.ts +0 -25
- package/dist/custom-types/string.js +0 -172
- package/dist/expressions/assign.d.ts +0 -13
- package/dist/expressions/assign.js +0 -174
- package/dist/expressions/binary-negated-expression.d.ts +0 -18
- package/dist/expressions/call.d.ts +0 -14
- package/dist/expressions/call.js +0 -209
- package/dist/expressions/import.d.ts +0 -14
- package/dist/expressions/import.js +0 -155
- package/dist/expressions/include.d.ts +0 -13
- package/dist/expressions/list.d.ts +0 -14
- package/dist/expressions/logical-and-binary.d.ts +0 -22
- package/dist/expressions/logical-and-binary.js +0 -222
- package/dist/expressions/map.d.ts +0 -19
- package/dist/expressions/map.js +0 -197
- package/dist/expressions/path.d.ts +0 -31
- package/dist/expressions/path.js +0 -384
- package/dist/operations/argument.d.ts +0 -8
- package/dist/operations/body.d.ts +0 -8
- package/dist/operations/debugger.d.ts +0 -7
- package/dist/operations/else-if.d.ts +0 -12
- package/dist/operations/else.d.ts +0 -10
- package/dist/operations/if.d.ts +0 -12
- package/dist/operations/new.d.ts +0 -11
- package/dist/resource.d.ts +0 -9
- package/dist/resource.js +0 -29
- package/dist/typer.d.ts +0 -6
- package/dist/typer.js +0 -95
- package/dist/types/custom-type.d.ts +0 -22
- package/dist/types/custom-type.js +0 -67
- package/dist/types/expression.d.ts +0 -7
- package/dist/types/expression.js +0 -9
- package/dist/types/operation.d.ts +0 -10
|
@@ -1,47 +1,46 @@
|
|
|
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
|
-
var
|
|
19
|
-
var CustomNumber = /** @class */ (function (_super) {
|
|
20
|
-
__extends(CustomNumber, _super);
|
|
21
|
-
function CustomNumber(value) {
|
|
22
|
-
var _this = _super.call(this) || this;
|
|
23
|
-
_this.value = value;
|
|
24
|
-
return _this;
|
|
25
|
-
}
|
|
26
|
-
CustomNumber.prototype.
|
|
27
|
-
return 'number';
|
|
28
|
-
};
|
|
29
|
-
CustomNumber.prototype.toString = function () {
|
|
30
|
-
return this.value.toString();
|
|
31
|
-
};
|
|
32
|
-
CustomNumber.prototype.
|
|
33
|
-
return this.value;
|
|
34
|
-
};
|
|
35
|
-
CustomNumber.prototype.
|
|
36
|
-
return
|
|
37
|
-
};
|
|
38
|
-
CustomNumber.prototype.
|
|
39
|
-
return this.value;
|
|
40
|
-
};
|
|
41
|
-
CustomNumber.prototype.
|
|
42
|
-
return
|
|
43
|
-
};
|
|
44
|
-
CustomNumber
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
exports.default = CustomNumber;
|
|
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
|
+
var generics_1 = require("./generics");
|
|
19
|
+
var CustomNumber = /** @class */ (function (_super) {
|
|
20
|
+
__extends(CustomNumber, _super);
|
|
21
|
+
function CustomNumber(value) {
|
|
22
|
+
var _this = _super.call(this) || this;
|
|
23
|
+
_this.value = value;
|
|
24
|
+
return _this;
|
|
25
|
+
}
|
|
26
|
+
CustomNumber.prototype.getCustomType = function () {
|
|
27
|
+
return 'number';
|
|
28
|
+
};
|
|
29
|
+
CustomNumber.prototype.toString = function () {
|
|
30
|
+
return this.value.toString();
|
|
31
|
+
};
|
|
32
|
+
CustomNumber.prototype.fork = function () {
|
|
33
|
+
return new CustomNumber(this.value);
|
|
34
|
+
};
|
|
35
|
+
CustomNumber.prototype.toInt = function () {
|
|
36
|
+
return this.value | 0;
|
|
37
|
+
};
|
|
38
|
+
CustomNumber.prototype.toNumber = function () {
|
|
39
|
+
return this.value;
|
|
40
|
+
};
|
|
41
|
+
CustomNumber.prototype.toTruthy = function () {
|
|
42
|
+
return !!this.value;
|
|
43
|
+
};
|
|
44
|
+
return CustomNumber;
|
|
45
|
+
}(generics_1.CustomValue));
|
|
46
|
+
exports.default = CustomNumber;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import IntrinsicsContainer from '../intrinsics-container';
|
|
2
|
+
import Path from '../utils/path';
|
|
3
|
+
import CustomFunction from './function';
|
|
4
|
+
import { CustomValue, CustomValueWithIntrinsics } from './generics';
|
|
5
|
+
export declare class CustomStringIterator implements Iterator<CustomValue> {
|
|
6
|
+
value: string;
|
|
7
|
+
index: number;
|
|
8
|
+
constructor(value: string);
|
|
9
|
+
next(): IteratorResult<CustomValue>;
|
|
10
|
+
}
|
|
11
|
+
export default class CustomString extends CustomValueWithIntrinsics {
|
|
12
|
+
static getCharIndex(item: CustomString, index: number): number;
|
|
13
|
+
private static intrinsics;
|
|
14
|
+
static getIntrinsics(): IntrinsicsContainer;
|
|
15
|
+
static addIntrinsic(name: string, fn: CustomFunction): void;
|
|
16
|
+
readonly value: string;
|
|
17
|
+
constructor(value: string);
|
|
18
|
+
getCustomType(): string;
|
|
19
|
+
toString(): string;
|
|
20
|
+
fork(): CustomString;
|
|
21
|
+
isNumber(): boolean;
|
|
22
|
+
parseFloat(): number;
|
|
23
|
+
parseInt(): number;
|
|
24
|
+
toNumber(): number;
|
|
25
|
+
toInt(): number;
|
|
26
|
+
toTruthy(): boolean;
|
|
27
|
+
slice(a: CustomValue, b: CustomValue): CustomString;
|
|
28
|
+
[Symbol.iterator](): CustomStringIterator;
|
|
29
|
+
getCharIndex(index: number): number;
|
|
30
|
+
has(path: Path<string> | string): boolean;
|
|
31
|
+
set(_path: Path<string> | string, _newValue: CustomValue): void;
|
|
32
|
+
get(path: Path<string> | string): CustomValue;
|
|
33
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
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.CustomStringIterator = void 0;
|
|
22
|
+
var intrinsics_container_1 = __importDefault(require("../intrinsics-container"));
|
|
23
|
+
var path_1 = __importDefault(require("../utils/path"));
|
|
24
|
+
var default_1 = __importDefault(require("./default"));
|
|
25
|
+
var generics_1 = require("./generics");
|
|
26
|
+
var CustomStringIterator = /** @class */ (function () {
|
|
27
|
+
function CustomStringIterator(value) {
|
|
28
|
+
var me = this;
|
|
29
|
+
me.value = value;
|
|
30
|
+
me.index = 0;
|
|
31
|
+
}
|
|
32
|
+
CustomStringIterator.prototype.next = function () {
|
|
33
|
+
var me = this;
|
|
34
|
+
if (me.index === me.value.length) {
|
|
35
|
+
return {
|
|
36
|
+
value: null,
|
|
37
|
+
done: true
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
value: new CustomString(me.value[me.index++]),
|
|
42
|
+
done: false
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
return CustomStringIterator;
|
|
46
|
+
}());
|
|
47
|
+
exports.CustomStringIterator = CustomStringIterator;
|
|
48
|
+
var CustomString = /** @class */ (function (_super) {
|
|
49
|
+
__extends(CustomString, _super);
|
|
50
|
+
function CustomString(value) {
|
|
51
|
+
var _this = _super.call(this) || this;
|
|
52
|
+
_this.value = value;
|
|
53
|
+
return _this;
|
|
54
|
+
}
|
|
55
|
+
CustomString.getCharIndex = function (item, index) {
|
|
56
|
+
var n = index | 0;
|
|
57
|
+
if (n < 0)
|
|
58
|
+
n += item.value.length;
|
|
59
|
+
if (n < 0 || n >= item.value.length)
|
|
60
|
+
return -1;
|
|
61
|
+
return n;
|
|
62
|
+
};
|
|
63
|
+
CustomString.getIntrinsics = function () {
|
|
64
|
+
return this.intrinsics;
|
|
65
|
+
};
|
|
66
|
+
CustomString.addIntrinsic = function (name, fn) {
|
|
67
|
+
this.intrinsics.add(name, fn);
|
|
68
|
+
};
|
|
69
|
+
CustomString.prototype.getCustomType = function () {
|
|
70
|
+
return 'string';
|
|
71
|
+
};
|
|
72
|
+
CustomString.prototype.toString = function () {
|
|
73
|
+
return this.value;
|
|
74
|
+
};
|
|
75
|
+
CustomString.prototype.fork = function () {
|
|
76
|
+
return new CustomString(this.value);
|
|
77
|
+
};
|
|
78
|
+
CustomString.prototype.isNumber = function () {
|
|
79
|
+
var nr = Number(this.value);
|
|
80
|
+
return !Number.isNaN(nr);
|
|
81
|
+
};
|
|
82
|
+
CustomString.prototype.parseFloat = function () {
|
|
83
|
+
return parseFloat(this.value);
|
|
84
|
+
};
|
|
85
|
+
CustomString.prototype.parseInt = function () {
|
|
86
|
+
return parseInt(this.value);
|
|
87
|
+
};
|
|
88
|
+
CustomString.prototype.toNumber = function () {
|
|
89
|
+
return 0;
|
|
90
|
+
};
|
|
91
|
+
CustomString.prototype.toInt = function () {
|
|
92
|
+
return 0;
|
|
93
|
+
};
|
|
94
|
+
CustomString.prototype.toTruthy = function () {
|
|
95
|
+
return this.value.length > 0;
|
|
96
|
+
};
|
|
97
|
+
CustomString.prototype.slice = function (a, b) {
|
|
98
|
+
return new CustomString(this.value.slice(a.toNumber(), b.toNumber()));
|
|
99
|
+
};
|
|
100
|
+
CustomString.prototype[Symbol.iterator] = function () {
|
|
101
|
+
return new CustomStringIterator(this.value);
|
|
102
|
+
};
|
|
103
|
+
CustomString.prototype.getCharIndex = function (index) {
|
|
104
|
+
return CustomString.getCharIndex(this, index);
|
|
105
|
+
};
|
|
106
|
+
CustomString.prototype.has = function (path) {
|
|
107
|
+
if (typeof path === 'string') {
|
|
108
|
+
return this.has(new path_1.default([path]));
|
|
109
|
+
}
|
|
110
|
+
var traversalPath = path.clone();
|
|
111
|
+
var current = traversalPath.next();
|
|
112
|
+
if (current !== null) {
|
|
113
|
+
var index = parseInt(current);
|
|
114
|
+
if (Number.isNaN(index)) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
return !!this.value[index];
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
};
|
|
121
|
+
CustomString.prototype.set = function (_path, _newValue) {
|
|
122
|
+
throw new Error('Mutable operations are not allowed on a string.');
|
|
123
|
+
};
|
|
124
|
+
CustomString.prototype.get = function (path) {
|
|
125
|
+
if (typeof path === 'string') {
|
|
126
|
+
return this.get(new path_1.default([path]));
|
|
127
|
+
}
|
|
128
|
+
var traversalPath = path.clone();
|
|
129
|
+
var current = traversalPath.next();
|
|
130
|
+
if (current !== null) {
|
|
131
|
+
var currentIndex = parseInt(current);
|
|
132
|
+
var isCurrentNumber = !Number.isNaN(currentIndex);
|
|
133
|
+
if (isCurrentNumber) {
|
|
134
|
+
currentIndex = this.getCharIndex(currentIndex);
|
|
135
|
+
}
|
|
136
|
+
if (isCurrentNumber) {
|
|
137
|
+
return new CustomString(this.value[currentIndex].toString());
|
|
138
|
+
}
|
|
139
|
+
else if (path.count() === 1 &&
|
|
140
|
+
CustomString.getIntrinsics().has(current)) {
|
|
141
|
+
return CustomString.intrinsics.get(current);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return default_1.default.Void;
|
|
145
|
+
};
|
|
146
|
+
CustomString.intrinsics = new intrinsics_container_1.default();
|
|
147
|
+
return CustomString;
|
|
148
|
+
}(generics_1.CustomValueWithIntrinsics));
|
|
149
|
+
exports.default = CustomString;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
+
if (ar || !(i in from)) {
|
|
21
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
+
ar[i] = from[i];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
var Path = /** @class */ (function () {
|
|
29
|
+
function Path(path) {
|
|
30
|
+
if (path === void 0) { path = []; }
|
|
31
|
+
this.path = __spreadArray([], __read(path), false);
|
|
32
|
+
}
|
|
33
|
+
Path.prototype.next = function () {
|
|
34
|
+
if (this.path.length === 0) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return this.path.shift();
|
|
38
|
+
};
|
|
39
|
+
Path.prototype.last = function () {
|
|
40
|
+
if (this.path.length === 0) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return this.path.pop();
|
|
44
|
+
};
|
|
45
|
+
Path.prototype.add = function (value) {
|
|
46
|
+
this.path.push(value);
|
|
47
|
+
};
|
|
48
|
+
Path.prototype.toString = function () {
|
|
49
|
+
return this.path.join('.');
|
|
50
|
+
};
|
|
51
|
+
Path.prototype.count = function () {
|
|
52
|
+
return this.path.length;
|
|
53
|
+
};
|
|
54
|
+
Path.prototype.clone = function () {
|
|
55
|
+
return new Path(this.path);
|
|
56
|
+
};
|
|
57
|
+
return Path;
|
|
58
|
+
}());
|
|
59
|
+
exports.default = Path;
|
package/package.json
CHANGED
|
@@ -1,44 +1,58 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "greybel-interpreter",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Interpreter",
|
|
5
|
-
"main": "dist/index",
|
|
6
|
-
"typings": "dist/index",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"prepublishOnly": "npm run build",
|
|
9
|
-
"build": "npm run clean && tsc -p .",
|
|
10
|
-
"watch": "tsc -w -p .",
|
|
11
|
-
"clean": "rm -rf dist",
|
|
12
|
-
"test": "jest ./tests"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"@types/
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"typescript": "^
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "greybel-interpreter",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "Interpreter",
|
|
5
|
+
"main": "dist/index",
|
|
6
|
+
"typings": "dist/index",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"prepublishOnly": "npm run build",
|
|
9
|
+
"build": "npm run clean && tsc -p .",
|
|
10
|
+
"watch": "tsc -w -p .",
|
|
11
|
+
"clean": "rm -rf dist",
|
|
12
|
+
"test": "jest ./tests",
|
|
13
|
+
"lint": "eslint 'src/**/*.ts'",
|
|
14
|
+
"lint:fix": "eslint --fix 'src/**/*.ts'"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/ayecue/greybel-interpreter.git"
|
|
19
|
+
},
|
|
20
|
+
"author": {
|
|
21
|
+
"name": "ayecue",
|
|
22
|
+
"email": "soerenwehmeier@googlemail.com"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/ayecue/greybel-interpreter/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/ayecue/greybel-interpreter#readme",
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/jest": "^27.0.3",
|
|
31
|
+
"@types/node": "^17.0.0",
|
|
32
|
+
"@types/uuid": "^8.3.3",
|
|
33
|
+
"@typescript-eslint/eslint-plugin": "^5.27.1",
|
|
34
|
+
"@typescript-eslint/parser": "^5.27.1",
|
|
35
|
+
"eslint": "^8.17.0",
|
|
36
|
+
"eslint-config-prettier": "^8.5.0",
|
|
37
|
+
"eslint-config-standard": "^17.0.0",
|
|
38
|
+
"eslint-plugin-import": "^2.26.0",
|
|
39
|
+
"eslint-plugin-jest": "^26.5.3",
|
|
40
|
+
"eslint-plugin-node": "^11.1.0",
|
|
41
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
42
|
+
"eslint-plugin-promise": "^6.0.0",
|
|
43
|
+
"eslint-plugin-security": "^1.5.0",
|
|
44
|
+
"eslint-plugin-simple-import-sort": "^7.0.0",
|
|
45
|
+
"jest": "^27.4.5",
|
|
46
|
+
"nodemon": "^2.0.15",
|
|
47
|
+
"ts-node": "^10.4.0",
|
|
48
|
+
"typescript": "^4.5.4"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"greybel-core": "^0.3.0",
|
|
52
|
+
"greyscript-core": "^0.2.8"
|
|
53
|
+
},
|
|
54
|
+
"keywords": [
|
|
55
|
+
"greyscript",
|
|
56
|
+
"greyhack"
|
|
57
|
+
]
|
|
58
|
+
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { CustomLiteralType } from '../types/custom-type';
|
|
2
|
-
export default class CustomBoolean extends CustomLiteralType {
|
|
3
|
-
static intrinsics: Map<string, Function>;
|
|
4
|
-
value: boolean;
|
|
5
|
-
constructor(value: boolean);
|
|
6
|
-
getType(): string;
|
|
7
|
-
toString(): string;
|
|
8
|
-
fork(): CustomBoolean;
|
|
9
|
-
toNumber(): number;
|
|
10
|
-
toTruthy(): boolean;
|
|
11
|
-
valueOf(): boolean;
|
|
12
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { CustomLiteralType, CustomObjectType, Callable } from '../types/custom-type';
|
|
2
|
-
export declare class CustomListIterator implements Iterator<any> {
|
|
3
|
-
value: any[];
|
|
4
|
-
index: number;
|
|
5
|
-
constructor(value: any);
|
|
6
|
-
next(): IteratorResult<any>;
|
|
7
|
-
}
|
|
8
|
-
export declare function itemAtIndex(list: any[], n: number): number | null;
|
|
9
|
-
export default class CustomList extends CustomObjectType {
|
|
10
|
-
static intrinsics: Map<string, Function>;
|
|
11
|
-
value: any[];
|
|
12
|
-
static isNumber(value: string): boolean;
|
|
13
|
-
constructor(value: any[]);
|
|
14
|
-
[Symbol.iterator](): CustomListIterator;
|
|
15
|
-
concat(list: CustomList): CustomList;
|
|
16
|
-
slice: (a: CustomLiteralType, b: CustomLiteralType) => CustomList;
|
|
17
|
-
set(path: any[], value: any): Promise<void>;
|
|
18
|
-
get(path: any[]): Promise<any>;
|
|
19
|
-
getCallable(path: any[]): Promise<Callable>;
|
|
20
|
-
getType(): string;
|
|
21
|
-
toString(): string;
|
|
22
|
-
toNumber(): number;
|
|
23
|
-
toTruthy(): boolean;
|
|
24
|
-
valueOf(): any[];
|
|
25
|
-
fork(): CustomList;
|
|
26
|
-
}
|