efront 4.4.2 → 4.4.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/coms/compile/common.js
CHANGED
|
@@ -125,7 +125,15 @@ var skipAssignment = function (o, cx) {
|
|
|
125
125
|
break;
|
|
126
126
|
case STRAP:
|
|
127
127
|
if (needpunc) {
|
|
128
|
-
if (!/^(in|instanceof|of|else|as|from)$/.test(o.text))
|
|
128
|
+
if (!/^(in|instanceof|of|else|as|from|catch|finally)$/.test(o.text)) {
|
|
129
|
+
break loop;
|
|
130
|
+
}
|
|
131
|
+
if (o.text === 'catch') {
|
|
132
|
+
next();
|
|
133
|
+
if (o && o.entry === '(') next();
|
|
134
|
+
needpunc = false;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
129
137
|
if (o.text === 'else') {
|
|
130
138
|
if (!ifdeep) break loop;
|
|
131
139
|
ifdeep--;
|
|
@@ -134,21 +142,16 @@ var skipAssignment = function (o, cx) {
|
|
|
134
142
|
next();
|
|
135
143
|
needpunc = false;
|
|
136
144
|
}
|
|
137
|
-
else if (/^(try|catch|finally)$/.test(o.text)) {
|
|
138
|
-
next();
|
|
139
|
-
if (o.entry === "(") next();
|
|
140
|
-
next();
|
|
141
|
-
}
|
|
142
145
|
else if (o.text === 'else') {
|
|
143
146
|
if (ifdeep <= 0) break loop;
|
|
144
147
|
ifdeep--;
|
|
145
148
|
needpunc = false;
|
|
146
149
|
next();
|
|
147
150
|
}
|
|
148
|
-
else if (/^(if|while|with|switch)$/.test(o.text)) {
|
|
151
|
+
else if (/^(if|while|with|switch|try)$/.test(o.text)) {
|
|
149
152
|
if (o.text === 'if') ifdeep++;
|
|
150
153
|
next();
|
|
151
|
-
next();
|
|
154
|
+
if (o.entry === "(") next();
|
|
152
155
|
}
|
|
153
156
|
else if (o.text === 'do') {
|
|
154
157
|
next();
|
|
@@ -34,6 +34,10 @@ testPickSentence(`a+b\r\n++c`, 5, "++c")
|
|
|
34
34
|
testPickSentence(`a+b++\r\nc`, 5, "c")
|
|
35
35
|
testPickSentence(`a+b++\r\nc`, 5, "c")
|
|
36
36
|
testPickSentence(`a+b++\r\n+c`, 6, "a + b++\r\n+ c")
|
|
37
|
+
testPickSentence(`if(a)try{}catch{}a;`, 0, "if (a) try {} catch {}")
|
|
38
|
+
testPickSentence(`if(a)try{}catch(a){}a;`, 0, "if (a) try {} catch (a) {}")
|
|
39
|
+
testPickSentence(`if(a)try{}catch{} else a;`, 0, "if (a) try {} catch {} else a")
|
|
40
|
+
testPickSentence(`if(a)try{}catch{} else if(a);`, 0, "if (a) try {} catch {} else if (a)")
|
|
37
41
|
assert(common.createString(common.pickArgument(scanner2(`a={a:1,c:d}`)[2][4])), 'c: d')
|
|
38
42
|
assert(common.createString(common.pickArgument(scanner2(`a=class{a=1\r\nc=d}`)[3][4])), 'c = d')
|
|
39
43
|
assert(common.createString(common.pickArgument(scanner2(`(a=1,c=d)`)[0][4])), 'c = d')
|
|
@@ -125,7 +125,6 @@ test("menus[a+b]()", "_ = a + b; menus[_]()", true);
|
|
|
125
125
|
test(`switch(a){default: a;case 1:b;}`, 'if (a === 1) return [2, 0]; return [1, 0];\r\n a; return [1, 0];\r\n b; return [1, 0]', true);
|
|
126
126
|
test("loop:{a=b;if(a) continue loop}", "a = b; if (a) return [0, 0]", true);
|
|
127
127
|
test("if(a)try{}finally{}else a;", 'if (!a) return [4, 0]; return [1, 8];\r\n return [0, 9];\r\n return [1, 9];\r\n return [2, 0];\r\n a; return [1, 0]')
|
|
128
|
-
test("if(a)try{}finally{}else;", 'if (!a) return [4, 0]; return [1, 8];\r\n return [0, 9];\r\n return [1, 9];\r\n return [1, 0]');
|
|
129
128
|
test("b:while(t){switch(a){case c:break b;}}", 'if (!t) return [1, 0]; if (a === c) return [1, 0]; return [0, 0]');
|
|
130
129
|
test("predef[key[1]](r.slice(key[0].length).trim())", '_ = key[1]; _0 = key[0].length; _0 = r.slice(_0); _0 = _0.trim(); predef[_](_0)');
|
|
131
130
|
test("predef[key[1]](r.slice())(r.slice())", '_ = key[1]; _0 = r.slice(); _ = predef[_](_0); _0 = r.slice(); _(_0)');
|
|
@@ -149,7 +148,8 @@ test(`a[0]-- > 1`, "_ = a[0]--, _ > 1");
|
|
|
149
148
|
test(`c=b\r\n++a`, "c = b; ++a");
|
|
150
149
|
test(`c=b+\r\n++a`, "_ =\r\n++a, c = b + _");
|
|
151
150
|
test(`c=b+ ++a`, "_ = ++a, c = b + _");
|
|
152
|
-
unstruct.debug = true; r++;
|
|
153
151
|
test(`c=b+ +a`, "_ = +a, c = b + _");
|
|
154
152
|
test(`c=b+ !a`, "_ = !a, c = b + _");
|
|
155
153
|
test(`do {var loadcount = 0;} while (loadcount !== 0);`, `loadcount = 0; _ = loadcount !== 0; if (_) return [0, 0]`);
|
|
154
|
+
unstruct.debug = true; r++;
|
|
155
|
+
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');
|