@woosh/meep-engine 2.49.6 → 2.49.7

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 (31) hide show
  1. package/package.json +1 -1
  2. package/src/core/cache/LoadingCache.d.ts +2 -0
  3. package/src/core/cache/LoadingCache.js +45 -18
  4. package/src/core/math/computeGreatestCommonDivisor.spec.js +9 -0
  5. package/src/core/math/statistics/computeStatisticalMean.spec.js +9 -0
  6. package/src/core/math/statistics/halton_sequence.spec.js +6 -1
  7. package/src/core/model/node-graph/node/Port.spec.js +10 -1
  8. package/src/core/model/reactive/evaluation/MultiPredicateEvaluator.js +5 -8
  9. package/src/core/model/reactive/evaluation/MultiPredicateEvaluator.spec.js +41 -0
  10. package/src/core/model/reactive/trigger/BlackboardTrigger.js +5 -0
  11. package/src/core/model/reactive/trigger/BlackboardTrigger.spec.js +24 -0
  12. package/src/core/parser/simple/readBooleanToken.js +38 -0
  13. package/src/core/parser/simple/readHexToken.js +95 -0
  14. package/src/core/parser/simple/readHexToken.spec.js +21 -0
  15. package/src/core/parser/simple/readIdentifierToken.js +43 -0
  16. package/src/core/parser/simple/readIdentifierToken.spec.js +32 -0
  17. package/src/core/parser/simple/readLiteralToken.js +96 -0
  18. package/src/core/parser/simple/readNumberToken.js +73 -0
  19. package/src/core/parser/simple/readNumberToken.spec.js +17 -0
  20. package/src/core/parser/simple/readReferenceToken.js +48 -0
  21. package/src/core/parser/simple/readReferenceToken.spec.js +18 -0
  22. package/src/core/parser/simple/readStringToken.js +94 -0
  23. package/src/core/parser/simple/readStringToken.spec.js +57 -0
  24. package/src/core/parser/simple/{readUnsignedInteger.js → readUnsignedIntegerToken.js} +1 -1
  25. package/src/core/parser/simple/readUnsignedIntegerToken.spec.js +6 -0
  26. package/src/core/process/executor/ConcurrentExecutor.js +147 -234
  27. package/src/engine/intelligence/blackboard/Blackboard.d.ts +4 -0
  28. package/src/engine/intelligence/blackboard/Blackboard.js +11 -0
  29. package/src/view/tooltip/gml/parser/readReferenceValueToken.js +2 -2
  30. package/src/core/parser/simple/SimpleParser.js +0 -464
  31. package/src/core/parser/simple/SimpleParser.spec.js +0 -105
@@ -0,0 +1,17 @@
1
+ import { readNumberToken } from "./readNumberToken.js";
2
+
3
+ test("hex", () => {
4
+ expect(readNumberToken("0x3", 0, 3).value).toBe(3);
5
+ });
6
+
7
+ test("signed integer", () => {
8
+ expect(readNumberToken("+3", 0, 2).value).toBe(3);
9
+ expect(readNumberToken("3", 0, 1).value).toBe(3);
10
+ expect(readNumberToken("-7", 0, 2).value).toBe(-7);
11
+ });
12
+
13
+ test("decimal", () => {
14
+ expect(readNumberToken("1.0", 0, 3).value).toBe(1);
15
+ expect(readNumberToken("0.1", 0, 3).value).toBe(0.1);
16
+ expect(readNumberToken("-0.830", 0, 6).value).toBe(-0.830);
17
+ });
@@ -0,0 +1,48 @@
1
+ import DataType from "./DataType.js";
2
+ import Token from "./Token.js";
3
+ import TokenType from "./TokenType.js";
4
+ import { readIdentifierToken } from "./readIdentifierToken.js";
5
+
6
+
7
+ /**
8
+ *
9
+ * @param {String} text
10
+ * @param {number} cursor
11
+ * @param {number} length
12
+ * @returns {Token}
13
+ */
14
+ export function readReferenceToken(text, cursor, length) {
15
+ let i = cursor;
16
+
17
+ const identifiers = [];
18
+
19
+ let identifier;
20
+
21
+ identifier = readIdentifierToken(text, i, length);
22
+
23
+ identifiers.push(identifier);
24
+
25
+ i = identifier.end;
26
+
27
+ for (; ;) {
28
+
29
+ const firstChar = text.charAt(i);
30
+
31
+ if (firstChar !== '.') {
32
+ break;
33
+ }
34
+
35
+ //skip over the separator
36
+ i++;
37
+
38
+ identifier = readIdentifierToken(text, i, length);
39
+
40
+ identifiers.push(identifier);
41
+
42
+ i = identifier.end;
43
+ }
44
+
45
+ return new Token(identifiers, cursor, i, TokenType.Reference, DataType.String);
46
+ }
47
+
48
+
@@ -0,0 +1,18 @@
1
+ import { readReferenceToken } from "./readReferenceToken.js";
2
+ import TokenType from "./TokenType.js";
3
+
4
+ test('parse reference a.b', () => {
5
+ const token = readReferenceToken('a.b', 0, 3);
6
+
7
+ expect(token.end).toBe(3);
8
+ expect(token.start).toBe(0);
9
+ expect(token.name).toBe(TokenType.Reference);
10
+
11
+ const identifiers = token.value;
12
+
13
+ expect(Array.isArray(identifiers)).toBe(true);
14
+ expect(identifiers.length).toBe(2);
15
+
16
+ expect(identifiers[0].value).toBe('a');
17
+ expect(identifiers[1].value).toBe('b');
18
+ });
@@ -0,0 +1,94 @@
1
+ import ParserError from "./ParserError.js";
2
+ import Token from "./Token.js";
3
+ import TokenType from "./TokenType.js";
4
+ import DataType from "./DataType.js";
5
+
6
+ /**
7
+ *
8
+ * @param {string} text
9
+ * @param {number} cursor
10
+ * @returns {string}
11
+ */
12
+ function readQuote(text, cursor) {
13
+ const char = text.charAt(cursor);
14
+
15
+ if (char !== '"' && char !== '\'') {
16
+ throw new ParserError(cursor, "Expected \", found " + char + " instead", text);
17
+ }
18
+
19
+ return char;
20
+ }
21
+
22
+ /**
23
+ *
24
+ * @param {string} text
25
+ * @param {number} cursor
26
+ * @param {number} length
27
+ * @returns {Token}
28
+ */
29
+ export function readStringToken(text, cursor, length) {
30
+ let i = cursor;
31
+
32
+ const openingQuote = readQuote(text, i);
33
+
34
+ i++;
35
+
36
+ let char;
37
+
38
+ let value = '';
39
+ const lastPossibleChar = length - 1;
40
+
41
+ for (; i < lastPossibleChar; i++) {
42
+ char = text.charAt(i);
43
+
44
+ if (char === '\\') {
45
+ i++;
46
+ //read escape sequence
47
+ char = text.charAt(i);
48
+
49
+ switch (char) {
50
+ case 'n':
51
+ value += '\n';
52
+ break;
53
+ case 't':
54
+ value += '\t';
55
+ break;
56
+ case 'r':
57
+ value += '\r';
58
+ break;
59
+ case 'b':
60
+ value += '\b';
61
+ break;
62
+ case 'f':
63
+ value += '\f';
64
+ break;
65
+ case 'v':
66
+ value += '\v';
67
+ break;
68
+ case '0':
69
+ value += '\0';
70
+ break;
71
+ case '\\':
72
+ case "'":
73
+ case '"':
74
+ default:
75
+ value += char;
76
+ break;
77
+ }
78
+ } else if (char !== openingQuote) {
79
+ value += char;
80
+ } else {
81
+ break;
82
+ }
83
+ }
84
+
85
+ char = text.charAt(i);
86
+
87
+ if (char !== openingQuote) {
88
+ throw new ParserError(cursor, "Expected string terminator : " + openingQuote + ", but found '" + char + "' instead", text);
89
+ }
90
+
91
+ i++;
92
+
93
+ return new Token(value, cursor, i, TokenType.LiteralString, DataType.String);
94
+ }
@@ -0,0 +1,57 @@
1
+ import { readStringToken } from "./readStringToken.js";
2
+
3
+ test('parse empty string literal', () => {
4
+ const token = readStringToken('""', 0, 2);
5
+
6
+ expect(token.value).toBe("");
7
+ expect(token.start).toBe(0);
8
+ expect(token.end).toBe(2);
9
+ });
10
+
11
+ test('parse short string literal', () => {
12
+ const token = readStringToken('"1"', 0, 3);
13
+
14
+ expect(token.value).toBe("1");
15
+ expect(token.start).toBe(0);
16
+ expect(token.end).toBe(3);
17
+ });
18
+
19
+ test('parse short string literal from longer input', () => {
20
+ const token = readStringToken('"1" ', 0, 5);
21
+
22
+ expect(token.value).toBe("1");
23
+ expect(token.start).toBe(0);
24
+ expect(token.end).toBe(3);
25
+ });
26
+
27
+ test('parse long string literal', () => {
28
+ const token = readStringToken('"hello world"', 0, 13);
29
+
30
+ expect(token.value).toBe("hello world");
31
+ expect(token.start).toBe(0);
32
+ expect(token.end).toBe(13);
33
+ });
34
+
35
+ test('parse a single escaped quote string literal', () => {
36
+ const token = readStringToken('"\\""', 0, 4);
37
+
38
+ expect(token.value).toBe('\"');
39
+ expect(token.start).toBe(0);
40
+ expect(token.end).toBe(4);
41
+ });
42
+
43
+ test('parse string literal with escaped quotes', () => {
44
+ const token = readStringToken('"what is \\"?"', 0, 13);
45
+
46
+ expect(token.value).toBe('what is "?');
47
+ expect(token.start).toBe(0);
48
+ expect(token.end).toBe(13);
49
+ });
50
+
51
+ test('parse string literal sequential escape sequences', () => {
52
+ const token = readStringToken('"\\n\\t"', 0, 6);
53
+
54
+ expect(token.value).toBe('\n\t');
55
+ expect(token.start).toBe(0);
56
+ expect(token.end).toBe(6);
57
+ });
@@ -9,7 +9,7 @@ import DataType from "./DataType.js";
9
9
  * @param {number} length
10
10
  * @returns {Token}
11
11
  */
12
- export function readUnsignedInteger(text, cursor, length) {
12
+ export function readUnsignedIntegerToken(text, cursor, length) {
13
13
  let i = cursor;
14
14
 
15
15
  let value = 0;
@@ -0,0 +1,6 @@
1
+ import { readUnsignedIntegerToken } from "./readUnsignedIntegerToken.js";
2
+
3
+ test("sequence with all digits", () => {
4
+ const token = readUnsignedIntegerToken("1234567890", 0, 10);
5
+ expect(token.value).toEqual(1234567890);
6
+ });