affinirum 1.5.2 → 1.5.4

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 (121) hide show
  1. package/README.md +12 -2
  2. package/dst/Affinirum.d.ts +22 -22
  3. package/dst/Affinirum.js +88 -80
  4. package/dst/CallFrame.d.ts +11 -0
  5. package/dst/CallFrame.js +35 -0
  6. package/dst/LexicalScope.d.ts +15 -0
  7. package/dst/LexicalScope.js +31 -0
  8. package/dst/Node.d.ts +5 -4
  9. package/dst/Node.js +5 -5
  10. package/dst/ParserState.d.ts +3 -3
  11. package/dst/ParserState.js +40 -40
  12. package/dst/ScriptSpan.d.ts +10 -0
  13. package/dst/{ParserFrame.js → ScriptSpan.js} +20 -31
  14. package/dst/Type.d.ts +2 -0
  15. package/dst/Type.js +2 -0
  16. package/dst/Variable.d.ts +0 -4
  17. package/dst/Variable.js +0 -7
  18. package/dst/cjs/Affinirum.d.ts +88 -0
  19. package/dst/cjs/Affinirum.js +88 -80
  20. package/dst/cjs/Atom.d.ts +7 -0
  21. package/dst/cjs/CallFrame.d.ts +11 -0
  22. package/dst/cjs/CallFrame.js +39 -0
  23. package/dst/cjs/Constant.d.ts +13 -0
  24. package/dst/cjs/Constants.d.ts +2 -0
  25. package/dst/cjs/Functions.d.ts +2 -0
  26. package/dst/cjs/Jump.d.ts +1 -0
  27. package/dst/cjs/JumpException.d.ts +9 -0
  28. package/dst/cjs/Keywords.d.ts +1 -0
  29. package/dst/cjs/LexicalScope.d.ts +15 -0
  30. package/dst/cjs/LexicalScope.js +35 -0
  31. package/dst/cjs/Node.d.ts +14 -0
  32. package/dst/cjs/Node.js +5 -5
  33. package/dst/cjs/ParserState.d.ts +60 -0
  34. package/dst/cjs/ParserState.js +40 -40
  35. package/dst/cjs/ScriptSpan.d.ts +10 -0
  36. package/dst/cjs/{ParserFrame.js → ScriptSpan.js} +22 -33
  37. package/dst/cjs/Type.d.ts +71 -0
  38. package/dst/cjs/Type.js +2 -0
  39. package/dst/cjs/Value.d.ts +5 -0
  40. package/dst/cjs/Variable.d.ts +9 -0
  41. package/dst/cjs/Variable.js +0 -7
  42. package/dst/cjs/atom/ArrayAtom.d.ts +16 -0
  43. package/dst/cjs/atom/FunctionAtom.d.ts +22 -0
  44. package/dst/cjs/atom/ObjectAtom.d.ts +14 -0
  45. package/dst/cjs/atom/PrimitiveAtom.d.ts +12 -0
  46. package/dst/cjs/index.d.ts +3 -0
  47. package/dst/cjs/native/Aggregable.d.ts +4 -0
  48. package/dst/cjs/native/Array.d.ts +16 -0
  49. package/dst/cjs/native/Boolean.d.ts +6 -0
  50. package/dst/cjs/native/Buffer.d.ts +13 -0
  51. package/dst/cjs/native/Buffer.js +1 -1
  52. package/dst/cjs/native/Enumerable.d.ts +4 -0
  53. package/dst/cjs/native/Float.d.ts +5 -0
  54. package/dst/cjs/native/Integer.d.ts +7 -0
  55. package/dst/cjs/native/Iterable.d.ts +5 -0
  56. package/dst/cjs/native/Number.d.ts +26 -0
  57. package/dst/cjs/native/Number.js +25 -12
  58. package/dst/cjs/native/Object.d.ts +5 -0
  59. package/dst/cjs/native/String.d.ts +28 -0
  60. package/dst/cjs/native/String.js +97 -48
  61. package/dst/cjs/native/Timestamp.d.ts +22 -0
  62. package/dst/cjs/native/Unknown.d.ts +14 -0
  63. package/dst/cjs/native/Unknown.js +10 -1
  64. package/dst/cjs/native/notation/AN.d.ts +4 -0
  65. package/dst/cjs/native/notation/AN.js +2 -2
  66. package/dst/cjs/native/notation/IP.d.ts +1 -0
  67. package/dst/cjs/native/notation/JSON.d.ts +3 -0
  68. package/dst/cjs/node/ArrayNode.d.ts +14 -0
  69. package/dst/cjs/node/ArrayNode.js +4 -11
  70. package/dst/cjs/node/BlockNode.d.ts +15 -0
  71. package/dst/cjs/node/BlockNode.js +10 -6
  72. package/dst/cjs/node/CallNode.d.ts +15 -0
  73. package/dst/cjs/node/CallNode.js +15 -28
  74. package/dst/cjs/node/CastNode.d.ts +16 -0
  75. package/dst/cjs/node/CastNode.js +4 -4
  76. package/dst/cjs/node/ConstantNode.d.ts +17 -0
  77. package/dst/cjs/node/ConstantNode.js +7 -5
  78. package/dst/cjs/node/JumpNode.d.ts +16 -0
  79. package/dst/cjs/node/JumpNode.js +10 -6
  80. package/dst/cjs/node/LoopNode.d.ts +14 -0
  81. package/dst/cjs/node/LoopNode.js +5 -5
  82. package/dst/cjs/node/ObjectNode.d.ts +14 -0
  83. package/dst/cjs/node/ObjectNode.js +6 -12
  84. package/dst/cjs/node/SwitchNode.d.ts +15 -0
  85. package/dst/cjs/node/SwitchNode.js +8 -7
  86. package/dst/cjs/node/VariableNode.d.ts +15 -0
  87. package/dst/cjs/node/VariableNode.js +5 -5
  88. package/dst/cjs/node/VariadicNode.d.ts +4 -0
  89. package/dst/cjs/node/VariadicNode.js +10 -0
  90. package/dst/native/Buffer.js +1 -1
  91. package/dst/native/Number.js +25 -12
  92. package/dst/native/String.js +97 -48
  93. package/dst/native/Unknown.js +10 -1
  94. package/dst/native/notation/AN.js +2 -2
  95. package/dst/node/ArrayNode.d.ts +4 -3
  96. package/dst/node/ArrayNode.js +4 -11
  97. package/dst/node/BlockNode.d.ts +6 -3
  98. package/dst/node/BlockNode.js +10 -6
  99. package/dst/node/CallNode.d.ts +4 -3
  100. package/dst/node/CallNode.js +15 -28
  101. package/dst/node/CastNode.d.ts +4 -3
  102. package/dst/node/CastNode.js +4 -4
  103. package/dst/node/ConstantNode.d.ts +5 -3
  104. package/dst/node/ConstantNode.js +7 -5
  105. package/dst/node/JumpNode.d.ts +5 -3
  106. package/dst/node/JumpNode.js +10 -6
  107. package/dst/node/LoopNode.d.ts +4 -3
  108. package/dst/node/LoopNode.js +5 -5
  109. package/dst/node/ObjectNode.d.ts +4 -3
  110. package/dst/node/ObjectNode.js +6 -12
  111. package/dst/node/SwitchNode.d.ts +4 -3
  112. package/dst/node/SwitchNode.js +8 -7
  113. package/dst/node/VariableNode.d.ts +4 -3
  114. package/dst/node/VariableNode.js +5 -5
  115. package/dst/node/VariadicNode.d.ts +4 -0
  116. package/dst/node/VariadicNode.js +6 -0
  117. package/package.json +10 -9
  118. package/dst/ParserFrame.d.ts +0 -13
  119. package/dst/Scope.d.ts +0 -16
  120. package/dst/Scope.js +0 -49
  121. package/dst/cjs/Scope.js +0 -53
@@ -0,0 +1,60 @@
1
+ import { Constant } from "./Constant.js";
2
+ import { Value } from "./Value.js";
3
+ import { Type } from "./Type.js";
4
+ import { ScriptSpan } from "./ScriptSpan.js";
5
+ declare class Literal {
6
+ readonly value: Value;
7
+ constructor(value: Value);
8
+ }
9
+ declare class Assignment {
10
+ readonly operator?: Constant | undefined;
11
+ constructor(operator?: Constant | undefined);
12
+ }
13
+ export declare class ParserState extends ScriptSpan {
14
+ protected _fragment: Literal | Assignment | Constant | Type | symbol | string | undefined;
15
+ constructor(script: string);
16
+ get literal(): Literal;
17
+ get assignment(): Assignment;
18
+ get operator(): Constant;
19
+ get type(): Type;
20
+ get token(): string;
21
+ get isOperator(): boolean;
22
+ get isLiteral(): boolean;
23
+ get isAssignment(): boolean;
24
+ get isType(): boolean;
25
+ get isToken(): boolean;
26
+ get isParenthesesOpen(): boolean;
27
+ get isParenthesesClose(): boolean;
28
+ get isBracketsOpen(): boolean;
29
+ get isBracketsClose(): boolean;
30
+ get isBracesOpen(): boolean;
31
+ get isBracesClose(): boolean;
32
+ get isSemicolon(): boolean;
33
+ get isColon(): boolean;
34
+ get isComma(): boolean;
35
+ get isTilda(): boolean;
36
+ get isDot(): boolean;
37
+ get isQuestion(): boolean;
38
+ get isEllipsis(): boolean;
39
+ get isCast(): boolean;
40
+ get isVar(): boolean;
41
+ get isVal(): boolean;
42
+ get isIf(): boolean;
43
+ get isElse(): boolean;
44
+ get isWhile(): boolean;
45
+ get isExit(): boolean;
46
+ get isReturn(): boolean;
47
+ get isStop(): boolean;
48
+ get isNext(): boolean;
49
+ get isEmpty(): boolean;
50
+ openParentheses(): this;
51
+ closeParentheses(): this;
52
+ openBrackets(): this;
53
+ closeBrackets(): this;
54
+ openBraces(): this;
55
+ closeBraces(): this;
56
+ separateByColon(): this;
57
+ clone(): ParserState;
58
+ next(): ParserState;
59
+ }
60
+ export {};
@@ -10,7 +10,7 @@ const String_js_1 = require("./native/String.js");
10
10
  const Timestamp_js_1 = require("./native/Timestamp.js");
11
11
  const Constant_js_1 = require("./Constant.js");
12
12
  const Type_js_1 = require("./Type.js");
13
- const ParserFrame_js_1 = require("./ParserFrame.js");
13
+ const ScriptSpan_js_1 = require("./ScriptSpan.js");
14
14
  class Literal {
15
15
  value;
16
16
  constructor(value) {
@@ -57,10 +57,10 @@ const idExit = Symbol();
57
57
  const idReturn = Symbol();
58
58
  const idStop = Symbol();
59
59
  const idNext = Symbol();
60
- class ParserState extends ParserFrame_js_1.ParserFrame {
60
+ class ParserState extends ScriptSpan_js_1.ScriptSpan {
61
61
  _fragment;
62
- constructor(expr) {
63
- super(expr);
62
+ constructor(script) {
63
+ super(script);
64
64
  }
65
65
  get literal() {
66
66
  return this._fragment;
@@ -207,7 +207,7 @@ class ParserState extends ParserFrame_js_1.ParserFrame {
207
207
  return this;
208
208
  }
209
209
  clone() {
210
- const state = new ParserState(this._expr);
210
+ const state = new ParserState(this._script);
211
211
  state._start = this._start;
212
212
  state._end = this._end;
213
213
  state._fragment = this._fragment;
@@ -215,9 +215,9 @@ class ParserState extends ParserFrame_js_1.ParserFrame {
215
215
  }
216
216
  next() {
217
217
  this._fragment = undefined;
218
- while (this._end < this._expr.length && this._fragment == null) {
218
+ while (this._end < this._script.length && this._fragment == null) {
219
219
  this._start = this._end;
220
- const c = this._expr.charAt(this._end);
220
+ const c = this._script.charAt(this._end);
221
221
  ++this._end;
222
222
  switch (c) {
223
223
  case " ":
@@ -248,7 +248,7 @@ class ParserState extends ParserFrame_js_1.ParserFrame {
248
248
  this._fragment = idSemicolon;
249
249
  break;
250
250
  case ":":
251
- switch (this._expr.charAt(this._end)) {
251
+ switch (this._script.charAt(this._end)) {
252
252
  case ":":
253
253
  ++this._end;
254
254
  this._fragment = idCast;
@@ -262,7 +262,7 @@ class ParserState extends ParserFrame_js_1.ParserFrame {
262
262
  this._fragment = idComma;
263
263
  break;
264
264
  case "~":
265
- switch (this._expr.charAt(this._end)) {
265
+ switch (this._script.charAt(this._end)) {
266
266
  case ">":
267
267
  ++this._end;
268
268
  this._fragment = idReturn;
@@ -273,7 +273,7 @@ class ParserState extends ParserFrame_js_1.ParserFrame {
273
273
  }
274
274
  break;
275
275
  case "?":
276
- switch (this._expr.charAt(this._end)) {
276
+ switch (this._script.charAt(this._end)) {
277
277
  case "?":
278
278
  ++this._end;
279
279
  this._fragment = Type_js_1.Type.Unknown;
@@ -288,7 +288,7 @@ class ParserState extends ParserFrame_js_1.ParserFrame {
288
288
  }
289
289
  break;
290
290
  case "|":
291
- switch (this._expr.charAt(this._end)) {
291
+ switch (this._script.charAt(this._end)) {
292
292
  case "=":
293
293
  ++this._end;
294
294
  this._fragment = funcOrAssignment;
@@ -299,7 +299,7 @@ class ParserState extends ParserFrame_js_1.ParserFrame {
299
299
  }
300
300
  break;
301
301
  case "&":
302
- switch (this._expr.charAt(this._end)) {
302
+ switch (this._script.charAt(this._end)) {
303
303
  case "=":
304
304
  ++this._end;
305
305
  this._fragment = funcAndAssignment;
@@ -310,7 +310,7 @@ class ParserState extends ParserFrame_js_1.ParserFrame {
310
310
  }
311
311
  break;
312
312
  case ">":
313
- switch (this._expr.charAt(this._end)) {
313
+ switch (this._script.charAt(this._end)) {
314
314
  case "=":
315
315
  ++this._end;
316
316
  this._fragment = Number_js_1.funcGreaterOrEqual;
@@ -321,7 +321,7 @@ class ParserState extends ParserFrame_js_1.ParserFrame {
321
321
  }
322
322
  break;
323
323
  case "<":
324
- switch (this._expr.charAt(this._end)) {
324
+ switch (this._script.charAt(this._end)) {
325
325
  case "=":
326
326
  ++this._end;
327
327
  this._fragment = Number_js_1.funcLessOrEqual;
@@ -332,7 +332,7 @@ class ParserState extends ParserFrame_js_1.ParserFrame {
332
332
  }
333
333
  break;
334
334
  case "!":
335
- switch (this._expr.charAt(this._end)) {
335
+ switch (this._script.charAt(this._end)) {
336
336
  case "=":
337
337
  ++this._end;
338
338
  this._fragment = Unknown_js_1.funcNotEqual;
@@ -343,7 +343,7 @@ class ParserState extends ParserFrame_js_1.ParserFrame {
343
343
  }
344
344
  break;
345
345
  case "=":
346
- switch (this._expr.charAt(this._end)) {
346
+ switch (this._script.charAt(this._end)) {
347
347
  case "=":
348
348
  ++this._end;
349
349
  this._fragment = Unknown_js_1.funcEqual;
@@ -358,7 +358,7 @@ class ParserState extends ParserFrame_js_1.ParserFrame {
358
358
  }
359
359
  break;
360
360
  case "+":
361
- switch (this._expr.charAt(this._end)) {
361
+ switch (this._script.charAt(this._end)) {
362
362
  case "=":
363
363
  ++this._end;
364
364
  this._fragment = funcAddAssignment;
@@ -369,7 +369,7 @@ class ParserState extends ParserFrame_js_1.ParserFrame {
369
369
  }
370
370
  break;
371
371
  case "-":
372
- switch (this._expr.charAt(this._end)) {
372
+ switch (this._script.charAt(this._end)) {
373
373
  case "=":
374
374
  ++this._end;
375
375
  this._fragment = funcSubtractAssignment;
@@ -380,7 +380,7 @@ class ParserState extends ParserFrame_js_1.ParserFrame {
380
380
  }
381
381
  break;
382
382
  case "*":
383
- switch (this._expr.charAt(this._end)) {
383
+ switch (this._script.charAt(this._end)) {
384
384
  case "=":
385
385
  ++this._end;
386
386
  this._fragment = funcMultiplyAssignment;
@@ -391,29 +391,29 @@ class ParserState extends ParserFrame_js_1.ParserFrame {
391
391
  }
392
392
  break;
393
393
  case "/":
394
- switch (this._expr.charAt(this._end)) {
394
+ switch (this._script.charAt(this._end)) {
395
395
  case "=":
396
396
  ++this._end;
397
397
  this._fragment = funcDivideAssignment;
398
398
  break;
399
399
  case "/":
400
- if (this._expr.charAt(++this._end) === "/") {
400
+ if (this._script.charAt(++this._end) === "/") {
401
401
  ++this._end;
402
- while (this._expr.charAt(this._end) !== ""
403
- && (this._expr.charAt(this._end) !== c
404
- || this._expr.charAt(this._end - 1) !== c
405
- || this._expr.charAt(this._end - 2) !== c)) {
402
+ while (this._script.charAt(this._end) !== ""
403
+ && (this._script.charAt(this._end) !== c
404
+ || this._script.charAt(this._end - 1) !== c
405
+ || this._script.charAt(this._end - 2) !== c)) {
406
406
  ++this._end;
407
407
  }
408
- if (this._end >= this._expr.length) {
409
- this._start = this._expr.length;
408
+ if (this._end >= this._script.length) {
409
+ this._start = this._script.length;
410
410
  throw new Error("missing closing comment mark");
411
411
  }
412
412
  ++this._end;
413
413
  }
414
414
  else {
415
- while (this._expr.charAt(this._end) !== ""
416
- && this._expr.charAt(this._end) !== "\n") {
415
+ while (this._script.charAt(this._end) !== ""
416
+ && this._script.charAt(this._end) !== "\n") {
417
417
  ++this._end;
418
418
  }
419
419
  }
@@ -424,7 +424,7 @@ class ParserState extends ParserFrame_js_1.ParserFrame {
424
424
  }
425
425
  break;
426
426
  case "%":
427
- switch (this._expr.charAt(this._end)) {
427
+ switch (this._script.charAt(this._end)) {
428
428
  case "=":
429
429
  ++this._end;
430
430
  this._fragment = funcRemainderAssignment;
@@ -438,9 +438,9 @@ class ParserState extends ParserFrame_js_1.ParserFrame {
438
438
  this._fragment = Number_js_1.funcPower;
439
439
  break;
440
440
  case ".":
441
- switch (this._expr.charAt(this._end)) {
441
+ switch (this._script.charAt(this._end)) {
442
442
  case ".":
443
- if (this._expr.charAt(++this._end) === ".") {
443
+ if (this._script.charAt(++this._end) === ".") {
444
444
  ++this._end;
445
445
  this._fragment = idEllipsis;
446
446
  }
@@ -454,30 +454,30 @@ class ParserState extends ParserFrame_js_1.ParserFrame {
454
454
  }
455
455
  break;
456
456
  case "@": {
457
- const [ts, tsEnd] = (0, Timestamp_js_1.parseLiteralTimestamp)(this._expr, this._start);
457
+ const [ts, tsEnd] = (0, Timestamp_js_1.parseLiteralTimestamp)(this._script, this._start);
458
458
  this._fragment = new Literal(ts);
459
459
  this._end = tsEnd;
460
460
  break;
461
461
  }
462
462
  case "`": {
463
- const [buf, bufEnd] = (0, Buffer_js_1.parseLiteralBuffer)(this._expr, this._start);
463
+ const [buf, bufEnd] = (0, Buffer_js_1.parseLiteralBuffer)(this._script, this._start);
464
464
  this._fragment = new Literal(buf);
465
465
  this._end = bufEnd;
466
466
  break;
467
467
  }
468
468
  case "\"":
469
469
  case "'": {
470
- const [str, strEnd] = (0, String_js_1.parseLiteralString)(this._expr, this._start);
470
+ const [str, strEnd] = (0, String_js_1.parseLiteralString)(this._script, this._start);
471
471
  this._fragment = new Literal(str);
472
472
  this._end = strEnd;
473
473
  break;
474
474
  }
475
475
  default:
476
476
  if ((0, String_js_1.isTokenStartSymbol)(c)) {
477
- while ((0, String_js_1.isTokenSymbol)(this._expr.charAt(this._end))) {
477
+ while ((0, String_js_1.isTokenSymbol)(this._script.charAt(this._end))) {
478
478
  ++this._end;
479
479
  }
480
- const token = this._expr.substring(this._start, this._end);
480
+ const token = this._script.substring(this._start, this._end);
481
481
  switch (token) {
482
482
  case "true":
483
483
  this._fragment = valueTrue;
@@ -549,7 +549,7 @@ class ParserState extends ParserFrame_js_1.ParserFrame {
549
549
  }
550
550
  }
551
551
  else if ((0, Number_js_1.isNumericSymbol)(c)) {
552
- const [num, numEnd] = (0, Number_js_1.parseLiteralNumber)(this._expr, this._start);
552
+ const [num, numEnd] = (0, Number_js_1.parseLiteralNumber)(this._script, this._start);
553
553
  this._fragment = new Literal(num);
554
554
  this._end = numEnd;
555
555
  }
@@ -559,8 +559,8 @@ class ParserState extends ParserFrame_js_1.ParserFrame {
559
559
  break;
560
560
  }
561
561
  }
562
- if (this._end > this._expr.length) {
563
- this._start = this._end = this._expr.length;
562
+ if (this._end > this._script.length) {
563
+ this._start = this._end = this._script.length;
564
564
  }
565
565
  return this;
566
566
  }
@@ -0,0 +1,10 @@
1
+ export declare class ScriptSpan {
2
+ protected readonly _script: string;
3
+ protected _start: number;
4
+ protected _end: number;
5
+ protected constructor(span: ScriptSpan | string);
6
+ start(): ScriptSpan;
7
+ end(span: ScriptSpan): this;
8
+ throwError(message: string): never;
9
+ toString(): string;
10
+ }
@@ -1,44 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParserFrame = void 0;
4
- class ParserFrame {
5
- _expr;
6
- _start;
7
- _end;
8
- constructor(_expr, _start = 0, _end = 0) {
9
- this._expr = _expr;
10
- this._start = _start;
11
- this._end = _end;
12
- }
13
- get expr() {
14
- return this._expr;
15
- }
16
- get start() {
17
- return this._start;
18
- }
19
- get end() {
20
- return this._end;
21
- }
22
- starts(frame) {
23
- if (frame) {
24
- this._start = frame.start;
25
- return this;
3
+ exports.ScriptSpan = void 0;
4
+ class ScriptSpan {
5
+ _script;
6
+ _start = 0;
7
+ _end = 0;
8
+ constructor(span) {
9
+ if (typeof span === "string") {
10
+ this._script = span;
26
11
  }
27
- return new ParserFrame(this._expr, this._start, this._end);
28
- }
29
- ends(frame) {
30
- if (frame) {
31
- this._end = frame.end;
32
- return this;
12
+ else {
13
+ this._script = span._script;
14
+ this._start = span._start;
15
+ this._end = span._end;
33
16
  }
34
- return new ParserFrame(this._expr, this._start, this._end);
17
+ }
18
+ start() {
19
+ return new ScriptSpan(this);
20
+ }
21
+ end(span) {
22
+ this._end = span._end;
23
+ return this;
35
24
  }
36
25
  throwError(message) {
37
26
  const offset = this._start < 32 ? 0 : this._start - 32;
38
27
  const length = this._end < this._start ? 0 : this._end - this._start - 1;
39
28
  let expr = "";
40
- for (let i = 0; i < this._expr.length; ++i) {
41
- const c = this._expr[i];
29
+ for (let i = 0; i < this._script.length; ++i) {
30
+ const c = this._script[i];
42
31
  expr += SPACE_SYMBOLS.includes(c) ? " " : c;
43
32
  }
44
33
  throw new Error(`error: ${message} at position ${this._start}:\n${expr.substring(offset, offset + 60)}\n` +
@@ -48,7 +37,7 @@ class ParserFrame {
48
37
  return `[${this._start}:${this._end}]`;
49
38
  }
50
39
  }
51
- exports.ParserFrame = ParserFrame;
40
+ exports.ScriptSpan = ScriptSpan;
52
41
  const SPACE_SYMBOLS = [
53
42
  // Whitespace and line-breaking characters
54
43
  "\t", // tab
@@ -0,0 +1,71 @@
1
+ import { Value } from "./Value.js";
2
+ import { PrimitiveAtom, Primitive } from "./atom/PrimitiveAtom.js";
3
+ import { ArrayAtom } from "./atom/ArrayAtom.js";
4
+ import { ObjectAtom } from "./atom/ObjectAtom.js";
5
+ import { FunctionAtom } from "./atom/FunctionAtom.js";
6
+ type Atom = PrimitiveAtom | ArrayAtom | ObjectAtom | FunctionAtom;
7
+ export declare class Type {
8
+ protected readonly _atoms: Atom[];
9
+ private constructor();
10
+ get isUnknown(): boolean;
11
+ get isAtom(): boolean;
12
+ get isOptional(): boolean;
13
+ get isVoid(): boolean;
14
+ get isBoolean(): boolean;
15
+ get isTimestamp(): boolean;
16
+ get isFloat(): boolean;
17
+ get isInteger(): boolean;
18
+ get isBuffer(): boolean;
19
+ get isString(): boolean;
20
+ get isArray(): boolean;
21
+ get isObject(): boolean;
22
+ get isFunction(): boolean;
23
+ equate(type: Type | undefined): boolean;
24
+ accept(type: Type | Atom): boolean;
25
+ acceptValue(value: Value): boolean;
26
+ reduce(mask: Type): Type | undefined;
27
+ intersect(type: Type): boolean;
28
+ weight(): number;
29
+ arrayAtomValType(index: number): Type;
30
+ functionAtomRetType(type: Type): Type;
31
+ functionAtoms(type: Type, argc: number): FunctionAtom[];
32
+ toOptional(): Type;
33
+ toMandatory(): Type;
34
+ toString(): string;
35
+ static union(...types: Type[]): Type;
36
+ static of(value: Value): Type;
37
+ static isPrimitive(value: Value): value is string | number | bigint | boolean | Date | ArrayBuffer | null | undefined;
38
+ static primitiveType(primitive: Primitive): Type;
39
+ static arrayType(itemTypes?: Type[]): Type;
40
+ static objectType(propTypes?: [string, Type][]): Type;
41
+ static functionType(retType?: Type, argTypes?: Type[], isVariadic?: boolean): Type;
42
+ static readonly Unknown: Type;
43
+ static readonly Void: Type;
44
+ static readonly Boolean: Type;
45
+ static readonly OptionalBoolean: Type;
46
+ static readonly Timestamp: Type;
47
+ static readonly OptionalTimestamp: Type;
48
+ static readonly Float: Type;
49
+ static readonly OptionalFloat: Type;
50
+ static readonly Integer: Type;
51
+ static readonly OptionalInteger: Type;
52
+ static readonly Buffer: Type;
53
+ static readonly OptionalBuffer: Type;
54
+ static readonly String: Type;
55
+ static readonly OptionalString: Type;
56
+ static readonly Array: Type;
57
+ static readonly OptionalArray: Type;
58
+ static readonly Object: Type;
59
+ static readonly OptionalObject: Type;
60
+ static readonly Function: Type;
61
+ static readonly OptionalFunction: Type;
62
+ static readonly Reference: Type;
63
+ static readonly OptionalReference: Type;
64
+ static readonly Number: Type;
65
+ static readonly OptionalNumber: Type;
66
+ static readonly Enumerable: Type;
67
+ static readonly OptionalEnumerable: Type;
68
+ static readonly Iterable: Type;
69
+ static readonly OptionalIterable: Type;
70
+ }
71
+ export {};
package/dst/cjs/Type.js CHANGED
@@ -245,6 +245,8 @@ class Type {
245
245
  static OptionalObject = Type.union(Type.Void, Type.Object);
246
246
  static Function = Type.functionType(undefined, undefined, true);
247
247
  static OptionalFunction = Type.union(Type.Void, Type.Function);
248
+ static Reference = Type.union(Type.Array, Type.Object, Type.Function);
249
+ static OptionalReference = Type.union(Type.Void, Type.Array, Type.Object, Type.Function);
248
250
  static Number = Type.union(Type.Float, Type.Integer);
249
251
  static OptionalNumber = Type.union(Type.Void, Type.Float, Type.Integer);
250
252
  static Enumerable = Type.union(Type.Buffer, Type.String, Type.Array);
@@ -0,0 +1,5 @@
1
+ export type PrimitiveValue = undefined | null | number | boolean | Date | bigint | ArrayBuffer | string;
2
+ export type Value = PrimitiveValue | Value[] | {
3
+ [key: string]: Value;
4
+ } | ((...args: any[]) => Value);
5
+ export declare const normalize: (value: Value) => Value;
@@ -0,0 +1,9 @@
1
+ import { Type } from "./Type.js";
2
+ export declare class Variable {
3
+ protected _type: Type;
4
+ protected readonly _assignable: boolean;
5
+ constructor(_type?: Type, _assignable?: boolean);
6
+ get type(): Type;
7
+ set type(type: Type);
8
+ get assignable(): boolean;
9
+ }
@@ -5,17 +5,10 @@ const Type_js_1 = require("./Type.js");
5
5
  class Variable {
6
6
  _type;
7
7
  _assignable;
8
- _value;
9
8
  constructor(_type = Type_js_1.Type.Unknown, _assignable = true) {
10
9
  this._type = _type;
11
10
  this._assignable = _assignable;
12
11
  }
13
- get value() {
14
- return this._value;
15
- }
16
- set value(value) {
17
- this._value = value;
18
- }
19
12
  get type() {
20
13
  return this._type;
21
14
  }
@@ -0,0 +1,16 @@
1
+ import { IAtom } from "../Atom.js";
2
+ import { Type } from "../Type.js";
3
+ export declare class ArrayAtom implements IAtom {
4
+ protected readonly _valTypes: Type[];
5
+ constructor(_valTypes?: Type[]);
6
+ private get _undefined();
7
+ private _intersectLength;
8
+ get isTuple(): boolean;
9
+ valTypes(): Type[];
10
+ valType(index: number): Type | undefined;
11
+ equate(atom: IAtom): boolean;
12
+ accept(atom: IAtom): boolean;
13
+ intersect(atom: IAtom): boolean;
14
+ weight(): number;
15
+ toString(): string;
16
+ }
@@ -0,0 +1,22 @@
1
+ import { IAtom } from "../Atom.js";
2
+ import { Type } from "../Type.js";
3
+ export declare class FunctionAtom implements IAtom {
4
+ protected readonly _retType: Type;
5
+ protected readonly _argTypes: Type[];
6
+ protected readonly _isVariadic: boolean;
7
+ protected readonly _minArity: number;
8
+ constructor(_retType?: Type, _argTypes?: Type[], _isVariadic?: boolean);
9
+ private get _undefined();
10
+ get retType(): Type;
11
+ get minArity(): number;
12
+ get maxArity(): number;
13
+ get isVariadic(): boolean;
14
+ get arity(): number;
15
+ argType(index: number): Type | undefined;
16
+ paramType(index: number): Type | undefined;
17
+ equate(atom: IAtom): boolean;
18
+ accept(atom: IAtom): boolean;
19
+ intersect(atom: IAtom): boolean;
20
+ weight(): number;
21
+ toString(): string;
22
+ }
@@ -0,0 +1,14 @@
1
+ import { IAtom } from "../Atom.js";
2
+ import { Type } from "../Type.js";
3
+ export declare class ObjectAtom implements IAtom {
4
+ protected readonly _valTypes: [string, Type][];
5
+ constructor(valTypes?: [string, Type][]);
6
+ private get _undefined();
7
+ valTypes(): [string, Type][];
8
+ valType(key: string): Type | undefined;
9
+ equate(atom: IAtom): boolean;
10
+ accept(atom: IAtom): boolean;
11
+ intersect(atom: IAtom): boolean;
12
+ weight(): number;
13
+ toString(): string;
14
+ }
@@ -0,0 +1,12 @@
1
+ import { IAtom } from "../Atom.js";
2
+ export type Primitive = "void" | "boolean" | "timestamp" | "float" | "integer" | "buffer" | "string";
3
+ export declare class PrimitiveAtom implements IAtom {
4
+ protected readonly _primitive: Primitive;
5
+ constructor(_primitive?: Primitive);
6
+ get undef(): boolean;
7
+ equate(atom: IAtom): boolean;
8
+ accept(atom: IAtom): boolean;
9
+ intersect(atom: IAtom): boolean;
10
+ weight(): number;
11
+ toString(): string;
12
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./Value.js";
2
+ export * from "./Type.js";
3
+ export * from "./Affinirum.js";
@@ -0,0 +1,4 @@
1
+ import { Constant } from "../Constant.js";
2
+ import { Value } from "../Value.js";
3
+ export declare const aggregate: (value1: ArrayBuffer | string | Value[] | null | undefined, value2: ArrayBuffer | string | Value[] | null | undefined) => string | ArrayBuffer | Value[] | undefined;
4
+ export declare const funcAdd: Constant;
@@ -0,0 +1,16 @@
1
+ import { Constant } from "../Constant.js";
2
+ export declare const funcFirst: Constant;
3
+ export declare const funcLast: Constant;
4
+ export declare const funcFirstIndex: Constant;
5
+ export declare const funcLastIndex: Constant;
6
+ export declare const funcEvery: Constant;
7
+ export declare const funcAny: Constant;
8
+ export declare const funcFlatten: Constant;
9
+ export declare const funcReverse: Constant;
10
+ export declare const funcDerive: Constant;
11
+ export declare const funcFilter: Constant;
12
+ export declare const funcReduce: Constant;
13
+ export declare const funcCompose: Constant;
14
+ export declare const funcPrepend: Constant;
15
+ export declare const funcAppend: Constant;
16
+ export declare const constArray: any;
@@ -0,0 +1,6 @@
1
+ import { Constant } from "../Constant.js";
2
+ export declare const funcOr: Constant;
3
+ export declare const funcAnd: Constant;
4
+ export declare const funcNot: Constant;
5
+ export declare const funcBoolean: Constant;
6
+ export declare const constBoolean: any;
@@ -0,0 +1,13 @@
1
+ import { Constant } from "../Constant.js";
2
+ export type BufferFormatting = "hex" | "base64";
3
+ export declare const EmptyBuffer: ArrayBuffer;
4
+ export declare const formatLiteralBuffer: (value: ArrayBuffer) => string;
5
+ export declare const parseLiteralBuffer: (value: string, offset?: number) => readonly [ArrayBuffer, number];
6
+ export declare const parseBoundedInteger: (input: string, base: 10 | 16, min: number, max: number) => number;
7
+ export declare const equateBuffers: (value1: ArrayBuffer, value2: ArrayBuffer) => boolean;
8
+ export declare const containsBuffer: (value: ArrayBuffer, search: ArrayBuffer, startPos?: number) => boolean;
9
+ export declare const concatBuffers: (value1: ArrayBuffer, value2: ArrayBuffer) => ArrayBuffer;
10
+ export declare const formatBuffer: (value: ArrayBuffer, formatting?: BufferFormatting) => string;
11
+ export declare const parseBuffer: (value?: string) => ArrayBuffer | undefined;
12
+ export declare const funcByte: Constant;
13
+ export declare const constBuffer: any;
@@ -97,7 +97,7 @@ const containsBuffer = (value, search, startPos) => {
97
97
  return true;
98
98
  }
99
99
  const pos = startPos == null ? 0 : startPos < 0 ? value.byteLength + startPos : startPos;
100
- if (pos > value.byteLength - search.byteLength) {
100
+ if (pos < 0 || pos > value.byteLength - search.byteLength) {
101
101
  return false;
102
102
  }
103
103
  const dvv = new DataView(value);
@@ -0,0 +1,4 @@
1
+ import { Constant } from "../Constant.js";
2
+ export declare const funcSlice: Constant;
3
+ export declare const funcSplice: Constant;
4
+ export declare const funcInject: Constant;