efront 4.5.18 → 4.6.3
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 +21 -0
- package/coms/compile/Javascript.js +1 -1
- package/coms/compile/audit.js +64 -0
- package/coms/compile/audit_test.js +2 -0
- package/coms/compile/common.js +10 -9
- package/coms/compile/unstruct.js +22 -21
- package/coms/compile/unstruct_test.js +8 -4
- package/coms/docs/codecolor.js +94 -0
- package/coms/docs/codetext.xht +9 -99
- package/coms/docs/helps.js +2 -1
- package/coms/reptile/colors.js +29 -0
- package/package.json +1 -1
- package/public/efront.js +1 -1
- package/readme-en.md +2 -2
- package/readme.md +19 -19
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
- zh-CN: 文件$1中暂未发现已记录的问题
|
|
2
|
+
en: No recorded issues have been found in file $1 yet
|
|
3
|
+
|
|
4
|
+
- zh-CN: 建议
|
|
5
|
+
en: proposal
|
|
6
|
+
|
|
7
|
+
- zh-CN: 改为
|
|
8
|
+
en: Change to
|
|
9
|
+
|
|
10
|
+
- zh-CN: 检查文件或文件夹中的易错语法
|
|
11
|
+
en: Check for error prone syntax in files or folders
|
|
12
|
+
|
|
13
|
+
- zh-CN: 发现错误代码:$1
|
|
14
|
+
en: "Error code found: $1"
|
|
15
|
+
|
|
16
|
+
- zh-CN: "If you are an English user, please switch to nodejs21.2 or above to display in English"
|
|
17
|
+
en: "If you are an English user, please switch to nodejs21.2 or above to display in English"
|
|
18
|
+
|
|
19
|
+
- zh-CN: 当前nodejs版本过低,请更换到nodejs12或以上版本使用
|
|
20
|
+
en: The current nodejs version is too low. Please switch to nodejs12 or higher to use it
|
|
21
|
+
|
|
1
22
|
- zh-CN: 共$1个不同的项
|
|
2
23
|
en: A total of $1 different items
|
|
3
24
|
|
|
@@ -29,6 +29,7 @@ const {
|
|
|
29
29
|
replace,
|
|
30
30
|
skipAssignment,
|
|
31
31
|
insertAfter,
|
|
32
|
+
pickSentence,
|
|
32
33
|
unshort,
|
|
33
34
|
} = require("./common");
|
|
34
35
|
var straps = `if,in,do,as,of
|
|
@@ -345,7 +346,6 @@ Javascript.prototype.setType = function (o) {
|
|
|
345
346
|
if (this.detectLabel(o)) return false;
|
|
346
347
|
var last = o.prev;
|
|
347
348
|
if (o.type === EXPRESS && /^\.[^\.]|^\.$/.test(o.text) && last && last.type === STAMP && last.text === "?") {
|
|
348
|
-
last = o.prev = snapExpressHead(last.prev);
|
|
349
349
|
last.type = EXPRESS;
|
|
350
350
|
return false;
|
|
351
351
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var { STAMP, STRAP, createString } = require("./common");
|
|
2
|
+
var suggest = {
|
|
3
|
+
"while($2[$1++]!==$3)": "while($1<$2.length&&$2[$1++]!==$3)",
|
|
4
|
+
"while($2[$1]!==$3)$1++": "while($1<$2.length&&$2[$1]!==$3)$1++"
|
|
5
|
+
};
|
|
6
|
+
var roles = Object.keys(suggest).map(s => {
|
|
7
|
+
var r = scanner2(s);
|
|
8
|
+
var { used, envs } = r;
|
|
9
|
+
for (var k in envs) {
|
|
10
|
+
used[k].forEach(f => {
|
|
11
|
+
f.suggest = /^\$\d+$/.test(f.text) ? f.text : null;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
r.suggest = scanner2(suggest[s]);
|
|
15
|
+
return r;
|
|
16
|
+
});
|
|
17
|
+
var match = function (role, c, nameMap = {}) {
|
|
18
|
+
var temp = role.first;
|
|
19
|
+
var matched = [];
|
|
20
|
+
while (temp) {
|
|
21
|
+
if (!c || c.type !== temp.type) return;
|
|
22
|
+
if (temp.suggest) {
|
|
23
|
+
var name = temp.suggest;
|
|
24
|
+
if (name in nameMap) {
|
|
25
|
+
if (nameMap[name] !== c.text) return;
|
|
26
|
+
}
|
|
27
|
+
else nameMap[name] = c.text;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
if (temp.entry !== c.entry && temp.leave !== c.leave && temp.text !== c.text) return;
|
|
31
|
+
if (temp.length) {
|
|
32
|
+
if (temp.length !== c.length) return;
|
|
33
|
+
if (!match(temp, c.first, nameMap)) return;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
temp = temp.next;
|
|
37
|
+
matched.push(c);
|
|
38
|
+
c = c.next;
|
|
39
|
+
}
|
|
40
|
+
if (role.suggest) {
|
|
41
|
+
var { used } = role.suggest;
|
|
42
|
+
for (var k in nameMap) {
|
|
43
|
+
if (used[k]) patchlist('', used[k], nameMap[k]);
|
|
44
|
+
}
|
|
45
|
+
matched.suggest = createString(role.suggest);
|
|
46
|
+
}
|
|
47
|
+
return matched;
|
|
48
|
+
}
|
|
49
|
+
var audit = function (code) {
|
|
50
|
+
var checked = [];
|
|
51
|
+
for (var r of roles) {
|
|
52
|
+
var rest = [code];
|
|
53
|
+
while (rest.length) {
|
|
54
|
+
var c = rest.pop();
|
|
55
|
+
if (c.length) {
|
|
56
|
+
rest.push.apply(rest, c);
|
|
57
|
+
}
|
|
58
|
+
var m = match(r, c);
|
|
59
|
+
if (!m) continue;
|
|
60
|
+
checked.push(m);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return checked;
|
|
64
|
+
};
|
package/coms/compile/common.js
CHANGED
|
@@ -16,6 +16,7 @@ const [
|
|
|
16
16
|
// --------------//1//2/////////////////////////22/////////////2//2//3//4/////4////////3/////3//////3//3//////3///////211/////////////2//////2//////1///
|
|
17
17
|
var number_reg = /^(?:(?:0x[0-9a-f]+|0b\d+|0o\d+)(?:_[0-9a-f]+)*|(?:(?:(?:\d+_)*\d+|\d*)\.\d+(?:_\d+)*|(?:\d+_)*\d+\.?))(?:e[\+\-]?\d+(?:_\d+)*|[mniul]|ll)?$/i;
|
|
18
18
|
var equal_reg = /^(?:[\+\-\*\/~\^&\|%]|\*\*|>>>?|<<)?\=$|^(?:\+\+|\-\-)$/;
|
|
19
|
+
var needhead_reg = /^\?\.|^\.[^\.]|^\[/;
|
|
19
20
|
var skipAssignment = function (o, cx) {
|
|
20
21
|
if (!o) return;
|
|
21
22
|
var next = arguments.length === 1 ? function () {
|
|
@@ -100,7 +101,7 @@ var skipAssignment = function (o, cx) {
|
|
|
100
101
|
next();
|
|
101
102
|
break;
|
|
102
103
|
case EXPRESS:
|
|
103
|
-
if (
|
|
104
|
+
if (needhead_reg.test(o.text)) {
|
|
104
105
|
next();
|
|
105
106
|
break;
|
|
106
107
|
}
|
|
@@ -344,7 +345,7 @@ var snapExpressHead = function (o) {
|
|
|
344
345
|
if (h) return h;
|
|
345
346
|
}
|
|
346
347
|
if (o.type === SCOPED && o.entry !== '{'
|
|
347
|
-
|| o.type === EXPRESS &&
|
|
348
|
+
|| o.type === EXPRESS && needhead_reg.test(o.text)
|
|
348
349
|
|| /\.$/.test(p.text) && !p.isdigit
|
|
349
350
|
|| o.type === QUOTED && (o.length || /^\`/.test(o.text))
|
|
350
351
|
) {
|
|
@@ -416,7 +417,7 @@ var snapExpressFoot = function (o) {
|
|
|
416
417
|
if (!n) break;
|
|
417
418
|
if (n.type === SCOPED && (o.entry !== '{' || isExpress)
|
|
418
419
|
|| /\.$/.test(o.text) && !o.isdigit
|
|
419
|
-
|| n.type === EXPRESS &&
|
|
420
|
+
|| n.type === EXPRESS && needhead_reg.test(n.text)
|
|
420
421
|
|| n.type === QUOTED && (n.length || /^\`/.test(n.text))
|
|
421
422
|
) {
|
|
422
423
|
o = n;
|
|
@@ -1063,7 +1064,7 @@ var createString = function (parsed) {
|
|
|
1063
1064
|
|| prev.type === STAMP && !prev.unary
|
|
1064
1065
|
) {
|
|
1065
1066
|
if (intag || prev.type === ELEMENT && o.type === ELEMENT) break a;
|
|
1066
|
-
if (o.type !== EXPRESS ||
|
|
1067
|
+
if (o.type !== EXPRESS || !needhead_reg.test(o.text) && !prev.tag && !o.tag) {
|
|
1067
1068
|
result.push(" ");
|
|
1068
1069
|
lasttype = SPACE
|
|
1069
1070
|
}
|
|
@@ -1192,7 +1193,7 @@ var createString = function (parsed) {
|
|
|
1192
1193
|
break;
|
|
1193
1194
|
default:
|
|
1194
1195
|
if (o && typeof o === "object") {
|
|
1195
|
-
if (intag || o.
|
|
1196
|
+
if (intag || o.type === EXPRESS && (needhead_reg.test(o.text) || o.prev?.type === EXPRESS && /\.$/.test(o.prev.text)));
|
|
1196
1197
|
else if ((STRAP | EXPRESS | PROPERTY | COMMENT | VALUE) & lasttype && (STRAP | EXPRESS | PROPERTY | VALUE | LABEL) & o.type) {
|
|
1197
1198
|
if (autospace) result.push(" ");
|
|
1198
1199
|
}
|
|
@@ -1484,7 +1485,7 @@ var unshort = function (o, text) {
|
|
|
1484
1485
|
o.type = EXPRESS;
|
|
1485
1486
|
delete o.short;
|
|
1486
1487
|
};
|
|
1487
|
-
var
|
|
1488
|
+
var getBodyWith = function (o, k) {
|
|
1488
1489
|
var q = o.queue;
|
|
1489
1490
|
while (q && (!q.scoped || !q.scoped.used[k])) q = q.queue;
|
|
1490
1491
|
return q;
|
|
@@ -1493,13 +1494,13 @@ var getScopeWith = function (o, k) {
|
|
|
1493
1494
|
var patchArrawScope = function (arraw, origin) {
|
|
1494
1495
|
var s1 = createScoped(arraw);
|
|
1495
1496
|
if (s1.used.this) {
|
|
1496
|
-
var s =
|
|
1497
|
+
var s = getBodyWith(origin, 'this').scoped;
|
|
1497
1498
|
s.used.this.push(...s1.used.this);
|
|
1498
1499
|
s.insett = true;
|
|
1499
1500
|
}
|
|
1500
1501
|
if (s1.used.arguments) {
|
|
1501
1502
|
s.inseta = true;
|
|
1502
|
-
var s =
|
|
1503
|
+
var s = getBodyWith(origin, 'arguments').scoped;
|
|
1503
1504
|
s.used.arguments.push(...s1.used.arguments);
|
|
1504
1505
|
};
|
|
1505
1506
|
};
|
|
@@ -1522,7 +1523,7 @@ module.exports = {
|
|
|
1522
1523
|
unshort,
|
|
1523
1524
|
skipAssignment,
|
|
1524
1525
|
getDeclared,
|
|
1525
|
-
|
|
1526
|
+
getBodyWith,
|
|
1526
1527
|
patchArrawScope,
|
|
1527
1528
|
remove,
|
|
1528
1529
|
createString,
|
package/coms/compile/unstruct.js
CHANGED
|
@@ -63,7 +63,7 @@ var _break = function (body, cx, result, iscontinue) {
|
|
|
63
63
|
var _try = function (body, cx, unblock, result, getname) {
|
|
64
64
|
var o = body[cx];
|
|
65
65
|
o = o.next;
|
|
66
|
-
while (body[cx++] !== o);
|
|
66
|
+
while (cx < body.length && body[cx++] !== o);
|
|
67
67
|
var trystart = stepReturn(0, 7);
|
|
68
68
|
var tse = trystart[trystart.length - 1];
|
|
69
69
|
pushstep(result, trystart);
|
|
@@ -109,7 +109,7 @@ var evals = [];
|
|
|
109
109
|
var _with = function (body, cx, unblock, result, getname) {
|
|
110
110
|
var o = body[cx];
|
|
111
111
|
var c = o.next;
|
|
112
|
-
while (body[cx] !== c) cx++;
|
|
112
|
+
while (cx < body.length && body[cx] !== c) cx++;
|
|
113
113
|
var qs = ternary(c, getname, true);
|
|
114
114
|
for (var q of qs) if (q.length) pushstep(result, q);
|
|
115
115
|
evals.push(q.name);
|
|
@@ -152,12 +152,12 @@ var _switch = function (body, cx, unblock, result, getname) {
|
|
|
152
152
|
var q = qt[qt.length - 1];
|
|
153
153
|
var qn = q.name;
|
|
154
154
|
o = o.next;
|
|
155
|
-
while (body[cx++] !== o);
|
|
155
|
+
while (cx < body.length && body[cx++] !== o);
|
|
156
156
|
if (!o) return;
|
|
157
157
|
var cy = 0;
|
|
158
158
|
var m = o.first;
|
|
159
159
|
var tmp = [];
|
|
160
|
-
while (o[cy] !== m) cy++;
|
|
160
|
+
while (cy < o.length && o[cy] !== m) cy++;
|
|
161
161
|
var default_ = null, case_ = null;
|
|
162
162
|
var cbindex = 0, cblength = 0;
|
|
163
163
|
while (cy < o.length) {
|
|
@@ -238,7 +238,7 @@ var _for = function (body, cx, unblock, result) {
|
|
|
238
238
|
var dx = cx;
|
|
239
239
|
var n = o.next;
|
|
240
240
|
if (n && n.type === SCOPED && n.entry === '(') n = n.next;
|
|
241
|
-
while (body[dx] !== n) dx++;
|
|
241
|
+
while (dx < body.length && body[dx] !== n) dx++;
|
|
242
242
|
var forin = body.slice(cx, dx);
|
|
243
243
|
var block = getblock(body, dx);
|
|
244
244
|
forin.push(...block);
|
|
@@ -246,7 +246,7 @@ var _for = function (body, cx, unblock, result) {
|
|
|
246
246
|
return dx + block.length + 1;
|
|
247
247
|
}
|
|
248
248
|
var cy = 0;
|
|
249
|
-
while (o[cy] !== m) cy++;
|
|
249
|
+
while (cy < o.length && o[cy] !== m) cy++;
|
|
250
250
|
var block = getblock(o, cy);// init
|
|
251
251
|
cy += block.length + 1;
|
|
252
252
|
unblock(block);
|
|
@@ -254,7 +254,7 @@ var _for = function (body, cx, unblock, result) {
|
|
|
254
254
|
var block1 = getblock(o, cy);// condition
|
|
255
255
|
cy += block1.length + 1;
|
|
256
256
|
var block2 = getblock(o, cy);// next
|
|
257
|
-
while (body[cx] !== o) cx++;
|
|
257
|
+
while (cx < body.length && body[cx] !== o) cx++;
|
|
258
258
|
var block_ = getblock(body, ++cx);// body
|
|
259
259
|
cx += block_.length;
|
|
260
260
|
var c = result.length;
|
|
@@ -322,7 +322,7 @@ var _while = function (body, cx, unblock, result) {
|
|
|
322
322
|
ifpatch(result);
|
|
323
323
|
o.contat = result.length;
|
|
324
324
|
o = o.next;
|
|
325
|
-
while (body[cx] !== o) cx++;
|
|
325
|
+
while (cx < body.length && body[cx] !== o) cx++;
|
|
326
326
|
var i = result.length;
|
|
327
327
|
var b = rescan`if (${getCondition(o, unblock, true)}) return []`;
|
|
328
328
|
var be = b[b.length - 1];
|
|
@@ -436,7 +436,7 @@ var _do = function (body, cx, unblock, result) {
|
|
|
436
436
|
var b = rescan`if (${getCondition(o, unblock)}) return [${i - result.length}, 0]`;
|
|
437
437
|
pushstep(result, b);
|
|
438
438
|
b[b.length - 1][0].text = String(i - result.length + 1);
|
|
439
|
-
while (body[cx] !== o) cx++;
|
|
439
|
+
while (cx < body.length && body[cx] !== o) cx++;
|
|
440
440
|
return cx + 1;
|
|
441
441
|
};
|
|
442
442
|
var stepReturn = function (value, type, q) {
|
|
@@ -1303,16 +1303,19 @@ function toqueue(body, getname, ret = false, result = []) {
|
|
|
1303
1303
|
}
|
|
1304
1304
|
var elseif = false, isbr = false;
|
|
1305
1305
|
if (o.text === 'else') {
|
|
1306
|
-
while (body[cx] !== o.next) cx++;
|
|
1306
|
+
while (cx < body.length && body[cx] !== o.next) cx++;
|
|
1307
1307
|
o = o.next;
|
|
1308
|
+
if (!iftop) {
|
|
1309
|
+
throw new Error(i18n`发现错误代码:${`${createString(o.queue)}`}`);
|
|
1310
|
+
}
|
|
1308
1311
|
var ispbr = iftop[iftop.length - 3];
|
|
1309
|
-
if (!ispbr) ifpatch(result,
|
|
1312
|
+
if (!ispbr) ifpatch(result, iftop[0]);
|
|
1310
1313
|
isbr = isbreak(o);
|
|
1311
1314
|
iftop.push(result.length);
|
|
1312
1315
|
elseif = true;
|
|
1313
1316
|
}
|
|
1314
1317
|
if (o.text === 'if') {
|
|
1315
|
-
while (body[cx] !== o.next) cx++;
|
|
1318
|
+
while (cx < body.length && body[cx] !== o.next) cx++;
|
|
1316
1319
|
o = o.next;
|
|
1317
1320
|
var isbr = isbreak(o.next);
|
|
1318
1321
|
var i = result.length;
|
|
@@ -1335,22 +1338,20 @@ function toqueue(body, getname, ret = false, result = []) {
|
|
|
1335
1338
|
elseif = true;
|
|
1336
1339
|
}
|
|
1337
1340
|
if (elseif) {
|
|
1338
|
-
while (body[cx] !== o) cx++;
|
|
1341
|
+
while (cx < body.length && body[cx] !== o) cx++;
|
|
1339
1342
|
var block = getblock(body, cx);
|
|
1340
1343
|
cx += block.length;
|
|
1341
1344
|
o = body[cx];
|
|
1342
1345
|
while (o && o.type & (SPACE | COMMENT)) o = body[++cx];
|
|
1343
|
-
unblock(block);
|
|
1344
1346
|
if (o && o.type === STAMP && o.text === ';') o = o.next;
|
|
1345
1347
|
while (cx < body.length && body[cx] !== o) cx++;
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1348
|
+
var nextelse = !!o && o.type === STRAP && o.text === 'else';
|
|
1349
|
+
var blength = result.length;
|
|
1350
|
+
unblock(block);
|
|
1351
|
+
if (result.length > blength && nextelse) ifpatch(result, false);
|
|
1352
|
+
if (!nextelse) {
|
|
1353
|
+
if (!isbr) ifpatch(result, iftop[0]);
|
|
1352
1354
|
uniftop();
|
|
1353
|
-
if (inif) ifpatch(result, false);
|
|
1354
1355
|
iftop = null;
|
|
1355
1356
|
}
|
|
1356
1357
|
}
|
|
@@ -35,7 +35,7 @@ test('return a = b', "a = b; return [b, 2]", true);
|
|
|
35
35
|
test('a*a', "a * a", true);
|
|
36
36
|
test('a * a && b * c * c ** d', "_ = a * a; if (!_) return [1, 0]; _ = b * c, _0 = c ** d, _ * _0", true);
|
|
37
37
|
test('a * a || b * c * c ** d', "_ = a * a; if (_) return [1, 0]; _ = b * c, _0 = c ** d, _ * _0", true);
|
|
38
|
-
test('a * a ?? b * c * c ** d', "_ = a * a; if (_
|
|
38
|
+
test('a * a ?? b * c * c ** d', "_ = a * a; if (_ != null) return [1, 0]; _ = b * c, _0 = c ** d, _ * _0", true);
|
|
39
39
|
test('a * a && await b*c', "_ = a * a; if (!_) return [2, 0]; _ = b; return [_, 1];\r\n _ = @; _ * c", true);
|
|
40
40
|
test("await a", "_ = a; return [_, 1]", true);
|
|
41
41
|
test("yield a", "return [a, 3]", true);
|
|
@@ -54,7 +54,7 @@ test("await a, await b", "_ = a; return [_, 1];\r\n _ = @; _ = b; return [_, 1]"
|
|
|
54
54
|
test("await a * b, await b", "_ = a; return [_, 1];\r\n _ = @; _ * b; _ = b; return [_, 1]", true);
|
|
55
55
|
test("if(a);", "if (!a) return [1, 0]; return [1, 0]", true);
|
|
56
56
|
test("if(a) return a;", "if (a) return [a, 2]", true);
|
|
57
|
-
test("if(a) { if(b) return a;} else return d", "if (!a) return [
|
|
57
|
+
test("if(a) { if(b) return a;} else return d", "if (!a) return [1, 0]; if (b) return [a, 2]; return [2, 0];\r\n return [d, 2]", true);
|
|
58
58
|
test("if(a) return a; else return b", "if (a) return [a, 2]; return [b, 2]", true);
|
|
59
59
|
test("if(a) await b", "if (!a) return [2, 0]; _ = b; return [_, 1];\r\n _ = @; return [1, 0]", true);
|
|
60
60
|
test("if(a) await b; else await c", "if (!a) return [2, 0]; _ = b; return [_, 1];\r\n _ = @; return [3, 0];\r\n _ = c; return [_, 1];\r\n _ = @; return [1, 0]", true);
|
|
@@ -151,7 +151,11 @@ test(`c=b+ ++a`, "_ = ++a, c = b + _");
|
|
|
151
151
|
test(`c=b+ +a`, "_ = +a, c = b + _");
|
|
152
152
|
test(`c=b+ !a`, "_ = !a, c = b + _");
|
|
153
153
|
test(`do {var loadcount = 0;} while (loadcount !== 0);`, `loadcount = 0; _ = loadcount !== 0; if (_) return [0, 0]`);
|
|
154
|
-
unstruct.debug = true; r++;
|
|
155
154
|
test("if(a)try{a}catch{};a;", 'if (!a) return [4, 0]; return [1, 7];\r\n a; return [0, 9];\r\n return [1, 9];\r\n return [1, 0];\r\n a');
|
|
156
155
|
test("url = (o===void 0||o===null?void 0:o.url)", '_ = void 0, _ = o === _; if (_) return [1, 0]; _ = o === null;\r\n if (!_) return [1, 0]; _ = void 0; return [2, 0];\r\n _ = o.url; return [1, 0];\r\n url = _', true);
|
|
157
|
-
test("p ? (ishttps ? `https` : `http`).toUpperCase() + i18n`端口` + (ishttps ? ': ' : ': ') + p : ''","if (!p) return [1, 0]; if (!ishttps) return [1, 0]; _0 = `https`; return [2, 0];\r\n _0 = `http`; return [1, 0];\r\n _1 = _0.toUpperCase(); _ = _1 + i18n`端口`; if (!ishttps) return [1, 0]; _2 = ': '; return [2, 0];\r\n _2 = ': '; return [1, 0];\r\n _ = _ + _2, _ = _ + p; return [2, 0];\r\n ''; return [1, 0]")
|
|
156
|
+
test("p ? (ishttps ? `https` : `http`).toUpperCase() + i18n`端口` + (ishttps ? ': ' : ': ') + p : ''", "if (!p) return [1, 0]; if (!ishttps) return [1, 0]; _0 = `https`; return [2, 0];\r\n _0 = `http`; return [1, 0];\r\n _1 = _0.toUpperCase(); _ = _1 + i18n`端口`; if (!ishttps) return [1, 0]; _2 = ': '; return [2, 0];\r\n _2 = ': '; return [1, 0];\r\n _ = _ + _2, _ = _ + p; return [2, 0];\r\n ''; return [1, 0]")
|
|
157
|
+
unstruct.debug = true; r++;
|
|
158
|
+
r++// test("if(a)else {}",'')
|
|
159
|
+
test("if(a){if(b){c}d}else{e}", `if (!a) return [2, 0]; if (!b) return [1, 0]; c; return [1, 0];\r\n d; return [2, 0];\r\n e; return [1, 0]`)
|
|
160
|
+
test("if(a){if(b){c}else{d}}else{e}", `if (!a) return [3, 0]; if (!b) return [1, 0]; c; return [2, 0];\r\n d; return [1, 0];\r\n return [2, 0];\r\n e; return [1, 0]`)
|
|
161
|
+
test("if(a)switch(b){case c:d;break;} else{h}", `if (!a) return [3, 0]; if (b === c) return [1, 0]; return [2, 0];\r\n d; return [1, 0];\r\n return [2, 0];\r\n h; return [1, 0]`)
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
|
|
2
|
+
var { STRAP, SCOPED, ELEMENT, QUOTED, LABEL, COMMENT, STAMP, VALUE, EXPRESS, PROPERTY, PIECE } = compile$common;
|
|
3
|
+
var predefs = Object.create(null);
|
|
4
|
+
predefs.module = true;
|
|
5
|
+
predefs.exports = true;
|
|
6
|
+
predefs["module.exports"] = true;
|
|
7
|
+
predefs.Promise = true;
|
|
8
|
+
[Boolean, Number, String, Function, Object, Array, Date, RegExp, Error].forEach(p => predefs[p.name] = true);
|
|
9
|
+
var codecolor = function (c, encode) {
|
|
10
|
+
var envs = c.envs;
|
|
11
|
+
var deep = 0;
|
|
12
|
+
var setcolor = function (o) {
|
|
13
|
+
var text = o.text;
|
|
14
|
+
switch (o.type) {
|
|
15
|
+
case LABEL:
|
|
16
|
+
o.text = `<label>${o.text}</label>`;
|
|
17
|
+
break;
|
|
18
|
+
case QUOTED:
|
|
19
|
+
if (o.length || !o.text) {
|
|
20
|
+
o.forEach(setcolor);
|
|
21
|
+
o.entry = "<text>" + o.entry + "</text>";
|
|
22
|
+
o.leave = "<text>" + o.leave + "</text>";
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
case PIECE:
|
|
26
|
+
if (o.queue && o.queue.tag) {
|
|
27
|
+
o.text = encode(o.text);
|
|
28
|
+
}
|
|
29
|
+
else if (/^\//.test(o.text)) {
|
|
30
|
+
o.text = `<regexp>${encode(o.text)}</regexp>`;
|
|
31
|
+
}
|
|
32
|
+
else o.text = `<text>${encode(o.text)}</text>`;
|
|
33
|
+
break;
|
|
34
|
+
break;
|
|
35
|
+
case ELEMENT:
|
|
36
|
+
if (o.attributes) o.attributes.forEach(setcolor);
|
|
37
|
+
if (o.tag_entry) o.tag_entry = `<stamp>${encode(o.tag_entry)}</stamp>`;
|
|
38
|
+
if (o.tag_leave) o.tag_leave = `<stamp>${encode(o.tag_leave)}</stamp>`;
|
|
39
|
+
if (o.entry) o.entry = `<stamp>${encode(o.entry)}</stamp>`;
|
|
40
|
+
if (o.leave) o.leave = `<stamp>${encode(o.leave)}</stamp>`;
|
|
41
|
+
o.tag = `<label>${o.tag}</label>`;
|
|
42
|
+
o.forEach(setcolor);
|
|
43
|
+
break;
|
|
44
|
+
case SCOPED:
|
|
45
|
+
deep++;
|
|
46
|
+
o.forEach(setcolor);
|
|
47
|
+
deep--;
|
|
48
|
+
o.entry = `<deep${deep}>${o.entry}</deep${deep}>`;
|
|
49
|
+
o.leave = `<deep${deep}>${o.leave}</deep${deep}>`;
|
|
50
|
+
break;
|
|
51
|
+
case VALUE:
|
|
52
|
+
if (o.isdigit) o.text = `<digit>${o.text}</digit>`;
|
|
53
|
+
else o.text = `<value>${o.text}</value>`;
|
|
54
|
+
break;
|
|
55
|
+
case PROPERTY:
|
|
56
|
+
var next = o.next;
|
|
57
|
+
if (next && next.type === c.SCOPED && next.entry === '(') {
|
|
58
|
+
o.text = `<method>${o.text}</method>`;
|
|
59
|
+
}
|
|
60
|
+
else o.text = `<property>${o.text}</property>`;
|
|
61
|
+
|
|
62
|
+
break;
|
|
63
|
+
case EXPRESS:
|
|
64
|
+
var keys = o.text.split(".");
|
|
65
|
+
var next = o.next;
|
|
66
|
+
if (next && next.type === c.SCOPED && next.entry === '(') {
|
|
67
|
+
keys[keys.length - 1] = `<invoke>${keys[keys.length - 1]}</invoke>`;
|
|
68
|
+
}
|
|
69
|
+
var [name0] = text.split(".");
|
|
70
|
+
var [name] = keys;
|
|
71
|
+
if (/^</.test(name0));
|
|
72
|
+
else if (/^(arguments|this|super|Infinity|NaN)$/.test(name0)) name = `<strap>${name}</strap>`;
|
|
73
|
+
else if (name0 in envs) name = name0 in predefs ? `<predef>${name}</predef>` : `<outside>${name}</outside>`;
|
|
74
|
+
keys[0] = name;
|
|
75
|
+
o.text = keys.map(k => /^\</.test(k) || !k ? k : `<express>${k}</express>`).join(".");
|
|
76
|
+
break;
|
|
77
|
+
case STRAP:
|
|
78
|
+
if (/^(if|else|switch|case|do|while|for|break|continue|default|import|from|as|export|try|catch|finally|throw|await|yield|return)$/.test(text))
|
|
79
|
+
o.text = `<flow>${o.text}</flow>`;
|
|
80
|
+
else o.text = `<strap>${o.text}</strap>`;
|
|
81
|
+
break;
|
|
82
|
+
case STAMP:
|
|
83
|
+
if (/^(=>)$/.test(o.text) || o.text === "*" && o.prev && o.prev.type === c.STRAP) o.text = `<strap>${encode(o.text)}</strap>`;
|
|
84
|
+
// else if (!/^[<\/>]+$/.test(o.text));
|
|
85
|
+
// else o.text = `<stamp>${encode(o.text)}</stamp>`;
|
|
86
|
+
break;
|
|
87
|
+
case COMMENT:
|
|
88
|
+
o.text = `<comment>${encode(o.text)}</comment>`;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
c.forEach(setcolor);
|
|
93
|
+
|
|
94
|
+
}
|
package/coms/docs/codetext.xht
CHANGED
|
@@ -89,100 +89,6 @@
|
|
|
89
89
|
var encode = function (text) {
|
|
90
90
|
return text.replace(/[\<\>\|]/g, a => `&#${a.charCodeAt()};`)
|
|
91
91
|
};
|
|
92
|
-
var codecolor = function (c, blink) {
|
|
93
|
-
var envs = c.envs;
|
|
94
|
-
var predefs = Object.create(null);
|
|
95
|
-
predefs.module = true;
|
|
96
|
-
predefs.exports = true;
|
|
97
|
-
predefs["module.exports"] = true;
|
|
98
|
-
predefs.Promise = true;
|
|
99
|
-
[Boolean, Number, String, Function, Object, Array, Date, RegExp, Error].forEach(p => predefs[p.name] = true);
|
|
100
|
-
var { STRAP, SCOPED, ELEMENT, QUOTED, LABEL, COMMENT, STAMP, VALUE, EXPRESS, PROPERTY, PIECE } = c;
|
|
101
|
-
var deep = 0;
|
|
102
|
-
var setcolor = function (o) {
|
|
103
|
-
var text = o.text;
|
|
104
|
-
if (o.blink >= 0) o.text = o.text.slice(0, o.blink) + blink + o.text.slice(o.blink);
|
|
105
|
-
switch (o.type) {
|
|
106
|
-
case LABEL:
|
|
107
|
-
o.text = `<label>${o.text}</label>`;
|
|
108
|
-
break;
|
|
109
|
-
case QUOTED:
|
|
110
|
-
if (o.length || !o.text) {
|
|
111
|
-
o.forEach(setcolor);
|
|
112
|
-
o.entry = "<text>" + o.entry + "</text>";
|
|
113
|
-
o.leave = "<text>" + o.leave + "</text>";
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
case PIECE:
|
|
117
|
-
if (o.queue && o.queue.tag) {
|
|
118
|
-
o.text = encode(o.text);
|
|
119
|
-
}
|
|
120
|
-
else if (/^\//.test(o.text)) {
|
|
121
|
-
o.text = `<regexp>${encode(o.text)}</regexp>`;
|
|
122
|
-
}
|
|
123
|
-
else o.text = `<text>${encode(o.text)}</text>`;
|
|
124
|
-
break;
|
|
125
|
-
break;
|
|
126
|
-
case ELEMENT:
|
|
127
|
-
if (o.attributes) o.attributes.forEach(setcolor);
|
|
128
|
-
if (o.tag_entry) o.tag_entry = `<stamp>${encode(o.tag_entry)}</stamp>`;
|
|
129
|
-
if (o.tag_leave) o.tag_leave = `<stamp>${encode(o.tag_leave)}</stamp>`;
|
|
130
|
-
if (o.entry) o.entry = `<stamp>${encode(o.entry)}</stamp>`;
|
|
131
|
-
if (o.leave) o.leave = `<stamp>${encode(o.leave)}</stamp>`;
|
|
132
|
-
o.tag = `<label>${o.tag}</label>`;
|
|
133
|
-
o.forEach(setcolor);
|
|
134
|
-
break;
|
|
135
|
-
case SCOPED:
|
|
136
|
-
deep++;
|
|
137
|
-
o.forEach(setcolor);
|
|
138
|
-
deep--;
|
|
139
|
-
o.entry = `<deep${deep}>${o.entry}</deep${deep}>`;
|
|
140
|
-
o.leave = `<deep${deep}>${o.leave}</deep${deep}>`;
|
|
141
|
-
break;
|
|
142
|
-
case VALUE:
|
|
143
|
-
if (o.isdigit) o.text = `<digit>${o.text}</digit>`;
|
|
144
|
-
else o.text = `<value>${o.text}</value>`;
|
|
145
|
-
break;
|
|
146
|
-
case PROPERTY:
|
|
147
|
-
var next = o.next;
|
|
148
|
-
if (next && next.type === c.SCOPED && next.entry === '(') {
|
|
149
|
-
o.text = `<method>${o.text}</method>`;
|
|
150
|
-
}
|
|
151
|
-
else o.text = `<property>${o.text}</property>`;
|
|
152
|
-
|
|
153
|
-
break;
|
|
154
|
-
case EXPRESS:
|
|
155
|
-
var keys = o.text.split(".");
|
|
156
|
-
var next = o.next;
|
|
157
|
-
if (next && next.type === c.SCOPED && next.entry === '(') {
|
|
158
|
-
keys[keys.length - 1] = `<invoke>${keys[keys.length - 1]}</invoke>`;
|
|
159
|
-
}
|
|
160
|
-
var [name0] = text.split(".");
|
|
161
|
-
var [name] = keys;
|
|
162
|
-
if (/^</.test(name0));
|
|
163
|
-
else if (/^(arguments|this|super|Infinity|NaN)$/.test(name0)) name = `<strap>${name}</strap>`;
|
|
164
|
-
else if (name0 in envs) name = name0 in predefs ? `<predef>${name}</predef>` : `<outside>${name}</outside>`;
|
|
165
|
-
keys[0] = name;
|
|
166
|
-
o.text = keys.map(k => /^\</.test(k) || !k ? k : `<express>${k}</express>`).join(".");
|
|
167
|
-
break;
|
|
168
|
-
case STRAP:
|
|
169
|
-
if (/^(if|else|switch|case|do|while|for|break|continue|default|import|from|as|export|try|catch|finally|throw|await|yield|return)$/.test(text))
|
|
170
|
-
o.text = `<flow>${o.text}</flow>`;
|
|
171
|
-
else o.text = `<strap>${o.text}</strap>`;
|
|
172
|
-
break;
|
|
173
|
-
case STAMP:
|
|
174
|
-
if (/^(=>)$/.test(o.text) || o.text === "*" && o.prev && o.prev.type === c.STRAP) o.text = `<strap>${encode(o.text)}</strap>`;
|
|
175
|
-
// else if (!/^[<\/>]+$/.test(o.text));
|
|
176
|
-
// else o.text = `<stamp>${encode(o.text)}</stamp>`;
|
|
177
|
-
break;
|
|
178
|
-
case COMMENT:
|
|
179
|
-
o.text = `<comment>${encode(o.text)}</comment>`;
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
c.forEach(setcolor);
|
|
184
|
-
|
|
185
|
-
}
|
|
186
92
|
var typescript = new compile$Javascript;
|
|
187
93
|
typescript.straps = typescript.straps.concat("interface", "implements", "declare", "module", "readonly", "enum");
|
|
188
94
|
var js = new compile$Javascript;
|
|
@@ -196,24 +102,24 @@
|
|
|
196
102
|
if (index >= 0) {
|
|
197
103
|
var patched = patchBlink(c, index, blink);
|
|
198
104
|
}
|
|
199
|
-
codecolor(c,
|
|
105
|
+
codecolor(c, encode);
|
|
200
106
|
a = c.toString();
|
|
201
107
|
if (index >= 0 && !patched) a = blink + a;
|
|
202
108
|
return a;
|
|
203
109
|
},
|
|
204
110
|
typescript(a) {
|
|
205
111
|
var c = compile$scanner2(a, typescript);
|
|
206
|
-
codecolor(c);
|
|
112
|
+
codecolor(c, encode);
|
|
207
113
|
return c.toString();
|
|
208
114
|
},
|
|
209
115
|
html(a) {
|
|
210
116
|
var code = compile$scanner2(a, 'html');
|
|
211
117
|
var scoped = code.scoped;
|
|
212
|
-
codecolor(code);
|
|
118
|
+
codecolor(code, encode);
|
|
213
119
|
backEach(scoped.richNodes, n => {
|
|
214
120
|
if (n.isScript) {
|
|
215
121
|
var js = compile$scanner2(compile$common.createString(n));
|
|
216
|
-
codecolor(js);
|
|
122
|
+
codecolor(js, encode);
|
|
217
123
|
n.splice(0, n.length, ...js);
|
|
218
124
|
}
|
|
219
125
|
})
|
|
@@ -221,7 +127,7 @@
|
|
|
221
127
|
},
|
|
222
128
|
css(a) {
|
|
223
129
|
var c = compile$scanner2(a);
|
|
224
|
-
codecolor(c);
|
|
130
|
+
codecolor(c, encode);
|
|
225
131
|
return c.toString();
|
|
226
132
|
}
|
|
227
133
|
};
|
|
@@ -240,6 +146,7 @@
|
|
|
240
146
|
}
|
|
241
147
|
else {
|
|
242
148
|
c.blink = 0;
|
|
149
|
+
c.text = blink + c.text;
|
|
243
150
|
}
|
|
244
151
|
return true;
|
|
245
152
|
}
|
|
@@ -249,6 +156,8 @@
|
|
|
249
156
|
}
|
|
250
157
|
else {
|
|
251
158
|
c.blink = index - c.start;
|
|
159
|
+
c.text = c.text.slice(0, c.blink) + blink + c.text.slice(c.blink);
|
|
160
|
+
|
|
252
161
|
return true;
|
|
253
162
|
}
|
|
254
163
|
}
|
|
@@ -273,6 +182,7 @@
|
|
|
273
182
|
}
|
|
274
183
|
else {
|
|
275
184
|
p.blink = p.text.length;
|
|
185
|
+
p.text = p.text + blink;
|
|
276
186
|
}
|
|
277
187
|
return true;
|
|
278
188
|
}
|
package/coms/docs/helps.js
CHANGED
|
@@ -17,13 +17,14 @@ var helps = [
|
|
|
17
17
|
["a", i18n`在项目文件夹启动开发环境服务器`, "dev", "devs", "test", "dev|test HTTP_PORT", "dev|test HTTP_PORT HTTPS_PORT", "devs|tests HTTPS_PORT", "devs|tests HTTPS_PORT HTTP_PORT"],
|
|
18
18
|
["a", i18n`在当前文件夹启动服务器`, "server", "serve|serv|http HTTP_PORT HTTPS_PORT", "serve|serv|http HTTP_PORT", "https HTTPS_PORT HTTP_PORT", "https HTTPS_PORT", "HTTP_PORT HTTPS_PORT", "HTTP_PORT", ""],
|
|
19
19
|
["a", i18n`显示本机ip地址`, "ip", "-ip", "--ip"],
|
|
20
|
-
["q", i18n`编译项目`, "public", "publish", "build", "release"],
|
|
20
|
+
["q", i18n`编译项目`, "public", "publish", "build|release", "build|release APPNAME"],
|
|
21
21
|
["a", i18n`监测文件变化,自动编译更新的部分并输出到指定目录`, "watch"],
|
|
22
22
|
["a", i18n`关闭efront服务器`, "kill HTTP_PORT|HTTPS_PORT", "close HTTP_PORT|HTTPS_PORT"],
|
|
23
23
|
["a", i18n`连接一台efront服务器,取得连接号`, "link ADDRESS"],
|
|
24
24
|
["a", i18n`用一个连接号登录本机的efront服务器,接收并打印消息`, "care ADDRESS", "care ADDRESS LINKID"],
|
|
25
25
|
["a", i18n`向一个连接号发送消息`, "cast ADDRESS LINKID MESSAGE"],
|
|
26
26
|
["z", i18n`检查文件或文件夹中的外部变量`, "check FILEPATH"],
|
|
27
|
+
["z", i18n`检查文件或文件夹中的易错语法`, "audit FILEPATH"],
|
|
27
28
|
["q", i18n`执行按efront方式加载的代码`, "run CODEFILE", "CODEFILE"],
|
|
28
29
|
["z", i18n`查找含有指定的外部变量的文件`, "find VARIABLE", "find VARIABLE FILEPATH"],
|
|
29
30
|
["-", i18n`从指定路径创建压缩文件`, "pack PUBLIC_PATH PACKAGE_PATH"],
|