efront 4.10.1 → 4.10.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/coms/basic/sortRegister.js +16 -0
- package/coms/basic_/nullish_.js +1 -1
- package/coms/compile/Html.js +5 -1
- package/coms/compile/Javascript.js +68 -55
- package/coms/compile/Javascript_test.js +7 -5
- package/coms/compile/Program.js +200 -76
- package/coms/compile/autoenum.js +5 -0
- package/coms/compile/common.js +81 -47
- package/coms/compile/downLevel.js +131 -48
- package/coms/compile/downLevel_test.js +8 -2
- package/coms/compile/powermap.js +6 -23
- package/coms/compile/unstruct.js +8 -5
- package/coms/compile/unstruct_test.js +3 -3
- package/coms/docs/codecolor.js +23 -2
- package/coms/docs/codetext.xht +12 -2
- package/coms/maps/gaode.js +1 -1
- package/package.json +1 -1
- package/public/efront.js +1 -1
package/coms/compile/Program.js
CHANGED
|
@@ -15,11 +15,7 @@ const {
|
|
|
15
15
|
number_reg,
|
|
16
16
|
} = require("./common");
|
|
17
17
|
var combine = require("../basic/combine");
|
|
18
|
-
var
|
|
19
|
-
if (a.indexOf(b) >= 0) return -1;
|
|
20
|
-
if (b.indexOf(a) >= 0) return 1;
|
|
21
|
-
return 0;
|
|
22
|
-
};
|
|
18
|
+
var sortRegster = require("../basic/sortRegister");
|
|
23
19
|
var createQuotedMap = function (entry) {
|
|
24
20
|
var map = {};
|
|
25
21
|
var end = {};
|
|
@@ -83,6 +79,7 @@ try {
|
|
|
83
79
|
spaceDefined.pop();
|
|
84
80
|
spaceDefined.pop();
|
|
85
81
|
}
|
|
82
|
+
var powermap = require("./powermap");
|
|
86
83
|
class Program {
|
|
87
84
|
quotes = [
|
|
88
85
|
[/'/, /'/, /\\[\s\S]/],
|
|
@@ -105,20 +102,35 @@ class Program {
|
|
|
105
102
|
["[", "]"],
|
|
106
103
|
["{", "}"],
|
|
107
104
|
]
|
|
108
|
-
stamps = "
|
|
105
|
+
stamps = "/=+;|:?<>-!~%^&*,.".split("")
|
|
109
106
|
value_reg = /^(false|true|null)$/
|
|
110
107
|
number_reg = number_reg;
|
|
111
108
|
Code = Array;
|
|
112
|
-
|
|
109
|
+
powermap = powermap;
|
|
110
|
+
transive_reg = /^(new|var|let|const|yield|void|in|of|typeof|delete|case|return|await|default|instanceof|throw|extends|import|from)$/;
|
|
113
111
|
straps = "if,for".split(',');
|
|
114
112
|
forceend_reg = /^(return|break|continue)$/;
|
|
115
|
-
|
|
113
|
+
funcstrap_reg = /^(class|function|fn|func|async|interface|struct|enum|impl|pub)$/;
|
|
116
114
|
extends_reg = /^(extends|implements)$/;
|
|
117
|
-
|
|
115
|
+
structstrap_reg = /^(class|interface|struct|enum)$/;
|
|
116
|
+
control_reg = /^(if|else|switch|case|do|while|for|loop|break|continue|default|import|from|as|export|try|catch|finally|throw|await|yield|return)$/;
|
|
117
|
+
type_reg = /^(var|let|const|function|fn|func|class|interface|type|struct|enum|impl)$/;
|
|
118
118
|
spaces = spaceDefined;
|
|
119
119
|
nocase = false
|
|
120
120
|
keepspace = false;
|
|
121
121
|
lastIndex = 0
|
|
122
|
+
twain(o1, o2) {
|
|
123
|
+
if (o1.istype || o1.needle || o2.needle) return;
|
|
124
|
+
o2.istype = true;
|
|
125
|
+
}
|
|
126
|
+
compile2(s) {
|
|
127
|
+
return s.replace(/\\[\s\S]|[\[\]\(\)\{\}\+\.\*\?\$\^\|\\\/\s\?]/g, function (m) {
|
|
128
|
+
if (m.length > 1) {
|
|
129
|
+
return m;
|
|
130
|
+
}
|
|
131
|
+
return "\\" + m;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
122
134
|
compile(s) {
|
|
123
135
|
return s.replace(/\\[\s\S]|[\[\]\(\)\{\}\+\.\-\*\?\$\^\|\\\/ ]/g, function (m) {
|
|
124
136
|
if (m.length > 1) {
|
|
@@ -130,9 +142,11 @@ class Program {
|
|
|
130
142
|
createRegExp(source, g) {
|
|
131
143
|
source = source.map(s => {
|
|
132
144
|
if (s instanceof RegExp) return s.source;
|
|
133
|
-
if (s instanceof Array) return s.slice().
|
|
134
|
-
return this.
|
|
145
|
+
if (s instanceof Array) return s.slice().map(s => this.compile2(s));
|
|
146
|
+
return this.compile2(s);
|
|
135
147
|
});
|
|
148
|
+
source = [].concat(...source);
|
|
149
|
+
sortRegster(source);
|
|
136
150
|
var flag = this.nocase ? "i" : "";
|
|
137
151
|
var s = source.join("|");
|
|
138
152
|
if (g) return new RegExp(`${s}`, "g" + flag);
|
|
@@ -166,15 +180,16 @@ class Program {
|
|
|
166
180
|
var express_reg = this.express_reg;
|
|
167
181
|
var value_reg = this.value_reg;
|
|
168
182
|
var extends_reg = this.extends_reg;
|
|
169
|
-
var
|
|
183
|
+
var funcstrap_reg = this.funcstrap_reg;
|
|
170
184
|
var entry_reg = this.entry_reg;
|
|
185
|
+
var type_reg = this.type_reg;
|
|
171
186
|
var comment_entry = this.comment_entry;
|
|
172
187
|
var rowsOf = m => m.replace(/[^\r\n\u2028\u2029]+/g, ';').replace(/\r\n|\r|\n|\u2028|\u2029/g, ' ').replace(/;/g, '').length;
|
|
173
188
|
var setRows = m => {
|
|
174
189
|
row += rowsOf(m);
|
|
175
190
|
colstart = start + m.length - m.replace(/^[\s\S]*?([^\r\n\u2028\u2029]*)$/, '$1').length - 1;
|
|
176
191
|
};
|
|
177
|
-
var queue_push =
|
|
192
|
+
var queue_push = (scope) => {
|
|
178
193
|
if (scope.type & (SPACE | COMMENT | PIECE | QUOTED)) {
|
|
179
194
|
if (scope.text) setRows(scope.text);
|
|
180
195
|
}
|
|
@@ -196,7 +211,16 @@ class Program {
|
|
|
196
211
|
last = queue.last, scope.prev = last;
|
|
197
212
|
if (last) last.text = text.slice(last.start, last.end);
|
|
198
213
|
}
|
|
199
|
-
if (
|
|
214
|
+
if (queue.isClass && scope.isprop) scope.isend = false;
|
|
215
|
+
if (last) {
|
|
216
|
+
last.next = scope;
|
|
217
|
+
if (queue[queue.length - 1] === last && last.type === scope.type && last.type & (EXPRESS | PROPERTY)) {
|
|
218
|
+
this.twain(last, scope);
|
|
219
|
+
}
|
|
220
|
+
if (last.type === STAMP && last.text === "*") {
|
|
221
|
+
if (scope.type === STRAP) last.unary = false;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
200
224
|
queue.last = scope;
|
|
201
225
|
for (var cx = queue.length - 1; cx >= 0; cx--) {
|
|
202
226
|
var o = queue[cx];
|
|
@@ -208,22 +232,73 @@ class Program {
|
|
|
208
232
|
queue.push(scope);
|
|
209
233
|
};
|
|
210
234
|
var row = 1, colstart = -1;
|
|
211
|
-
var
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
235
|
+
var cache_stamp = null;
|
|
236
|
+
var powermap = this.powermap;
|
|
237
|
+
var push_stamp = function () {
|
|
238
|
+
var last = queue.last;
|
|
239
|
+
var o = cache_stamp;
|
|
240
|
+
if (last?.istype && last.prev?.isarg) {
|
|
241
|
+
o.unary = true;
|
|
242
|
+
}
|
|
243
|
+
else if (!last || last.type === STAMP && (!(last.text in powermap)) && !last.istype) {
|
|
244
|
+
if (!queue.istype && powermap[o.text] > powermap["="]) o.unary = true;
|
|
245
|
+
}
|
|
246
|
+
else if (last.type === STRAP && !last.isend || last.type === STAMP && !last.istype && !/^(\+\+|\-\-)$/.test(last.text) || last.type === SCOPED && /^[\{\[]$/.test(last.entry) && !last.isExpress) {
|
|
247
|
+
o.unary = /^[^=;,\:]$/.test(o.text);
|
|
248
|
+
if (o.unary && /^(\+|\-)$/.test(o.text) && last && last.type === STAMP && /^(\+\+|\-\-)$/.test(last.text)) o.unary = !!last.unary;
|
|
249
|
+
}
|
|
250
|
+
if (/^(\+\+|\-\-)$/.test(o.text)) {
|
|
251
|
+
var i = 1;
|
|
252
|
+
var p = queue[queue.length - i];
|
|
253
|
+
if (p === o) p = queue[queue.length - ++i];
|
|
254
|
+
while (p && p.type & (SPACE | COMMENT)) {
|
|
255
|
+
if (p.type === SPACE && /[\r\n\u2028\u2029]/.test(p.text)) break;
|
|
256
|
+
p = queue[queue.length - ++i];
|
|
224
257
|
}
|
|
258
|
+
o.unary = !p || p.type & (SPACE | STAMP | STRAP) || p.type === EXPRESS && p.prev && p.prev.type === STAMP && /^(\+\+|\-\-)$/.test(p.prev.text) && p.prev.unary;
|
|
225
259
|
}
|
|
226
260
|
|
|
261
|
+
if (!o.unary && /^(\.\.\.|\*)$/.test(o.text)) {
|
|
262
|
+
if (powermap[o.text] === powermap.new) o.unary = true;
|
|
263
|
+
if (last?.isarg || last?.isargl || last?.isprop) {
|
|
264
|
+
o.unary = true;
|
|
265
|
+
o.istype = true;
|
|
266
|
+
}
|
|
267
|
+
else if (queue.istype || o.isprop) o.unary = true;
|
|
268
|
+
else {
|
|
269
|
+
if (last?.isprop && !last.isend) o.unary = true;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (powermap[o.text] >= powermap["."]) {
|
|
273
|
+
o.needle = true;
|
|
274
|
+
}
|
|
275
|
+
if (o.needle);
|
|
276
|
+
else if (powermap[o.text] > powermap.new && !o.unary) {
|
|
277
|
+
o.needle = true;
|
|
278
|
+
}
|
|
279
|
+
queue_push(cache_stamp);
|
|
280
|
+
if (cache_stamp.istype && cache_stamp.unary && powermap[cache_stamp.text] == powermap[":"]) cache_stamp.unary = false;
|
|
281
|
+
if (cache_stamp === queue.last && cache_stamp.isExpress && cache_stamp.text in powermap && !cache_stamp.needle) queue.inExpress = true;
|
|
282
|
+
lasttype = cache_stamp.type;
|
|
283
|
+
cache_stamp = null;
|
|
284
|
+
}
|
|
285
|
+
var save = (type) => {
|
|
286
|
+
if (type === STAMP) {
|
|
287
|
+
if (cache_stamp) {
|
|
288
|
+
var stamp = cache_stamp.text;
|
|
289
|
+
if (!stamp) stamp = m;
|
|
290
|
+
else stamp += m;
|
|
291
|
+
if (stamp in powermap) {
|
|
292
|
+
cache_stamp.text = stamp;
|
|
293
|
+
cache_stamp.end = end;
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
push_stamp();
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
if (cache_stamp) push_stamp();
|
|
301
|
+
}
|
|
227
302
|
var scope = {
|
|
228
303
|
type,
|
|
229
304
|
start,
|
|
@@ -232,18 +307,23 @@ class Program {
|
|
|
232
307
|
col: start - colstart,
|
|
233
308
|
isExpress: queue.inExpress,
|
|
234
309
|
text: m
|
|
310
|
+
};
|
|
311
|
+
lasttype = type;
|
|
312
|
+
if (type === STAMP) {
|
|
313
|
+
cache_stamp = scope;
|
|
314
|
+
scope.prev = queue.last;
|
|
315
|
+
return;
|
|
235
316
|
}
|
|
236
317
|
if (type === STRAP) {
|
|
237
318
|
if (forceend_reg.test(m)) scope.isend = false, queue.inExpress = false;
|
|
238
|
-
if (this.transive_reg.test(m)) scope.transive = true, queue.inExpress = true;
|
|
239
319
|
}
|
|
240
320
|
if (isdigit) scope.isdigit = true;
|
|
241
|
-
lasttype = type;
|
|
242
321
|
queue_push(scope);
|
|
243
322
|
};
|
|
244
323
|
var space_exp = this.space_exp;
|
|
245
324
|
var scriptTags = this.scriptTags;
|
|
246
325
|
var ignoreTags = this.ignoreTags;
|
|
326
|
+
var structstrap_reg = this.structstrap_reg;
|
|
247
327
|
var openTag = function () {
|
|
248
328
|
var m1 = text.slice(start, match.index);
|
|
249
329
|
var s = space_exp.exec(m1);
|
|
@@ -346,6 +426,7 @@ class Program {
|
|
|
346
426
|
push_parents(scope);
|
|
347
427
|
};
|
|
348
428
|
var push_parents = function (scope) {
|
|
429
|
+
if (cache_stamp) push_stamp();
|
|
349
430
|
scope.queue = queue;
|
|
350
431
|
scope.prev = queue.last;
|
|
351
432
|
scope.row = row;
|
|
@@ -355,6 +436,7 @@ class Program {
|
|
|
355
436
|
lasttype = null;
|
|
356
437
|
}
|
|
357
438
|
var pop_parents = function () {
|
|
439
|
+
if (cache_stamp) push_stamp();
|
|
358
440
|
if (!parents.length) {
|
|
359
441
|
delete queue.end;
|
|
360
442
|
var last = queue.last;
|
|
@@ -383,6 +465,7 @@ class Program {
|
|
|
383
465
|
lasttype = scope.type;
|
|
384
466
|
}
|
|
385
467
|
var push_piece = function (index = match.index) {
|
|
468
|
+
if (cache_stamp) push_stamp();
|
|
386
469
|
if (index > start) {
|
|
387
470
|
var piece = queue[queue.length - 1];
|
|
388
471
|
if (piece && piece.type === PIECE) {
|
|
@@ -399,6 +482,7 @@ class Program {
|
|
|
399
482
|
m = match[0];
|
|
400
483
|
}
|
|
401
484
|
loop: while (index < text.length) {
|
|
485
|
+
|
|
402
486
|
if (queue.type & (QUOTED | ELEMENT)) {
|
|
403
487
|
var quote = quote_map[queue.entry];
|
|
404
488
|
var reg = quote.reg;
|
|
@@ -509,8 +593,10 @@ class Program {
|
|
|
509
593
|
var end = match[0].length + match.index;
|
|
510
594
|
index = end;
|
|
511
595
|
var m = match[0];
|
|
596
|
+
if (cache_stamp && !stamp_reg.test(m)) push_stamp();
|
|
597
|
+
var last = cache_stamp || queue.last;
|
|
598
|
+
|
|
512
599
|
test: if (quote_map.hasOwnProperty(m)) {
|
|
513
|
-
var last = queue.last;
|
|
514
600
|
var quote = quote_map[m];
|
|
515
601
|
if (queue.tag && quote.tag) {
|
|
516
602
|
var tagend = end + queue.tag.length
|
|
@@ -523,9 +609,10 @@ class Program {
|
|
|
523
609
|
break test;
|
|
524
610
|
}
|
|
525
611
|
}
|
|
526
|
-
|
|
612
|
+
var iscomment = comment_entry.test(m);
|
|
527
613
|
var isTypeTag = false;
|
|
528
|
-
if (
|
|
614
|
+
if (iscomment);
|
|
615
|
+
else if (queue.istype) {
|
|
529
616
|
isTypeTag = true;
|
|
530
617
|
}
|
|
531
618
|
else if (!last) {
|
|
@@ -534,8 +621,8 @@ class Program {
|
|
|
534
621
|
}
|
|
535
622
|
}
|
|
536
623
|
else if (stamp_reg.test(m) && last) {
|
|
537
|
-
if (
|
|
538
|
-
if (last.istype || last.isprop) {
|
|
624
|
+
if (last.type === STAMP && m === last.text) break test;
|
|
625
|
+
if (last.istype || last.isprop || last.isargl) {
|
|
539
626
|
isTypeTag = true;
|
|
540
627
|
}
|
|
541
628
|
else if ((VALUE | EXPRESS | PROPERTY) & last.type) a: {
|
|
@@ -555,11 +642,11 @@ class Program {
|
|
|
555
642
|
}
|
|
556
643
|
break test;
|
|
557
644
|
}
|
|
645
|
+
if (lp.istype || lp.isargl) {
|
|
646
|
+
isTypeTag = true;
|
|
647
|
+
break a;
|
|
648
|
+
}
|
|
558
649
|
if (lp.type === STRAP) {
|
|
559
|
-
if (lp.istype) {
|
|
560
|
-
isTypeTag = true;
|
|
561
|
-
break a;
|
|
562
|
-
}
|
|
563
650
|
if (lp.transive) break test;
|
|
564
651
|
}
|
|
565
652
|
}
|
|
@@ -570,7 +657,7 @@ class Program {
|
|
|
570
657
|
if (!last.tag) break test;
|
|
571
658
|
break;
|
|
572
659
|
case SCOPED:
|
|
573
|
-
if (queue.inExpress) break test;
|
|
660
|
+
if (queue.inExpress && !iscomment) break test;
|
|
574
661
|
break;
|
|
575
662
|
case STAMP:
|
|
576
663
|
if (/^(\+\+|\-\-)$/.test(last.text)) break test;
|
|
@@ -578,7 +665,7 @@ class Program {
|
|
|
578
665
|
}
|
|
579
666
|
}
|
|
580
667
|
var scope = [];
|
|
581
|
-
scope.type =
|
|
668
|
+
scope.type = iscomment ? COMMENT : QUOTED;
|
|
582
669
|
if (isTypeTag && scope.type === QUOTED) scope.istype = isTypeTag;
|
|
583
670
|
scope.isExpress = queue.inExpress;
|
|
584
671
|
scope.start = start;
|
|
@@ -591,8 +678,8 @@ class Program {
|
|
|
591
678
|
|
|
592
679
|
var m0 = m;
|
|
593
680
|
var reg = quote.reg;
|
|
681
|
+
reg.lastIndex = index;
|
|
594
682
|
while (index < text.length) {
|
|
595
|
-
reg.lastIndex = index;
|
|
596
683
|
var match = reg.exec(text);
|
|
597
684
|
if (!match) {
|
|
598
685
|
index = text.length;
|
|
@@ -632,7 +719,6 @@ class Program {
|
|
|
632
719
|
}
|
|
633
720
|
if (space_reg.test(m)) {
|
|
634
721
|
if (/[\r\n\u2028\u2029]/.test(m)) {
|
|
635
|
-
var last = queue.last;
|
|
636
722
|
if (last && last.isend === false) {
|
|
637
723
|
last.isend = true;
|
|
638
724
|
queue.inExpress = false;
|
|
@@ -645,10 +731,8 @@ class Program {
|
|
|
645
731
|
lasttype = SPACE;
|
|
646
732
|
continue;
|
|
647
733
|
}
|
|
648
|
-
if (strap_reg.test(m)) {
|
|
649
|
-
if (
|
|
650
|
-
else {
|
|
651
|
-
var last = queue.last;
|
|
734
|
+
if (!last?.needle && strap_reg.test(m)) {
|
|
735
|
+
if (funcstrap_reg.test(m)) {
|
|
652
736
|
if (!last);
|
|
653
737
|
else if (last.type === STAMP) {
|
|
654
738
|
queue.inExpress = !/^(;|\+\+|\-\-)$/.test(last.text);
|
|
@@ -658,6 +742,25 @@ class Program {
|
|
|
658
742
|
}
|
|
659
743
|
}
|
|
660
744
|
save(STRAP);
|
|
745
|
+
var last = queue.last;
|
|
746
|
+
if (last.type === STRAP && structstrap_reg.test(last.text) && !queue.classed) {
|
|
747
|
+
queue.classed = [last.text];
|
|
748
|
+
}
|
|
749
|
+
else if (queue.classed) {
|
|
750
|
+
if (last.type === STRAP && funcstrap_reg.test(last.text)) queue.classed.push(last.text);
|
|
751
|
+
}
|
|
752
|
+
if (funcstrap_reg.test(m)) {
|
|
753
|
+
last.isargl = true;
|
|
754
|
+
}
|
|
755
|
+
else if (type_reg.test(m)) {
|
|
756
|
+
last.istype = true;
|
|
757
|
+
}
|
|
758
|
+
if (this.transive_reg.test(m)) {
|
|
759
|
+
last.transive = queue.inExpress = true;
|
|
760
|
+
}
|
|
761
|
+
else {
|
|
762
|
+
queue.inExpress = false;
|
|
763
|
+
}
|
|
661
764
|
continue;
|
|
662
765
|
}
|
|
663
766
|
var isdigit = number_reg.exec(m);
|
|
@@ -675,10 +778,9 @@ class Program {
|
|
|
675
778
|
}
|
|
676
779
|
isdigit = true;
|
|
677
780
|
}
|
|
678
|
-
if (value_reg.test(m) || isdigit) {
|
|
781
|
+
if (!last?.needle && value_reg.test(m) || isdigit) {
|
|
679
782
|
queue.inExpress = true;
|
|
680
783
|
if (isdigit && lasttype === STAMP) {
|
|
681
|
-
var last = queue.last;
|
|
682
784
|
var prev = last.prev;
|
|
683
785
|
if ((!prev || prev.type & (STAMP | STRAP) && !/^(\+\+|\-\-)$/.test(prev.text)) && /^[+\-]+$/.test(last.text)) {
|
|
684
786
|
last.type = VALUE;
|
|
@@ -693,8 +795,7 @@ class Program {
|
|
|
693
795
|
continue;
|
|
694
796
|
}
|
|
695
797
|
if (express_reg.test(m)) {
|
|
696
|
-
|
|
697
|
-
if (last && last.type === STRAP && classstrap_reg.test(last.text));
|
|
798
|
+
if (last && last.type === STRAP && funcstrap_reg.test(last.text));
|
|
698
799
|
else queue.inExpress = true;
|
|
699
800
|
save(EXPRESS);
|
|
700
801
|
continue;
|
|
@@ -707,7 +808,6 @@ class Program {
|
|
|
707
808
|
scope.start = match.index;
|
|
708
809
|
scope.col = match.index - colstart;
|
|
709
810
|
scope.row = row;
|
|
710
|
-
var last = queue.last;
|
|
711
811
|
if (m === "{") {
|
|
712
812
|
if (!last) {
|
|
713
813
|
if (queue.istype) scope.isClass = true;
|
|
@@ -719,11 +819,14 @@ class Program {
|
|
|
719
819
|
var clsd = classed.pop();
|
|
720
820
|
scope.isClass = true;
|
|
721
821
|
if (!classed.length) queue.classed = null;
|
|
722
|
-
scope.istype = clsd
|
|
822
|
+
scope.istype = clsd !== 'class';
|
|
723
823
|
scope.extend += extends_reg.test(last.text);
|
|
724
824
|
scope.inExpress = false;
|
|
725
825
|
}
|
|
726
826
|
}
|
|
827
|
+
else if (last.type === SCOPED && last.istype) {
|
|
828
|
+
scope.isClass = true;
|
|
829
|
+
}
|
|
727
830
|
else if (last.type === STAMP) {
|
|
728
831
|
if (last.istype) {
|
|
729
832
|
scope.isClass = true;
|
|
@@ -733,33 +836,47 @@ class Program {
|
|
|
733
836
|
}
|
|
734
837
|
else queue.inExpress = scope.isObject = !/^(;|\+\+|\-\-|=>)$/.test(last.text);
|
|
735
838
|
}
|
|
736
|
-
else if (last.type === EXPRESS
|
|
737
|
-
|
|
839
|
+
else if (last.type === EXPRESS) a: {
|
|
840
|
+
var li = queue.length - 1;
|
|
841
|
+
var lp = queue[li];
|
|
842
|
+
while (lp !== last) {
|
|
843
|
+
if (lp.type === SPACE) break a;
|
|
844
|
+
lp = queue[li--];
|
|
845
|
+
}
|
|
846
|
+
var lp = last.prev;
|
|
847
|
+
if (lp?.type === STAMP && powermap[lp.text] === powermap["="]) scope.isObject = true;
|
|
738
848
|
}
|
|
739
849
|
else if (last.type === STRAP) {
|
|
740
850
|
if (last.isend);
|
|
741
|
-
else scope.isObject =
|
|
851
|
+
else scope.isObject = last.transive;
|
|
742
852
|
}
|
|
743
853
|
scope.brace = true;
|
|
744
854
|
scope.isExpress = queue.inExpress;
|
|
745
855
|
}
|
|
746
856
|
else {
|
|
857
|
+
var prev = last;
|
|
858
|
+
if (prev?.type === ELEMENT) prev = prev.prev;
|
|
859
|
+
if (prev?.type === EXPRESS) {
|
|
860
|
+
prev = prev.prev;
|
|
861
|
+
}
|
|
862
|
+
if (prev) {
|
|
863
|
+
if (prev.isargl || prev.isprop || queue.istype) {
|
|
864
|
+
scope.isargl = true;
|
|
865
|
+
}
|
|
866
|
+
else if (prev.istype) {
|
|
867
|
+
scope.istype = true;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
747
870
|
if (!last || (last.type & (SCOPED | STAMP))) queue.inExpress = true;
|
|
748
871
|
scope.isExpress = queue.inExpress;
|
|
749
872
|
scope.inExpress = true;
|
|
750
|
-
if (last?.istype && last.type === STAMP) {
|
|
751
|
-
scope.istype = true;
|
|
752
|
-
}
|
|
753
873
|
}
|
|
754
874
|
push_parents(scope);
|
|
755
875
|
continue;
|
|
756
876
|
}
|
|
757
877
|
if (this.scope_leave[m] && queue.entry === this.scope_leave[m]) {
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
if (lastUncomment.type === PROPERTY) {
|
|
761
|
-
lastUncomment.short = true;
|
|
762
|
-
}
|
|
878
|
+
if (last?.type === PROPERTY) {
|
|
879
|
+
last.short = true;
|
|
763
880
|
}
|
|
764
881
|
|
|
765
882
|
queue.end = end;
|
|
@@ -769,10 +886,7 @@ class Program {
|
|
|
769
886
|
continue;
|
|
770
887
|
}
|
|
771
888
|
if (this.scope_leave[m]) console.warn(i18n`标记不匹配`, queue.entry, m, "queue-start:", queue.start, "position:", `${row}:${index - colstart}\r\n`, index - queue.start < 200 ? text.slice(queue.start, index) : text.slice(queue.start, queue.start + 100) + "..." + text.slice(index - 97, index));
|
|
772
|
-
|
|
773
|
-
save(STAMP);
|
|
774
|
-
}
|
|
775
|
-
|
|
889
|
+
save(STAMP);
|
|
776
890
|
}
|
|
777
891
|
while (queue.tag && parents.length) {
|
|
778
892
|
for (var cx = 0, dx = parents.length; cx < dx; cx++) {
|
|
@@ -787,27 +901,34 @@ class Program {
|
|
|
787
901
|
queue_push(p);
|
|
788
902
|
}
|
|
789
903
|
};
|
|
904
|
+
if (cache_stamp) push_stamp();
|
|
790
905
|
this.lastIndex = index;
|
|
791
906
|
if (queue !== origin) {
|
|
792
|
-
|
|
793
|
-
|
|
907
|
+
console.log(
|
|
908
|
+
"代码异常结束",
|
|
909
|
+
createString(origin.slice(0, 30)),
|
|
794
910
|
`\r\n ----- deep: ${parents.length}`,
|
|
795
911
|
`\r\n ---- enrty: ${queue.entry}`,
|
|
796
912
|
`\r\n --- length: ${queue.length}`,
|
|
797
|
-
`\r\n ----- last: ${queue.last ? createString([queue.last]) : createString(queue)}`,
|
|
913
|
+
`\r\n ----- last: ${queue.last ? createString([queue.last]).slice(0, 30) : createString(queue).slice(0, 30)}`,
|
|
798
914
|
`\r\n -- parents: ${parents.map(p => `${p.row}:${p.col}-${p.tag || p.text || p.entry} `).join('-)> ')}`,
|
|
799
915
|
`\r\n ----- snap: ${createString([queue]).slice(-200)}`,
|
|
800
916
|
`\r\n ------ end. `
|
|
801
|
-
)
|
|
917
|
+
);
|
|
918
|
+
while (queue !== origin) {
|
|
919
|
+
queue.error = "代码异常结束";
|
|
920
|
+
queue.leave = '';
|
|
921
|
+
pop_parents();
|
|
922
|
+
}
|
|
802
923
|
}
|
|
803
|
-
return
|
|
924
|
+
return origin;
|
|
804
925
|
}
|
|
805
926
|
commit() {
|
|
806
927
|
this.strap_reg = this.createRegExp(this.straps);
|
|
807
928
|
this.comment_entry = this.createRegExp(this.comments.map(m => m[0]));
|
|
808
929
|
var stamps = this.stamps.join("");
|
|
809
930
|
stamps = this.compile(stamps);
|
|
810
|
-
this.stamp_reg = new RegExp(`^[${stamps}]
|
|
931
|
+
this.stamp_reg = new RegExp(`^[${stamps}]+$`);
|
|
811
932
|
var tokens = {};
|
|
812
933
|
var quote_map = {};
|
|
813
934
|
this.quote_map = quote_map;
|
|
@@ -843,7 +964,8 @@ class Program {
|
|
|
843
964
|
return this.compile(q);
|
|
844
965
|
});
|
|
845
966
|
if (q.tag) r = r.concat(q.tag);
|
|
846
|
-
r = r.concat(ts.map(this.compile))
|
|
967
|
+
r = r.concat(ts.map(this.compile));
|
|
968
|
+
r = sortRegster(r).join("|");
|
|
847
969
|
q.reg = new RegExp(r, 'g');
|
|
848
970
|
q.end = this.createRegExp([q[1]]);
|
|
849
971
|
if (q.length >= 4) {
|
|
@@ -876,8 +998,10 @@ class Program {
|
|
|
876
998
|
this.express_reg = new RegExp(`^${express}$`, flagUnicode);
|
|
877
999
|
this.space_reg = new RegExp(`^[${spaces}]+$`, flagUnicode);
|
|
878
1000
|
this.space_exp = new RegExp(`[${spaces}]+`, flagUnicode);
|
|
879
|
-
var
|
|
880
|
-
|
|
1001
|
+
var quotes_entries = this.createRegExp(this.comments.concat(this.quotes).map(q => q[0]), true).source;
|
|
1002
|
+
var powers = Object.keys(this.powermap).filter(k => this.stamp_reg.test(k));
|
|
1003
|
+
var powers_entries = this.createRegExp(this.tags.map(t => t[0]).concat(powers), true).source;
|
|
1004
|
+
this.entry_reg = new RegExp([`[${spaces}]+|${quotes_entries}|[${scopes}]|${number_reg.source.replace(/^\^|\$$/g, "")}[^${tokens}]*|${express}|${powers_entries}|[${stamps}]`], "gi" + flagUnicode);
|
|
881
1005
|
}
|
|
882
1006
|
}
|
|
883
1007
|
module.exports = Program;
|