pacc 8.9.1 → 8.9.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/package.json +1 -1
- package/src/expression.mjs +10 -10
package/package.json
CHANGED
package/src/expression.mjs
CHANGED
|
@@ -18,7 +18,7 @@ export function parseOnly(input, context = {}) {
|
|
|
18
18
|
|
|
19
19
|
let node, token, value;
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
function advance() {
|
|
22
22
|
const next = input.next();
|
|
23
23
|
if (next.done) {
|
|
24
24
|
token = EOF;
|
|
@@ -28,9 +28,9 @@ export function parseOnly(input, context = {}) {
|
|
|
28
28
|
value = next.value[1];
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
}
|
|
31
|
+
}
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
function expect(expected) {
|
|
34
34
|
if (token !== expected) {
|
|
35
35
|
throw new Error(
|
|
36
36
|
`unexpected '${token?.str || token}' expecting '${expected.str}'`,
|
|
@@ -38,9 +38,9 @@ export function parseOnly(input, context = {}) {
|
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
40
|
advance();
|
|
41
|
-
}
|
|
41
|
+
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
function nud(last, left) {
|
|
44
44
|
switch (last) {
|
|
45
45
|
case OPEN_ROUND: {
|
|
46
46
|
const sequence = [];
|
|
@@ -86,9 +86,9 @@ export function parseOnly(input, context = {}) {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
return last;
|
|
89
|
-
}
|
|
89
|
+
}
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
function led(last, left) {
|
|
92
92
|
switch (last.type) {
|
|
93
93
|
case "infixr":
|
|
94
94
|
return ASTBinop(last, left, expression(last.precedence - 1));
|
|
@@ -134,9 +134,9 @@ export function parseOnly(input, context = {}) {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
return { token };
|
|
137
|
-
}
|
|
137
|
+
}
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
function expression(precedence) {
|
|
140
140
|
const last = token;
|
|
141
141
|
advance();
|
|
142
142
|
node = nud(last, node);
|
|
@@ -148,7 +148,7 @@ export function parseOnly(input, context = {}) {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
return node;
|
|
151
|
-
}
|
|
151
|
+
}
|
|
152
152
|
|
|
153
153
|
advance();
|
|
154
154
|
|