efront 4.1.12 → 4.1.13
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/#/345/233/275/351/231/205/345/214/226.yml +3 -0
- package/coms/basic/assert.js +9 -6
- package/coms/compile/Javascript.js +11 -0
- package/coms/compile/common.js +40 -8
- package/coms/compile/common_test.js +25 -1
- package/coms/zimoli/back.xht +4 -2
- package/coms/zimoli/render.js +2 -1
- package/package.json +1 -1
- package/public/efront.js +1 -1
package/coms/basic/assert.js
CHANGED
|
@@ -4,12 +4,14 @@ var dump = function (a, msg) {
|
|
|
4
4
|
else if (msg) console.log(msg + ":", a);
|
|
5
5
|
else console.log(a);
|
|
6
6
|
};
|
|
7
|
-
var colorString = function (s,
|
|
7
|
+
var colorString = function (s, color1, e, color2) {
|
|
8
8
|
s = String(s);
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
e = String(e);
|
|
10
|
+
var [c0, c1] = color1;
|
|
11
|
+
var [r0, r1] = color2;
|
|
12
|
+
if (s.indexOf(c1) === 0 && e.indexOf(r1) === 0) s = s.slice(c1.length);
|
|
11
13
|
else s = c0 + s;
|
|
12
|
-
if (s.lastIndexOf(c0) === s.length - c0.length) {
|
|
14
|
+
if (s.lastIndexOf(c0) === s.length - c0.length && e.lastIndexOf(r0) === e.length - r0.length) {
|
|
13
15
|
s = s.slice(0, s.length - c0.length);
|
|
14
16
|
}
|
|
15
17
|
else s += c1;
|
|
@@ -29,8 +31,9 @@ var assert = function (result, expect, log = dump) {
|
|
|
29
31
|
mark.setTag1(color1[1], color1[0]);
|
|
30
32
|
mark.setTag2(color2[1], color2[0]);
|
|
31
33
|
var [r, e] = mark.pair(result, expect);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
var s = r;
|
|
35
|
+
r = colorString(r, color1, e, color2);
|
|
36
|
+
e = colorString(e, color2, s, color1);
|
|
34
37
|
errors = `${color3[0]}结果 ${color3[1]}${r}\r\n ${color3[0]}应为 ${color3[1]}${e}\r\n`;
|
|
35
38
|
};
|
|
36
39
|
return function (error) {
|
|
@@ -386,6 +386,17 @@ Javascript.prototype.setType = function (o) {
|
|
|
386
386
|
if (o.type === STAMP) {
|
|
387
387
|
if (!last || last.type & (STAMP | STRAP) || last.type === SCOPED && /^[\{\[]$/.test(last.entry) && !last.isExpress) {
|
|
388
388
|
o.unary = /^[^=;,\*]$|.[^\=\>\<\|\&\^]$/.test(o.text);
|
|
389
|
+
if (o.unary && last && last.type === STAMP && /^(\+\+|\-\-)$/.test(last.text)) o.unary = !/^[\+\-]$/.test(o.text);
|
|
390
|
+
}
|
|
391
|
+
if (last && /^(\+\+|\-\-)$/.test(o.text)) {
|
|
392
|
+
var i = 1;
|
|
393
|
+
var p = queue[queue.length - i];
|
|
394
|
+
if (p === o) p = queue[queue.length - ++i];
|
|
395
|
+
while (p && p.type & (SPACE | COMMENT)) {
|
|
396
|
+
if (p.type === SPACE && /[\r\n\u2028\u2029]/.test(p.text)) break;
|
|
397
|
+
p = queue[queue.length - ++i];
|
|
398
|
+
}
|
|
399
|
+
o.unary = !p || p.type & (SPACE | STAMP | STRAP) || p.type === EXPRESS && p.prev && p.prev.type === STAMP && /^(\+\+|\-\-)$/.test(p.prev.text) && p.prev.unary;
|
|
389
400
|
}
|
|
390
401
|
}
|
|
391
402
|
};
|
package/coms/compile/common.js
CHANGED
|
@@ -122,7 +122,7 @@ var skipAssignment = function (o, cx) {
|
|
|
122
122
|
break;
|
|
123
123
|
case STRAP:
|
|
124
124
|
if (needpunc) {
|
|
125
|
-
if (!/^(in|instanceof|of|else|as)$/.test(o.text)) break loop;
|
|
125
|
+
if (!/^(in|instanceof|of|else|as|from)$/.test(o.text)) break loop;
|
|
126
126
|
if (o.text === 'else') {
|
|
127
127
|
if (!ifdeep) break loop;
|
|
128
128
|
ifdeep--;
|
|
@@ -227,6 +227,10 @@ function snapSentenceHead(o) {
|
|
|
227
227
|
o = p;
|
|
228
228
|
continue;
|
|
229
229
|
}
|
|
230
|
+
if (o.type === STRAP && /^(in|instanceof|of|as|from)$/.test(o.text)) {
|
|
231
|
+
o = p;
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
230
234
|
break;
|
|
231
235
|
}
|
|
232
236
|
if (p.type & (VALUE | QUOTED)) {
|
|
@@ -257,10 +261,24 @@ function snapSentenceHead(o) {
|
|
|
257
261
|
o = p;
|
|
258
262
|
continue;
|
|
259
263
|
}
|
|
260
|
-
if (/^(in|instanceof)$/.test(p.text)) {
|
|
264
|
+
if (/^(in|instanceof|of|as|from)$/.test(p.text)) {
|
|
261
265
|
o = p.prev;
|
|
262
266
|
continue;
|
|
263
267
|
}
|
|
268
|
+
if (/^(return|yield|break|continue)$/.test(p.text)) {
|
|
269
|
+
if (p.isend) break;
|
|
270
|
+
o = p;
|
|
271
|
+
if (p.text === 'yield') continue;
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
if (/^import$/.test(p.text)) {
|
|
275
|
+
if (o.type === SCOPED && o.entry === '(') {
|
|
276
|
+
o = p;
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
o = p;
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
264
282
|
break;
|
|
265
283
|
}
|
|
266
284
|
if (p.type === STAMP) {
|
|
@@ -274,9 +292,21 @@ function snapSentenceHead(o) {
|
|
|
274
292
|
}
|
|
275
293
|
}
|
|
276
294
|
if (/^(?:[!~]|\+\+|\-\-)$/.test(p.text)) {
|
|
295
|
+
if (!p.unary) {
|
|
296
|
+
if (o.type === STAMP && !o.unary || o.type === STRAP && /^(in|instanceof|of|as|from)$/.test(o.text)) {
|
|
297
|
+
o = p;
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
277
302
|
o = p;
|
|
278
303
|
continue;
|
|
279
304
|
}
|
|
305
|
+
var pp = p.prev;
|
|
306
|
+
if (pp.type === STAMP && /^(\+\+|\-\-)$/.test(pp.text) && pp.prev) {
|
|
307
|
+
o = pp.prev;
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
280
310
|
o = p.prev;
|
|
281
311
|
continue;
|
|
282
312
|
}
|
|
@@ -966,7 +996,7 @@ var hasBreakBetween = function (prev, next) {
|
|
|
966
996
|
};
|
|
967
997
|
var getSemicolonBetween = function (prev, next) {
|
|
968
998
|
if (next.type === PROPERTY) return ";";
|
|
969
|
-
if (next.type === STAMP && next.text === "*") return ";";
|
|
999
|
+
if (next.type === STAMP && next.text === "*" && next.next && next.next.type === PROPERTY) return ";";
|
|
970
1000
|
if (
|
|
971
1001
|
(EXPRESS | VALUE | QUOTED) & prev.type
|
|
972
1002
|
|| prev.type === STAMP && /^(\+\+|\-\-)$/.test(prev.text)
|
|
@@ -1129,11 +1159,13 @@ var createString = function (parsed) {
|
|
|
1129
1159
|
if (autospace) if (!prev.unary || /[\+\-]$/.test(prev.text) && prev.text === o.text) result.push(" ");
|
|
1130
1160
|
}
|
|
1131
1161
|
else if (/^(\+\+|\-\-)$/.test(o.prev.text) && o.prev.prev) {
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1162
|
+
if (o.unary) {
|
|
1163
|
+
var prev_prev = o.prev.prev;
|
|
1164
|
+
if (
|
|
1165
|
+
prev_prev.type === STRAP && !prev_prev.isExpress
|
|
1166
|
+
|| prev_prev.type & (EXPRESS | VALUE)
|
|
1167
|
+
) result.push(";");
|
|
1168
|
+
}
|
|
1137
1169
|
}
|
|
1138
1170
|
|
|
1139
1171
|
else if (o.text === '*') {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
function testPickSentence(text, index, except) {
|
|
2
|
-
var
|
|
2
|
+
var js = new Javascript;
|
|
3
|
+
js.defaultType = common.STRAP;
|
|
4
|
+
var code = scanner2(text, js);
|
|
3
5
|
assert(common.createString(common.pickSentence(code[index])), except);
|
|
4
6
|
}
|
|
5
7
|
testPickSentence(`function 九尾妖狐(){}`, 0, "function 九尾妖狐() {}")
|
|
@@ -10,3 +12,25 @@ testPickSentence(`a: function 九尾妖狐(){}`, 2, "a: function 九尾妖狐()
|
|
|
10
12
|
testPickSentence(`a: 王天霸, 步惊云 b:叶流云, 四顾剑`, 2, "a: 王天霸, 步惊云")
|
|
11
13
|
testPickSentence(`a: 王天霸, 步惊云 b:叶流云, 四顾剑`, 4, "b: 叶流云, 四顾剑")
|
|
12
14
|
testPickSentence(`a: 王天霸, 步惊云; b:叶流云, 四顾剑`, 4, "a: 王天霸, 步惊云")
|
|
15
|
+
testPickSentence(`return a`, 1, "return a")
|
|
16
|
+
testPickSentence(`a=yield 1`, 3, "a = yield 1")
|
|
17
|
+
testPickSentence(`return a=yield 1`, 3, "return a = yield 1")
|
|
18
|
+
testPickSentence(`if(a)return a=yield 1`, 6, "return a = yield 1")
|
|
19
|
+
testPickSentence(`if(a)return\r\na=yield 1`, 6, "a = yield 1")
|
|
20
|
+
testPickSentence(`if(a)return\r\na=yield 1`, 3, "return\r\n")
|
|
21
|
+
testPickSentence(`if(a)import(a)`, 3, "import(a)")
|
|
22
|
+
testPickSentence(`import(b)import(a)`, 3, "import(a)")
|
|
23
|
+
testPickSentence(`1+import(a)`, 3, "1 + import(a)")
|
|
24
|
+
testPickSentence(`1+await import(a)`, 3, "1 + await import(a)")
|
|
25
|
+
testPickSentence(`a as b`, 2, "a as b")
|
|
26
|
+
testPickSentence(`a of b`, 2, "a of b")
|
|
27
|
+
testPickSentence(`a in b`, 2, "a in b")
|
|
28
|
+
testPickSentence(`a instanceof b`, 2, "a instanceof b")
|
|
29
|
+
testPickSentence(`import a from b`, 3, "import a from b")
|
|
30
|
+
testPickSentence(`1+2+3`, 3, "1 + 2 + 3")
|
|
31
|
+
testPickSentence(`1+2+3`, 2, "1 + 2 + 3")
|
|
32
|
+
testPickSentence(`a+b+ ++c`, 5, "a + b + ++c")
|
|
33
|
+
testPickSentence(`a+b\r\n++c`, 5, "++c")
|
|
34
|
+
testPickSentence(`a+b++\r\nc`, 5, "c")
|
|
35
|
+
testPickSentence(`a+b++\r\nc`, 5, "c")
|
|
36
|
+
testPickSentence(`a+b++\r\n+c`, 6, "a + b++\r\n+ c")
|
package/coms/zimoli/back.xht
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
<back onclick="history.back()">
|
|
2
|
-
<i></i><span
|
|
2
|
+
<i></i><span>${i18n`返回`}</span>
|
|
3
3
|
</back>
|
|
4
4
|
<style>
|
|
5
5
|
i:before {
|
|
6
6
|
content: "‹";
|
|
7
|
-
font-size:
|
|
7
|
+
font-size: 26px;
|
|
8
|
+
font-family: Arial, Helvetica, sans-serif;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
i {
|
|
@@ -13,6 +14,7 @@
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
span {
|
|
17
|
+
text-transform: capitalize;
|
|
16
18
|
font-size: 14px;
|
|
17
19
|
margin-left: 10px;
|
|
18
20
|
margin-top: -10px;
|
package/coms/zimoli/render.js
CHANGED