nadesiko3 3.7.2 → 3.7.4
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/batch/command.txt +472 -469
- package/batch/pickup_command.nako3 +1 -1
- package/core/.eslintrc.cjs +10 -3
- package/core/package-lock.json +1184 -645
- package/core/package.json +4 -5
- package/core/src/nako3.mjs +8 -6
- package/core/src/nako3.mts +19 -16
- package/core/src/nako_ast.mts +2 -3
- package/core/src/nako_core_version.mjs +2 -2
- package/core/src/nako_core_version.mts +2 -2
- package/core/src/nako_csv.mjs +1 -0
- package/core/src/nako_csv.mts +3 -2
- package/core/src/nako_from_dncl.mjs +1 -1
- package/core/src/nako_from_dncl.mts +1 -1
- package/core/src/nako_from_dncl2.mjs +1 -1
- package/core/src/nako_from_dncl2.mts +2 -2
- package/core/src/nako_gen.mjs +37 -35
- package/core/src/nako_gen.mts +70 -67
- package/core/src/nako_global.mjs +3 -2
- package/core/src/nako_global.mts +3 -2
- package/core/src/nako_lexer.mjs +3 -3
- package/core/src/nako_lexer.mts +3 -3
- package/core/src/nako_logger.mjs +1 -1
- package/core/src/nako_logger.mts +2 -2
- package/core/src/nako_parser3.mjs +67 -59
- package/core/src/nako_parser3.mts +96 -90
- package/core/src/nako_parser_base.mts +3 -3
- package/core/src/nako_prepare.mjs +1 -1
- package/core/src/nako_prepare.mts +1 -1
- package/core/src/nako_source_mapping.mts +0 -1
- package/core/src/nako_token.mts +8 -8
- package/core/src/nako_types.mts +1 -1
- package/core/src/plugin_api.mts +1 -1
- package/core/src/plugin_csv.mjs +1 -0
- package/core/src/plugin_csv.mts +2 -1
- package/core/src/plugin_math.mjs +2 -2
- package/core/src/plugin_math.mts +3 -3
- package/core/src/plugin_promise.mjs +1 -1
- package/core/src/plugin_promise.mts +1 -1
- package/core/src/plugin_system.mjs +117 -40
- package/core/src/plugin_system.mts +132 -58
- package/core/src/plugin_test.mjs +3 -1
- package/core/src/plugin_test.mts +3 -1
- package/core/test/basic_test.mjs +16 -0
- package/core/test/calc_test.mjs +7 -0
- package/core/test/plugin_system_test.mjs +33 -0
- package/doc/files.md +4 -4
- package/doc/plugins.md +1 -1
- package/package.json +9 -9
- package/release/_hash.txt +36 -121
- package/release/_script-tags.txt +16 -33
- package/release/command.json +1 -1
- package/release/command.json.js +1 -1
- package/release/command_cnako3.json +1 -1
- package/release/command_list.json +1 -1
- package/release/edit_main.js +3 -3
- package/release/edit_main.js.map +2 -2
- package/release/editor.js +3 -3
- package/release/plugin_markup.js +53 -53
- package/release/plugin_markup.js.map +3 -3
- package/release/plugin_weykturtle3d.js +1 -1
- package/release/plugin_weykturtle3d.js.map +4 -4
- package/release/version.js +3 -3
- package/release/version_main.js +3 -3
- package/release/version_main.js.map +2 -2
- package/release/wnako3.js +66 -66
- package/release/wnako3.js.map +3 -3
- package/release/wnako3webworker.js +58 -58
- package/release/wnako3webworker.js.map +3 -3
- package/src/browsers.txt +30 -20
- package/src/cnako3mod.mjs +19 -18
- package/src/cnako3mod.mts +17 -16
- package/src/deno_wrapper.mjs +6 -6
- package/src/deno_wrapper.mts +11 -11
- package/src/nako_version.mjs +2 -2
- package/src/nako_version.mts +2 -2
- package/src/plugin_browser.mjs +2 -2
- package/src/plugin_browser.mts +5 -5
- package/src/plugin_browser_ajax.mjs +2 -2
- package/src/plugin_browser_ajax.mts +2 -2
- package/src/plugin_browser_api.mts +0 -1
- package/src/plugin_browser_crypto.mjs +8 -8
- package/src/plugin_browser_crypto.mts +13 -13
- package/src/plugin_browser_dom_basic.mjs +3 -3
- package/src/plugin_browser_dom_basic.mts +5 -7
- package/src/plugin_browser_dom_event.mjs +1 -1
- package/src/plugin_browser_dom_event.mts +2 -1
- package/src/plugin_browser_dom_parts.mjs +33 -18
- package/src/plugin_browser_dom_parts.mts +60 -59
- package/src/plugin_browser_speech.mjs +1 -1
- package/src/plugin_browser_speech.mts +1 -1
- package/src/plugin_node.mjs +5 -3
- package/src/plugin_node.mts +6 -4
- package/src/plugin_weykturtle3d.mjs +38 -15
- package/src/plugin_weykturtle3d.mts +279 -240
- package/src/plugin_weykturtle3d_three.mjs +3 -0
- package/src/plugin_weykturtle3d_three.mts +214 -0
- package/src/plugin_weykturtle3d_threeutil.mjs +28 -0
- package/src/plugin_weykturtle3d_threeutil.mts +31 -0
- package/src/wnako3.mjs +1 -0
- package/src/wnako3.mts +1 -0
- package/src/wnako3mod.mjs +5 -2
- package/src/wnako3mod.mts +6 -3
- package/batch/command_nakopad.txt +0 -1177
- package/core/__report.txt +0 -617
- package/core/command/plugin_snako.mjs +0 -112
- package/core/command/snako.mjs +0 -108
- package/release/core_src_nako_josi_list_mjs.js +0 -3
- package/release/core_src_nako_josi_list_mjs.js.LICENSE.txt +0 -3
- package/release/core_src_nako_josi_list_mjs.js.map +0 -1
- package/release/core_src_nako_reserved_words_mjs.js +0 -3
- package/release/core_src_nako_reserved_words_mjs.js.LICENSE.txt +0 -3
- package/release/core_src_nako_reserved_words_mjs.js.map +0 -1
- package/release/editor/edit_main.js +0 -48
- package/release/editor/edit_main.js.map +0 -7
- package/release/editor/version_main.js +0 -44
- package/release/editor/version_main.js.map +0 -7
- package/release/editor.js.LICENSE.txt +0 -91
- package/release/editor.js.map +0 -1
- package/release/nako_gen_async.js +0 -2
- package/release/nako_gen_async.js.LICENSE.txt +0 -21
- package/release/nako_gen_async.js.map +0 -1
- package/release/plugin_caniuse.js.LICENSE.txt +0 -15
- package/release/plugin_datetime.js.LICENSE.txt +0 -21
- package/release/plugin_kansuji.js.LICENSE.txt +0 -3
- package/release/plugin_markup.js.LICENSE.txt +0 -15
- package/release/plugin_toml.js +0 -295
- package/release/plugin_toml.js.map +0 -7
- package/release/plugin_turtle.js.LICENSE.txt +0 -9
- package/release/plugin_webworker.js.LICENSE.txt +0 -3
- package/release/plugin_weykturtle3d.js.LICENSE.txt +0 -3
- package/release/src/plugin_caniuse.js +0 -2
- package/release/src/plugin_caniuse.js.map +0 -7
- package/release/src/plugin_datetime.js +0 -2
- package/release/src/plugin_datetime.js.map +0 -7
- package/release/src/plugin_kansuji.js +0 -2
- package/release/src/plugin_kansuji.js.map +0 -7
- package/release/src/plugin_keigo.js +0 -2
- package/release/src/plugin_keigo.js.map +0 -7
- package/release/src/plugin_markup.js +0 -64
- package/release/src/plugin_markup.js.map +0 -7
- package/release/src/plugin_three.js +0 -2
- package/release/src/plugin_three.js.map +0 -7
- package/release/src/plugin_turtle.js +0 -2
- package/release/src/plugin_turtle.js.map +0 -7
- package/release/src/plugin_webworker.js +0 -4
- package/release/src/plugin_webworker.js.map +0 -7
- package/release/src/plugin_weykturtle3d.js +0 -2
- package/release/src/plugin_weykturtle3d.js.map +0 -7
- package/release/src/wnako3.js +0 -482
- package/release/src/wnako3.js.map +0 -7
- package/release/src/wnako3webworker.js +0 -428
- package/release/src/wnako3webworker.js.map +0 -7
- package/release/stats.json +0 -1
- package/release/version.js.LICENSE.txt +0 -65
- package/release/version.js.map +0 -1
- package/release/wnako3.js.LICENSE.txt +0 -341
- package/release/wnako3webworker.js.LICENSE.txt +0 -209
- package/src/plugin_three.mts +0 -240
|
@@ -71,7 +71,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
71
71
|
this.logger.debug('構文解析に失敗:' + this.nodeToStr(this.peek(), { depth: 1 }, true), token);
|
|
72
72
|
throw NakoSyntaxError.fromNode('構文解析に失敗:' + this.nodeToStr(this.peek(), { depth: 1 }, false), token);
|
|
73
73
|
}
|
|
74
|
-
return { type: 'block', blocks
|
|
74
|
+
return { type: 'block', blocks, josi: '', ...map, end: this.peekSourceMap() };
|
|
75
75
|
}
|
|
76
76
|
/** 余剰スタックのレポートを作る */
|
|
77
77
|
makeStackBalanceReport() {
|
|
@@ -90,7 +90,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
90
90
|
for (const f of this.recentlyCalledFunc) {
|
|
91
91
|
descFunc += ' - ';
|
|
92
92
|
let no = 0;
|
|
93
|
-
const josiA = f.josi;
|
|
93
|
+
const josiA = (f).josi;
|
|
94
94
|
if (josiA) {
|
|
95
95
|
for (const arg of josiA) {
|
|
96
96
|
const ch = String.fromCharCode(chA + no);
|
|
@@ -104,7 +104,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
104
104
|
no++;
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
descFunc += f.name + '\n';
|
|
107
|
+
descFunc += String(f.name) + '\n';
|
|
108
108
|
}
|
|
109
109
|
this.recentlyCalledFunc = [];
|
|
110
110
|
return `未解決の単語があります: [${desc}]\n次の命令の可能性があります:\n${descFunc}`;
|
|
@@ -126,7 +126,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
126
126
|
comment: eol.value,
|
|
127
127
|
line: eol.line,
|
|
128
128
|
column: eol.column,
|
|
129
|
-
file: eol.file
|
|
129
|
+
file: eol.file
|
|
130
130
|
};
|
|
131
131
|
}
|
|
132
132
|
/** @returns {Ast | null} */
|
|
@@ -169,7 +169,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
169
169
|
}
|
|
170
170
|
if (this.accept(['not', '厳チェック'])) {
|
|
171
171
|
return this.ySetMode('厳しくチェック');
|
|
172
|
-
} // (#1698)
|
|
172
|
+
} // (#1698)
|
|
173
173
|
// (memo) 現状「取込」はプリプロセス段階(NakoCompiler.listRequireStatements)で処理される
|
|
174
174
|
// if (this.accept(['require', 'string', '取込'])) { return this.yRequire() }
|
|
175
175
|
// <廃止された構文>
|
|
@@ -287,7 +287,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
287
287
|
}
|
|
288
288
|
blocks.push(this.y[0]);
|
|
289
289
|
}
|
|
290
|
-
return { type: 'block', blocks
|
|
290
|
+
return { type: 'block', blocks, josi: '', ...map, end: this.peekSourceMap() };
|
|
291
291
|
}
|
|
292
292
|
yDefFuncReadArgs() {
|
|
293
293
|
if (!this.check('(')) {
|
|
@@ -402,11 +402,18 @@ export class NakoParser extends NakoParserBase {
|
|
|
402
402
|
this.localvars.set(fnName, { 'type': 'var', 'value': '' });
|
|
403
403
|
}
|
|
404
404
|
block = this.yBlock();
|
|
405
|
+
// 「ここまで」のチェック
|
|
405
406
|
if (this.check('ここまで')) {
|
|
406
|
-
this.get();
|
|
407
|
+
this.get(); // skip 'ここまで'
|
|
407
408
|
}
|
|
408
409
|
else {
|
|
409
|
-
|
|
410
|
+
// 「ここまで」が見当たらない
|
|
411
|
+
const nextWordO = this.peek();
|
|
412
|
+
let nextWord = JSON.stringify(nextWordO);
|
|
413
|
+
if (nextWordO && nextWordO.type && nextWordO.value) {
|
|
414
|
+
nextWord = nextWordO.value;
|
|
415
|
+
}
|
|
416
|
+
throw NakoSyntaxError.fromNode(`『ここまで』がありません。関数定義の末尾に必要です。『${nextWord}』の前に『ここまで』を記述してください。`, def);
|
|
410
417
|
}
|
|
411
418
|
this.loadStack();
|
|
412
419
|
}
|
|
@@ -421,9 +428,9 @@ export class NakoParser extends NakoParserBase {
|
|
|
421
428
|
}
|
|
422
429
|
catch (err) {
|
|
423
430
|
this.logger.debug(this.nodeToStr(funcName, { depth: 0, typeName: '関数' }, true) +
|
|
424
|
-
'の定義で以下のエラーがありました。\n' + err.message, def);
|
|
431
|
+
'の定義で以下のエラーがありました。\n' + String(err.message), def);
|
|
425
432
|
throw NakoSyntaxError.fromNode(this.nodeToStr(funcName, { depth: 0, typeName: '関数' }, false) +
|
|
426
|
-
'の定義で以下のエラーがありました。\n' + err.message, def);
|
|
433
|
+
'の定義で以下のエラーがありました。\n' + String(err.message), def);
|
|
427
434
|
}
|
|
428
435
|
const func = this.funclist.get(funcName.value);
|
|
429
436
|
if (func && !func.asyncFn && asyncFn) {
|
|
@@ -538,7 +545,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
538
545
|
expr = this.yIFCond();
|
|
539
546
|
}
|
|
540
547
|
catch (err) {
|
|
541
|
-
throw NakoSyntaxError.fromNode('『もし』文の条件で次のエラーがあります。\n' + err.message, mosi);
|
|
548
|
+
throw NakoSyntaxError.fromNode('『もし』文の条件で次のエラーがあります。\n' + String(err.message), mosi);
|
|
542
549
|
}
|
|
543
550
|
return this.yIfThen(expr, map);
|
|
544
551
|
}
|
|
@@ -1093,11 +1100,11 @@ export class NakoParser extends NakoParserBase {
|
|
|
1093
1100
|
else {
|
|
1094
1101
|
flagUp = false;
|
|
1095
1102
|
}
|
|
1096
|
-
const w = incdec.value + kurikaesu.type;
|
|
1097
|
-
if (w
|
|
1103
|
+
const w = String(incdec.value) + kurikaesu.type;
|
|
1104
|
+
if (w === '増繰返') {
|
|
1098
1105
|
kurikaesu.type = '増繰返';
|
|
1099
1106
|
}
|
|
1100
|
-
else if (w
|
|
1107
|
+
else if (w === '減繰返') {
|
|
1101
1108
|
kurikaesu.type = '減繰返';
|
|
1102
1109
|
}
|
|
1103
1110
|
else {
|
|
@@ -1409,6 +1416,9 @@ export class NakoParser extends NakoParserBase {
|
|
|
1409
1416
|
if (!word || (word.type !== 'word' && word.type !== 'func' && word.type !== 'ref_array')) {
|
|
1410
1417
|
throw NakoSyntaxError.fromNode('代入文で代入先の変数が見当たりません。『(変数名)に(値)を代入』のように使います。', dainyu);
|
|
1411
1418
|
}
|
|
1419
|
+
if (word.type === 'func') {
|
|
1420
|
+
throw NakoSyntaxError.fromNode('関数『' + String(word.name) + '』に代入できません。『(変数名)に(値)を代入』のように使います。', dainyu);
|
|
1421
|
+
}
|
|
1412
1422
|
// 配列への代入
|
|
1413
1423
|
if (word.type === 'ref_array') {
|
|
1414
1424
|
const indexArray = word.index || [];
|
|
@@ -1507,8 +1517,8 @@ export class NakoParser extends NakoParserBase {
|
|
|
1507
1517
|
}
|
|
1508
1518
|
// 減らすなら-1かける
|
|
1509
1519
|
if (action.value === '減') {
|
|
1510
|
-
const
|
|
1511
|
-
value = { type: 'op', operator: '*', blocks: [value,
|
|
1520
|
+
const minusOne = { type: 'number', value: -1, line: action.line };
|
|
1521
|
+
value = { type: 'op', operator: '*', blocks: [value, minusOne], josi: '', ...map };
|
|
1512
1522
|
}
|
|
1513
1523
|
return {
|
|
1514
1524
|
type: 'inc',
|
|
@@ -1711,16 +1721,16 @@ export class NakoParser extends NakoParserBase {
|
|
|
1711
1721
|
blocks: args,
|
|
1712
1722
|
meta: f,
|
|
1713
1723
|
josi: t.josi,
|
|
1714
|
-
asyncFn: f.asyncFn
|
|
1724
|
+
asyncFn: !!f.asyncFn,
|
|
1715
1725
|
...map,
|
|
1716
1726
|
end: this.peekSourceMap()
|
|
1717
1727
|
};
|
|
1718
1728
|
// 「プラグイン名設定」ならば、そこでスコープを変更することを意味する (#1112)
|
|
1719
1729
|
if (funcNode.name === 'プラグイン名設定') {
|
|
1720
1730
|
if (args.length > 0 && args[0]) {
|
|
1721
|
-
let fname =
|
|
1731
|
+
let fname = String(args[0].value);
|
|
1722
1732
|
if (fname === 'メイン') {
|
|
1723
|
-
fname =
|
|
1733
|
+
fname = String(args[0].file);
|
|
1724
1734
|
}
|
|
1725
1735
|
this.namespaceStack.push(this.modName);
|
|
1726
1736
|
this.isExportStack.push(this.isExportDefault);
|
|
@@ -1845,7 +1855,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
1845
1855
|
if (this.accept(['word', 'とは'])) {
|
|
1846
1856
|
const wordToken = this.y[0];
|
|
1847
1857
|
if (!this.checkTypes(['変数', '定数'])) {
|
|
1848
|
-
throw NakoSyntaxError.fromNode('ローカル変数『' + wordToken.value + '』の定義エラー', wordToken);
|
|
1858
|
+
throw NakoSyntaxError.fromNode('ローカル変数『' + String(wordToken.value) + '』の定義エラー', wordToken);
|
|
1849
1859
|
}
|
|
1850
1860
|
const vtype = this.getCur(); // 変数 or 定数
|
|
1851
1861
|
let isExport = this.isExportDefault;
|
|
@@ -1853,7 +1863,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
1853
1863
|
this.get();
|
|
1854
1864
|
const attrNode = this.get();
|
|
1855
1865
|
if (attrNode === null) {
|
|
1856
|
-
throw NakoSyntaxError.fromNode('ローカル変数『' + wordToken.value + '』の定義エラー', wordToken);
|
|
1866
|
+
throw NakoSyntaxError.fromNode('ローカル変数『' + String(wordToken.value) + '』の定義エラー', wordToken);
|
|
1857
1867
|
}
|
|
1858
1868
|
const attr = attrNode.value;
|
|
1859
1869
|
if (attr === '公開') {
|
|
@@ -1949,9 +1959,10 @@ export class NakoParser extends NakoParserBase {
|
|
|
1949
1959
|
};
|
|
1950
1960
|
}
|
|
1951
1961
|
}
|
|
1952
|
-
if (this.accept(['定数', 'word', 'eq'
|
|
1953
|
-
const
|
|
1954
|
-
const
|
|
1962
|
+
if (this.accept(['定数', 'word', 'eq'])) {
|
|
1963
|
+
const constName = this.y[1];
|
|
1964
|
+
const word = this.createVar(constName, true, this.isExportDefault);
|
|
1965
|
+
const astValue = this.yCalc() || this.yNop();
|
|
1955
1966
|
return {
|
|
1956
1967
|
type: 'def_local_var',
|
|
1957
1968
|
name: word.value,
|
|
@@ -1961,7 +1972,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
1961
1972
|
end: this.peekSourceMap()
|
|
1962
1973
|
};
|
|
1963
1974
|
}
|
|
1964
|
-
if (this.accept(['定数', 'word', '{', 'word', '}', 'eq'
|
|
1975
|
+
if (this.accept(['定数', 'word', '{', 'word', '}', 'eq'])) {
|
|
1965
1976
|
let isExport = this.isExportDefault;
|
|
1966
1977
|
const attr = this.y[3].value;
|
|
1967
1978
|
if (attr === '公開') {
|
|
@@ -1977,7 +1988,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
1977
1988
|
this.logger.warn(`不明な定数属性『${attr}』が指定されています。`);
|
|
1978
1989
|
}
|
|
1979
1990
|
const word = this.createVar(this.y[1], true, isExport);
|
|
1980
|
-
const astValue = this.
|
|
1991
|
+
const astValue = this.yCalc() || this.yNop();
|
|
1981
1992
|
return {
|
|
1982
1993
|
type: 'def_local_var',
|
|
1983
1994
|
name: word.value,
|
|
@@ -1989,13 +2000,13 @@ export class NakoParser extends NakoParserBase {
|
|
|
1989
2000
|
};
|
|
1990
2001
|
}
|
|
1991
2002
|
// 複数定数への代入 #563
|
|
1992
|
-
if (this.accept(['定数', this.yJSONArray, 'eq'
|
|
2003
|
+
if (this.accept(['定数', this.yJSONArray, 'eq'])) {
|
|
1993
2004
|
const names = this.y[1];
|
|
1994
2005
|
// check array
|
|
1995
2006
|
if (names && names.blocks instanceof Array) {
|
|
1996
2007
|
for (const i in names.blocks) {
|
|
1997
2008
|
if (names.blocks[i].type !== 'word') {
|
|
1998
|
-
throw NakoSyntaxError.fromNode(`複数定数の代入文${i + 1}番目でエラー。『定数[A,B,C]=[1,2,3]』の書式で記述してください。`, this.y[0]);
|
|
2009
|
+
throw NakoSyntaxError.fromNode(`複数定数の代入文${Number(i) + 1}番目でエラー。『定数[A,B,C]=[1,2,3]』の書式で記述してください。`, this.y[0]);
|
|
1999
2010
|
}
|
|
2000
2011
|
}
|
|
2001
2012
|
}
|
|
@@ -2003,7 +2014,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
2003
2014
|
throw NakoSyntaxError.fromNode('複数定数の代入文でエラー。『定数[A,B,C]=[1,2,3]』の書式で記述してください。', this.y[0]);
|
|
2004
2015
|
}
|
|
2005
2016
|
const namesAst = this._tokensToNodes(this.createVarList(names.blocks, true, this.isExportDefault));
|
|
2006
|
-
const astValue = this.
|
|
2017
|
+
const astValue = this.yCalc() || this.yNop();
|
|
2007
2018
|
return {
|
|
2008
2019
|
type: 'def_local_varlist',
|
|
2009
2020
|
names: namesAst,
|
|
@@ -2014,21 +2025,21 @@ export class NakoParser extends NakoParserBase {
|
|
|
2014
2025
|
};
|
|
2015
2026
|
}
|
|
2016
2027
|
// 複数変数への代入 #563
|
|
2017
|
-
if (this.accept(['変数', this.yJSONArray, 'eq'
|
|
2028
|
+
if (this.accept(['変数', this.yJSONArray, 'eq'])) {
|
|
2018
2029
|
const names = this.y[1];
|
|
2019
2030
|
// check array
|
|
2020
2031
|
if (names && names.blocks instanceof Array) {
|
|
2021
|
-
|
|
2022
|
-
if (
|
|
2023
|
-
throw NakoSyntaxError.fromNode(`複数変数の代入文${
|
|
2032
|
+
names.blocks.forEach((block, index) => {
|
|
2033
|
+
if (block.type !== 'word') {
|
|
2034
|
+
throw NakoSyntaxError.fromNode(`複数変数の代入文${String(index + 1)}番目でエラー『変数[A,B,C]=[1,2,3]』の書式で記述してください。`, this.y[0]);
|
|
2024
2035
|
}
|
|
2025
|
-
}
|
|
2036
|
+
});
|
|
2026
2037
|
}
|
|
2027
2038
|
else {
|
|
2028
2039
|
throw NakoSyntaxError.fromNode('複数変数の代入文でエラー。『変数[A,B,C]=[1,2,3]』の書式で記述してください。', this.y[0]);
|
|
2029
2040
|
}
|
|
2030
2041
|
const namesAst = this._tokensToNodes(this.createVarList(names.blocks, false, this.isExportDefault));
|
|
2031
|
-
const astValue = this.
|
|
2042
|
+
const astValue = this.yCalc() || this.yNop();
|
|
2032
2043
|
return {
|
|
2033
2044
|
type: 'def_local_varlist',
|
|
2034
2045
|
names: namesAst,
|
|
@@ -2041,10 +2052,10 @@ export class NakoParser extends NakoParserBase {
|
|
|
2041
2052
|
// 複数変数への代入 #563
|
|
2042
2053
|
if (this.check2(['word', 'comma', 'word'])) {
|
|
2043
2054
|
// 2 word
|
|
2044
|
-
if (this.accept(['word', 'comma', 'word', 'eq'
|
|
2055
|
+
if (this.accept(['word', 'comma', 'word', 'eq'])) {
|
|
2045
2056
|
let names = [this.y[0], this.y[2]];
|
|
2046
2057
|
names = this.createVarList(names, false, this.isExportDefault);
|
|
2047
|
-
const astValue = this.
|
|
2058
|
+
const astValue = this.yCalc() || this.yNop();
|
|
2048
2059
|
return {
|
|
2049
2060
|
type: 'def_local_varlist',
|
|
2050
2061
|
names,
|
|
@@ -2055,10 +2066,10 @@ export class NakoParser extends NakoParserBase {
|
|
|
2055
2066
|
};
|
|
2056
2067
|
}
|
|
2057
2068
|
// 3 word
|
|
2058
|
-
if (this.accept(['word', 'comma', 'word', 'comma', 'word', 'eq'
|
|
2069
|
+
if (this.accept(['word', 'comma', 'word', 'comma', 'word', 'eq'])) {
|
|
2059
2070
|
let names = [this.y[0], this.y[2], this.y[4]];
|
|
2060
2071
|
names = this.createVarList(names, false, this.isExportDefault);
|
|
2061
|
-
const astValue = this.
|
|
2072
|
+
const astValue = this.yCalc() || this.yNop();
|
|
2062
2073
|
return {
|
|
2063
2074
|
type: 'def_local_varlist',
|
|
2064
2075
|
names,
|
|
@@ -2069,10 +2080,10 @@ export class NakoParser extends NakoParserBase {
|
|
|
2069
2080
|
};
|
|
2070
2081
|
}
|
|
2071
2082
|
// 4 word
|
|
2072
|
-
if (this.accept(['word', 'comma', 'word', 'comma', 'word', 'comma', 'word', 'eq'
|
|
2083
|
+
if (this.accept(['word', 'comma', 'word', 'comma', 'word', 'comma', 'word', 'eq'])) {
|
|
2073
2084
|
let names = [this.y[0], this.y[2], this.y[4], this.y[6]];
|
|
2074
2085
|
names = this.createVarList(names, false, this.isExportDefault);
|
|
2075
|
-
const astValue = this.
|
|
2086
|
+
const astValue = this.yCalc() || this.yNop();
|
|
2076
2087
|
return {
|
|
2077
2088
|
type: 'def_local_varlist',
|
|
2078
2089
|
names,
|
|
@@ -2083,10 +2094,10 @@ export class NakoParser extends NakoParserBase {
|
|
|
2083
2094
|
};
|
|
2084
2095
|
}
|
|
2085
2096
|
// 5 word
|
|
2086
|
-
if (this.accept(['word', 'comma', 'word', 'comma', 'word', 'comma', 'word', 'comma', 'word', 'eq'
|
|
2097
|
+
if (this.accept(['word', 'comma', 'word', 'comma', 'word', 'comma', 'word', 'comma', 'word', 'eq'])) {
|
|
2087
2098
|
let names = [this.y[0], this.y[2], this.y[4], this.y[6], this.y[8]];
|
|
2088
2099
|
names = this.createVarList(names, false, this.isExportDefault);
|
|
2089
|
-
const astValue = this.
|
|
2100
|
+
const astValue = this.yCalc() || this.yNop();
|
|
2090
2101
|
return {
|
|
2091
2102
|
type: 'def_local_varlist',
|
|
2092
2103
|
names,
|
|
@@ -2110,7 +2121,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
2110
2121
|
return node;
|
|
2111
2122
|
}
|
|
2112
2123
|
// 配列が1から始まるのであれば演算を加えて返す
|
|
2113
|
-
const
|
|
2124
|
+
const minusNum = {
|
|
2114
2125
|
...node,
|
|
2115
2126
|
'type': 'number',
|
|
2116
2127
|
'value': this.arrayIndexFrom
|
|
@@ -2119,7 +2130,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
2119
2130
|
...node,
|
|
2120
2131
|
type: 'op',
|
|
2121
2132
|
operator: '-',
|
|
2122
|
-
blocks: [node,
|
|
2133
|
+
blocks: [node, minusNum]
|
|
2123
2134
|
};
|
|
2124
2135
|
}
|
|
2125
2136
|
/**
|
|
@@ -2451,7 +2462,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
2451
2462
|
blocks: args,
|
|
2452
2463
|
josi: f.josi,
|
|
2453
2464
|
meta,
|
|
2454
|
-
asyncFn: meta.asyncFn
|
|
2465
|
+
asyncFn: !!meta.asyncFn,
|
|
2455
2466
|
...map,
|
|
2456
2467
|
end: this.peekSourceMap()
|
|
2457
2468
|
};
|
|
@@ -2478,7 +2489,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
2478
2489
|
else { // 引数の個数が違う
|
|
2479
2490
|
throw NakoSyntaxError.fromNode(`関数『${funcToken.value}』で引数${args.length}個が指定されましたが、${meta.josi.length}個の引数を指定してください。`, funcToken);
|
|
2480
2491
|
}
|
|
2481
|
-
asyncFn = meta.asyncFn
|
|
2492
|
+
asyncFn = !!meta.asyncFn;
|
|
2482
2493
|
}
|
|
2483
2494
|
return {
|
|
2484
2495
|
type: 'func',
|
|
@@ -2634,7 +2645,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
2634
2645
|
type: 'ref_prop', // プロパティ参照
|
|
2635
2646
|
name: word,
|
|
2636
2647
|
index: propList,
|
|
2637
|
-
josi
|
|
2648
|
+
josi,
|
|
2638
2649
|
...map,
|
|
2639
2650
|
end: this.peekSourceMap()
|
|
2640
2651
|
};
|
|
@@ -2687,7 +2698,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
2687
2698
|
const f = this.findVar(word.value);
|
|
2688
2699
|
if (!f) { // 変数が見つからない
|
|
2689
2700
|
if (this.funcLevel === 0 && word.value.indexOf('__') < 0) {
|
|
2690
|
-
word.value = this.modName + '__' + word.value;
|
|
2701
|
+
word.value = this.modName + '__' + String(word.value);
|
|
2691
2702
|
}
|
|
2692
2703
|
}
|
|
2693
2704
|
else if (f && f.scope === 'global') {
|
|
@@ -2723,21 +2734,18 @@ export class NakoParser extends NakoParserBase {
|
|
|
2723
2734
|
a.push(this.y[0]);
|
|
2724
2735
|
a.push(this.y[2]);
|
|
2725
2736
|
}
|
|
2726
|
-
// 'key' : value
|
|
2727
|
-
else if (this.accept(['string', ':', this.yCalc])) {
|
|
2737
|
+
else if (this.accept(['string', ':', this.yCalc])) { // 'key' : value
|
|
2728
2738
|
a.push(this.y[0]);
|
|
2729
2739
|
a.push(this.y[2]);
|
|
2730
2740
|
}
|
|
2731
|
-
// key
|
|
2732
|
-
else if (this.accept(['word'])) {
|
|
2741
|
+
else if (this.accept(['word'])) { // key
|
|
2733
2742
|
const key = this.y[0];
|
|
2734
2743
|
const val = JSON.parse(JSON.stringify(key));
|
|
2735
2744
|
key.type = 'string'; // キー名の文字列記号省略の場合
|
|
2736
2745
|
a.push(key);
|
|
2737
2746
|
a.push(val);
|
|
2738
2747
|
}
|
|
2739
|
-
// str or num
|
|
2740
|
-
else if (this.checkTypes(['string', 'number'])) {
|
|
2748
|
+
else if (this.checkTypes(['string', 'number'])) { // str or num
|
|
2741
2749
|
const w = this.getCur(); // Tokenを強制的にAstに変換している
|
|
2742
2750
|
a.push(w);
|
|
2743
2751
|
a.push(w);
|
|
@@ -2913,7 +2921,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
2913
2921
|
return false;
|
|
2914
2922
|
}
|
|
2915
2923
|
// 関数定義があれば関数
|
|
2916
|
-
if (node.type
|
|
2924
|
+
if (node.type === 'def_func' || node.type === 'def_test' || node.type === 'func_obj') {
|
|
2917
2925
|
// 関数定義でasyncFnが指定されているならtrueを返す
|
|
2918
2926
|
const def = node;
|
|
2919
2927
|
if (def.asyncFn) {
|
|
@@ -2932,7 +2940,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
2932
2940
|
}
|
|
2933
2941
|
}
|
|
2934
2942
|
// 関数呼び出しを調べて非同期処理が必要ならtrueを返す
|
|
2935
|
-
if (node.type
|
|
2943
|
+
if (node.type === 'func') {
|
|
2936
2944
|
// 関数呼び出し自体が非同期処理ならtrueを返す
|
|
2937
2945
|
const callNode = node;
|
|
2938
2946
|
if (callNode.asyncFn) {
|
|
@@ -2959,7 +2967,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
2959
2967
|
return false;
|
|
2960
2968
|
}
|
|
2961
2969
|
// 連文 ... 現在、効率は悪いが非同期で実行することになっている
|
|
2962
|
-
if (node.type
|
|
2970
|
+
if (node.type === 'renbun') {
|
|
2963
2971
|
return true;
|
|
2964
2972
|
}
|
|
2965
2973
|
// その他
|
|
@@ -2987,7 +2995,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
2987
2995
|
*/
|
|
2988
2996
|
_tokenToNode(token) {
|
|
2989
2997
|
const map = this.peekSourceMap(token);
|
|
2990
|
-
if (token.type === 'string' || token.type
|
|
2998
|
+
if (token.type === 'string' || token.type === 'number' || token.type === 'bigint') {
|
|
2991
2999
|
return this.yConst(token, map);
|
|
2992
3000
|
}
|
|
2993
3001
|
if (token.type === 'word') {
|