@mark1russell7/vex-compiler 0.11.0 → 0.11.1
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/build/index.d.ts.map +1 -1
- package/build/index.js +16 -1
- package/build/index.js.map +1 -1
- package/package.json +4 -4
- package/src/module.ts +18 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@mark1russell7/vex-compiler",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.1",
|
|
5
5
|
"description": "The Vex compiler: generated JavaScript for Vex programs, at run time and at build time, with the results of the interpreter.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"vex",
|
|
@@ -43,15 +43,15 @@
|
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@mark1russell7/cue": "github:mark1russell7/cue",
|
|
46
|
-
"@mark1russell7/vex-domains": "0.11.
|
|
47
|
-
"@mark1russell7/vex-testkit": "0.11.
|
|
46
|
+
"@mark1russell7/vex-domains": "0.11.1",
|
|
47
|
+
"@mark1russell7/vex-testkit": "0.11.1",
|
|
48
48
|
"@types/node": "^26.6.4",
|
|
49
49
|
"fast-check": "^4.10.2",
|
|
50
50
|
"typescript": "^7.0.2",
|
|
51
51
|
"vitest": "^5.0.3"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@mark1russell7/vex": "0.11.
|
|
54
|
+
"@mark1russell7/vex": "0.11.1"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"build": "tsdown",
|
package/src/module.ts
CHANGED
|
@@ -571,6 +571,23 @@ interface InlineForm {
|
|
|
571
571
|
readonly uses: readonly number[];
|
|
572
572
|
}
|
|
573
573
|
|
|
574
|
+
/**
|
|
575
|
+
* The tokens of the text between the names of an inline form: digits, spaces, operators and parentheses. The tokenizer
|
|
576
|
+
* takes the first token that matches at each position, as the tokenizer of JavaScript takes the longest operator. So
|
|
577
|
+
* `<<=`, `>>=` and `>>>=` leave a lone `=`, and an assignment stops the inline form (V-058).
|
|
578
|
+
*/
|
|
579
|
+
const TOKEN = /\d|\.\d|\s|===?|!==?|<<|>>>?|<=|>=|[+\-*/%<>!?:(),&|^~]/y;
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* This function tells if a text is a sequence of tokens. It takes one token at each step, so its time is linear in the
|
|
583
|
+
* length of the text. A repeated group of the tokens can split `!==` in two ways, and its time is exponential (V-057).
|
|
584
|
+
*/
|
|
585
|
+
function isTokens(t: string): boolean {
|
|
586
|
+
TOKEN.lastIndex = 0;
|
|
587
|
+
while (TOKEN.lastIndex < t.length) if (!TOKEN.test(t)) return false;
|
|
588
|
+
return true;
|
|
589
|
+
}
|
|
590
|
+
|
|
574
591
|
/**
|
|
575
592
|
* This function gives the inline form of the source of an arrow function. The body of the function must be an
|
|
576
593
|
* expression of operators, numbers, its parameters and the functions of `CALLS`. Such a body cannot throw for primitive
|
|
@@ -588,7 +605,7 @@ function inlineForm(src: string): InlineForm | undefined {
|
|
|
588
605
|
const split = (m[2] as string).split(/([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)?)/);
|
|
589
606
|
for (const [i, t] of split.entries()) {
|
|
590
607
|
if (i % 2 === 0) {
|
|
591
|
-
if (
|
|
608
|
+
if (!isTokens(t) || /\+\+|--|\)\s*\(/.test(t)) return undefined;
|
|
592
609
|
text += t;
|
|
593
610
|
} else if (CALLS.has(t)) text += t;
|
|
594
611
|
else {
|