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
|
@@ -6,7 +6,7 @@ import { opPriority, RenbunJosi, operatorList } from './nako_parser_const.mjs'
|
|
|
6
6
|
import { NakoParserBase } from './nako_parser_base.mjs'
|
|
7
7
|
import { NakoSyntaxError } from './nako_errors.mjs'
|
|
8
8
|
import { NakoLexer } from './nako_lexer.mjs'
|
|
9
|
-
import {
|
|
9
|
+
import { FuncListItemType, FuncArgs, NewEmptyToken, SourceMap } from './nako_types.mjs'
|
|
10
10
|
import { NodeType, Ast, AstEol, AstBlocks, AstOperator, AstConst, AstLet, AstLetArray, AstIf, AstWhile, AstAtohantei, AstFor, AstForeach, AstSwitch, AstRepeatTimes, AstDefFunc, AstCallFunc, AstStrValue, AstDefVar, AstDefVarList } from './nako_ast.mjs'
|
|
11
11
|
import { Token, TokenDefFunc, TokenCallFunc } from './nako_token.mjs'
|
|
12
12
|
|
|
@@ -61,7 +61,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/** 複数文を返す */
|
|
64
|
-
ySentenceList(): AstBlocks {
|
|
64
|
+
ySentenceList (): AstBlocks {
|
|
65
65
|
const blocks = []
|
|
66
66
|
let line = -1
|
|
67
67
|
const map = this.peekSourceMap()
|
|
@@ -76,7 +76,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
76
76
|
this.logger.debug('構文解析に失敗:' + this.nodeToStr(this.peek(), { depth: 1 }, true), token)
|
|
77
77
|
throw NakoSyntaxError.fromNode('構文解析に失敗:' + this.nodeToStr(this.peek(), { depth: 1 }, false), token)
|
|
78
78
|
}
|
|
79
|
-
return { type: 'block', blocks
|
|
79
|
+
return { type: 'block', blocks, josi: '', ...map, end: this.peekSourceMap() }
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/** 余剰スタックのレポートを作る */
|
|
@@ -94,7 +94,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
94
94
|
for (const f of this.recentlyCalledFunc) {
|
|
95
95
|
descFunc += ' - '
|
|
96
96
|
let no = 0
|
|
97
|
-
const josiA: FuncArgs | undefined = (f
|
|
97
|
+
const josiA: FuncArgs | undefined = (f).josi
|
|
98
98
|
if (josiA) {
|
|
99
99
|
for (const arg of josiA) {
|
|
100
100
|
const ch = String.fromCharCode(chA + no)
|
|
@@ -103,13 +103,13 @@ export class NakoParser extends NakoParserBase {
|
|
|
103
103
|
no++
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
descFunc += f.name + '\n'
|
|
106
|
+
descFunc += String(f.name) + '\n'
|
|
107
107
|
}
|
|
108
108
|
this.recentlyCalledFunc = []
|
|
109
109
|
return `未解決の単語があります: [${desc}]\n次の命令の可能性があります:\n${descFunc}`
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
yEOL(): AstEol | null {
|
|
112
|
+
yEOL (): AstEol | null {
|
|
113
113
|
// 行末のチェック #1009
|
|
114
114
|
const eol = this.get()
|
|
115
115
|
if (!eol) { return null }
|
|
@@ -124,7 +124,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
124
124
|
comment: eol.value,
|
|
125
125
|
line: eol.line,
|
|
126
126
|
column: eol.column,
|
|
127
|
-
file: eol.file
|
|
127
|
+
file: eol.file
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
|
|
@@ -145,7 +145,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
145
145
|
if (this.accept(['DNCL2モード'])) { return this.yDNCLMode(2) }
|
|
146
146
|
if (this.accept(['not', 'string', 'モード設定'])) { return this.ySetGenMode(this.y[1].value) }
|
|
147
147
|
if (this.accept(['not', 'モジュール公開既定値', 'eq', 'string'])) { return this.yExportDefault(this.y[3].value) }
|
|
148
|
-
if (this.accept(['not', '厳チェック'])) { return this.ySetMode('厳しくチェック') } // (#1698)
|
|
148
|
+
if (this.accept(['not', '厳チェック'])) { return this.ySetMode('厳しくチェック') } // (#1698)
|
|
149
149
|
// (memo) 現状「取込」はプリプロセス段階(NakoCompiler.listRequireStatements)で処理される
|
|
150
150
|
// if (this.accept(['require', 'string', '取込'])) { return this.yRequire() }
|
|
151
151
|
// <廃止された構文>
|
|
@@ -241,7 +241,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
/** @returns {AstBlocks} */
|
|
244
|
-
yBlock(): AstBlocks {
|
|
244
|
+
yBlock (): AstBlocks {
|
|
245
245
|
const map = this.peekSourceMap()
|
|
246
246
|
const blocks = []
|
|
247
247
|
if (this.check('ここから')) { this.get() }
|
|
@@ -250,7 +250,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
250
250
|
if (!this.accept([this.ySentence])) { break }
|
|
251
251
|
blocks.push(this.y[0])
|
|
252
252
|
}
|
|
253
|
-
return { type: 'block', blocks
|
|
253
|
+
return { type: 'block', blocks, josi: '', ...map, end: this.peekSourceMap() }
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
yDefFuncReadArgs (): Ast[]|null {
|
|
@@ -280,7 +280,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
280
280
|
/** ユーザー関数の定義
|
|
281
281
|
* @returns {AstDefFunc | null}
|
|
282
282
|
*/
|
|
283
|
-
yDefFuncCommon(type: NodeType): AstDefFunc | null {
|
|
283
|
+
yDefFuncCommon (type: NodeType): AstDefFunc | null {
|
|
284
284
|
if (!this.check(type)) { // yDefFuncから呼ばれれば def_func なのかをチェックする
|
|
285
285
|
return null
|
|
286
286
|
}
|
|
@@ -344,7 +344,16 @@ export class NakoParser extends NakoParserBase {
|
|
|
344
344
|
this.localvars.set(fnName, { 'type': 'var', 'value': '' })
|
|
345
345
|
}
|
|
346
346
|
block = this.yBlock()
|
|
347
|
-
|
|
347
|
+
// 「ここまで」のチェック
|
|
348
|
+
if (this.check('ここまで')) {
|
|
349
|
+
this.get() // skip 'ここまで'
|
|
350
|
+
} else {
|
|
351
|
+
// 「ここまで」が見当たらない
|
|
352
|
+
const nextWordO = this.peek()
|
|
353
|
+
let nextWord = JSON.stringify(nextWordO)
|
|
354
|
+
if (nextWordO && nextWordO.type && nextWordO.value) { nextWord = nextWordO.value }
|
|
355
|
+
throw NakoSyntaxError.fromNode(`『ここまで』がありません。関数定義の末尾に必要です。『${nextWord}』の前に『ここまで』を記述してください。`, def)
|
|
356
|
+
}
|
|
348
357
|
this.loadStack()
|
|
349
358
|
} else {
|
|
350
359
|
this.saveStack()
|
|
@@ -356,9 +365,9 @@ export class NakoParser extends NakoParserBase {
|
|
|
356
365
|
this.localvars = backupLocalvars
|
|
357
366
|
} catch (err: any) {
|
|
358
367
|
this.logger.debug(this.nodeToStr(funcName, { depth: 0, typeName: '関数' }, true) +
|
|
359
|
-
'の定義で以下のエラーがありました。\n' + err.message, def)
|
|
368
|
+
'の定義で以下のエラーがありました。\n' + String(err.message), def)
|
|
360
369
|
throw NakoSyntaxError.fromNode(this.nodeToStr(funcName, { depth: 0, typeName: '関数' }, false) +
|
|
361
|
-
'の定義で以下のエラーがありました。\n' + err.message, def)
|
|
370
|
+
'の定義で以下のエラーがありました。\n' + String(err.message), def)
|
|
362
371
|
}
|
|
363
372
|
const func = this.funclist.get(funcName.value)
|
|
364
373
|
if (func && !func.asyncFn && asyncFn) {
|
|
@@ -390,7 +399,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
390
399
|
// チェック : Aならば
|
|
391
400
|
if (a.josi === 'ならば') { return a }
|
|
392
401
|
if (a.josi === 'でなければ') {
|
|
393
|
-
a = { type: 'not', operator: 'not', blocks:[a], josi: '', ...map, end: this.peekSourceMap() } as AstOperator
|
|
402
|
+
a = { type: 'not', operator: 'not', blocks: [a], josi: '', ...map, end: this.peekSourceMap() } as AstOperator
|
|
394
403
|
return a
|
|
395
404
|
}
|
|
396
405
|
// チェック : AがBならば --- 「関数B(A)」のとき
|
|
@@ -470,7 +479,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
470
479
|
try {
|
|
471
480
|
expr = this.yIFCond()
|
|
472
481
|
} catch (err: any) {
|
|
473
|
-
throw NakoSyntaxError.fromNode('『もし』文の条件で次のエラーがあります。\n' + err.message, mosi)
|
|
482
|
+
throw NakoSyntaxError.fromNode('『もし』文の条件で次のエラーがあります。\n' + String(err.message), mosi)
|
|
474
483
|
}
|
|
475
484
|
return this.yIfThen(expr, map)
|
|
476
485
|
}
|
|
@@ -503,7 +512,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
503
512
|
if (this.check('eol')) {
|
|
504
513
|
falseBlock = this.yBlock()
|
|
505
514
|
} else {
|
|
506
|
-
const block: Ast|null = this.ySentence()
|
|
515
|
+
const block: Ast|null = this.ySentence()
|
|
507
516
|
if (block) { falseBlock = block }
|
|
508
517
|
tanbun = true
|
|
509
518
|
}
|
|
@@ -671,7 +680,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
671
680
|
|
|
672
681
|
/**
|
|
673
682
|
* 範囲(関数)を返す
|
|
674
|
-
* @param kara
|
|
683
|
+
* @param kara
|
|
675
684
|
* @returns {AstCallFunc | null}
|
|
676
685
|
*/
|
|
677
686
|
yRange (kara: Ast): AstCallFunc | null {
|
|
@@ -832,7 +841,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
832
841
|
}
|
|
833
842
|
|
|
834
843
|
/** @returns {AstRepeatTimes | null} */
|
|
835
|
-
yRepeatTime(): AstRepeatTimes | null {
|
|
844
|
+
yRepeatTime (): AstRepeatTimes | null {
|
|
836
845
|
const map = this.peekSourceMap()
|
|
837
846
|
if (!this.check('回')) { return null }
|
|
838
847
|
this.get() // skip '回'
|
|
@@ -866,7 +875,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
866
875
|
}
|
|
867
876
|
|
|
868
877
|
/** @returns {AstWhile | null} */
|
|
869
|
-
yWhile(): AstWhile | null { // 「*の間」文
|
|
878
|
+
yWhile (): AstWhile | null { // 「*の間」文
|
|
870
879
|
const map = this.peekSourceMap()
|
|
871
880
|
if (!this.check('間')) { return null }
|
|
872
881
|
this.get() // skip '間'
|
|
@@ -896,7 +905,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
896
905
|
}
|
|
897
906
|
|
|
898
907
|
/** @returns {AstAtohantei | null} */
|
|
899
|
-
yAtohantei(): AstAtohantei |null {
|
|
908
|
+
yAtohantei (): AstAtohantei |null {
|
|
900
909
|
const map = this.peekSourceMap()
|
|
901
910
|
if (this.check('後判定')) { this.get() } // skip 後判定
|
|
902
911
|
if (this.check('繰返')) { this.get() } // skip 繰り返す
|
|
@@ -922,7 +931,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
922
931
|
end: this.peekSourceMap()
|
|
923
932
|
} as AstOperator
|
|
924
933
|
}
|
|
925
|
-
if (!cond) { cond = {type: 'number', value: 1, josi: '', ...map, end: this.peekSourceMap()} as AstConst }
|
|
934
|
+
if (!cond) { cond = { type: 'number', value: 1, josi: '', ...map, end: this.peekSourceMap() } as AstConst }
|
|
926
935
|
return {
|
|
927
936
|
type: 'atohantei',
|
|
928
937
|
blocks: [cond, block],
|
|
@@ -950,10 +959,10 @@ export class NakoParser extends NakoParserBase {
|
|
|
950
959
|
if (incdec) {
|
|
951
960
|
if (incdec.type === 'word' && (incdec.value === '増' || incdec.value === '減')) {
|
|
952
961
|
if (incdec.value === '増') { flagDown = false } else { flagUp = false }
|
|
953
|
-
const w = incdec.value + kurikaesu.type
|
|
954
|
-
if (w
|
|
955
|
-
kurikaesu.type =
|
|
956
|
-
} else if (w
|
|
962
|
+
const w = String(incdec.value) + kurikaesu.type
|
|
963
|
+
if (w === '増繰返') {
|
|
964
|
+
kurikaesu.type = '増繰返'
|
|
965
|
+
} else if (w === '減繰返') {
|
|
957
966
|
kurikaesu.type = '減繰返'
|
|
958
967
|
} else {
|
|
959
968
|
throw Error('[System Error] 増繰り返し | 減繰り返しのエラー。')
|
|
@@ -972,7 +981,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
972
981
|
const vTo = this.popStack(['まで', 'を']) // 範囲オブジェクトの場合もあり
|
|
973
982
|
const vFrom = this.popStack(['から']) || this.yNop()
|
|
974
983
|
const vWord: Ast|null = this.popStack(['を', 'で'])
|
|
975
|
-
let wordStr
|
|
984
|
+
let wordStr = ''
|
|
976
985
|
if (vWord !== null) { // 変数
|
|
977
986
|
if (vWord.type !== 'word') {
|
|
978
987
|
throw NakoSyntaxError.fromNode('『(変数名)をAからBまで繰り返す』で指定してください。', vWord)
|
|
@@ -1008,7 +1017,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
1008
1017
|
const b = this.ySentence()
|
|
1009
1018
|
if (b) { block = b }
|
|
1010
1019
|
}
|
|
1011
|
-
|
|
1020
|
+
|
|
1012
1021
|
if (!block) { block = this.yNop() }
|
|
1013
1022
|
|
|
1014
1023
|
return {
|
|
@@ -1025,7 +1034,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
1025
1034
|
}
|
|
1026
1035
|
|
|
1027
1036
|
/** @returns {AstBlocks | null} */
|
|
1028
|
-
yReturn(): AstBlocks | null {
|
|
1037
|
+
yReturn (): AstBlocks | null {
|
|
1029
1038
|
const map = this.peekSourceMap()
|
|
1030
1039
|
if (!this.check('戻る')) { return null }
|
|
1031
1040
|
this.get() // skip '戻る'
|
|
@@ -1043,7 +1052,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
1043
1052
|
}
|
|
1044
1053
|
|
|
1045
1054
|
/** @returns {AstForeach | null} */
|
|
1046
|
-
yForEach(): AstForeach |null {
|
|
1055
|
+
yForEach (): AstForeach |null {
|
|
1047
1056
|
const map = this.peekSourceMap()
|
|
1048
1057
|
if (!this.check('反復')) { return null }
|
|
1049
1058
|
this.get() // skip '反復'
|
|
@@ -1051,7 +1060,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
1051
1060
|
const target = this.popStack(['を']) || this.yNop()
|
|
1052
1061
|
// target == null なら「それ」の値が使われる
|
|
1053
1062
|
const name = this.popStack(['で'])
|
|
1054
|
-
let wordStr
|
|
1063
|
+
let wordStr = ''
|
|
1055
1064
|
if (name !== null) {
|
|
1056
1065
|
if (name.type !== 'word') {
|
|
1057
1066
|
throw NakoSyntaxError.fromNode('『(変数名)で(配列)を反復』で指定してください。', map)
|
|
@@ -1154,7 +1163,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
1154
1163
|
blocks.push(cond)
|
|
1155
1164
|
blocks.push(condBlock)
|
|
1156
1165
|
}
|
|
1157
|
-
|
|
1166
|
+
|
|
1158
1167
|
const ast: AstSwitch = {
|
|
1159
1168
|
type: 'switch',
|
|
1160
1169
|
blocks,
|
|
@@ -1216,11 +1225,14 @@ export class NakoParser extends NakoParserBase {
|
|
|
1216
1225
|
const map = this.peekSourceMap()
|
|
1217
1226
|
const dainyu = this.get() // 代入
|
|
1218
1227
|
if (dainyu === null) { return null }
|
|
1219
|
-
const value = this.popStack(['を']) || {type: 'word', value: 'それ', josi: 'を', ...map} as AstStrValue
|
|
1228
|
+
const value = this.popStack(['を']) || { type: 'word', value: 'それ', josi: 'を', ...map } as AstStrValue
|
|
1220
1229
|
const word: Ast|null = this.popStack(['へ', 'に'])
|
|
1221
1230
|
if (!word || (word.type !== 'word' && word.type !== 'func' && word.type !== 'ref_array')) {
|
|
1222
1231
|
throw NakoSyntaxError.fromNode('代入文で代入先の変数が見当たりません。『(変数名)に(値)を代入』のように使います。', dainyu)
|
|
1223
1232
|
}
|
|
1233
|
+
if (word.type === 'func') {
|
|
1234
|
+
throw NakoSyntaxError.fromNode('関数『' + String(word.name) + '』に代入できません。『(変数名)に(値)を代入』のように使います。', dainyu)
|
|
1235
|
+
}
|
|
1224
1236
|
// 配列への代入
|
|
1225
1237
|
if (word.type === 'ref_array') {
|
|
1226
1238
|
const indexArray = word.index || []
|
|
@@ -1311,8 +1323,8 @@ export class NakoParser extends NakoParserBase {
|
|
|
1311
1323
|
|
|
1312
1324
|
// 減らすなら-1かける
|
|
1313
1325
|
if (action.value === '減') {
|
|
1314
|
-
const
|
|
1315
|
-
value = { type: 'op', operator: '*', blocks: [value,
|
|
1326
|
+
const minusOne = { type: 'number', value: -1, line: action.line } as AstConst
|
|
1327
|
+
value = { type: 'op', operator: '*', blocks: [value, minusOne], josi: '', ...map } as AstOperator
|
|
1316
1328
|
}
|
|
1317
1329
|
|
|
1318
1330
|
return {
|
|
@@ -1486,7 +1498,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
1486
1498
|
blocks: args,
|
|
1487
1499
|
meta: f,
|
|
1488
1500
|
josi: t.josi,
|
|
1489
|
-
asyncFn: f.asyncFn
|
|
1501
|
+
asyncFn: !!f.asyncFn,
|
|
1490
1502
|
...map,
|
|
1491
1503
|
end: this.peekSourceMap()
|
|
1492
1504
|
}
|
|
@@ -1494,8 +1506,8 @@ export class NakoParser extends NakoParserBase {
|
|
|
1494
1506
|
// 「プラグイン名設定」ならば、そこでスコープを変更することを意味する (#1112)
|
|
1495
1507
|
if (funcNode.name === 'プラグイン名設定') {
|
|
1496
1508
|
if (args.length > 0 && args[0]) {
|
|
1497
|
-
let fname
|
|
1498
|
-
if (fname === 'メイン') { fname =
|
|
1509
|
+
let fname = String(args[0].value)
|
|
1510
|
+
if (fname === 'メイン') { fname = String(args[0].file) }
|
|
1499
1511
|
this.namespaceStack.push(this.modName)
|
|
1500
1512
|
this.isExportStack.push(this.isExportDefault)
|
|
1501
1513
|
this.modName = NakoLexer.filenameToModName(fname)
|
|
@@ -1608,7 +1620,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
1608
1620
|
if (this.accept(['word', 'とは'])) {
|
|
1609
1621
|
const wordToken = this.y[0]
|
|
1610
1622
|
if (!this.checkTypes(['変数', '定数'])) {
|
|
1611
|
-
throw NakoSyntaxError.fromNode('ローカル変数『' + wordToken.value + '』の定義エラー', wordToken)
|
|
1623
|
+
throw NakoSyntaxError.fromNode('ローカル変数『' + String(wordToken.value) + '』の定義エラー', wordToken)
|
|
1612
1624
|
}
|
|
1613
1625
|
const vtype = this.getCur() // 変数 or 定数
|
|
1614
1626
|
let isExport : boolean = this.isExportDefault
|
|
@@ -1616,7 +1628,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
1616
1628
|
this.get()
|
|
1617
1629
|
const attrNode = this.get()
|
|
1618
1630
|
if (attrNode === null) {
|
|
1619
|
-
throw NakoSyntaxError.fromNode('ローカル変数『' + wordToken.value + '』の定義エラー', wordToken)
|
|
1631
|
+
throw NakoSyntaxError.fromNode('ローカル変数『' + String(wordToken.value) + '』の定義エラー', wordToken)
|
|
1620
1632
|
}
|
|
1621
1633
|
const attr = attrNode.value
|
|
1622
1634
|
if (attr === '公開') { isExport = true } else if (attr === '非公開') { isExport = false } else if (attr === 'エクスポート') { isExport = true } else { this.logger.warn(`不明な変数属性『${attr}』が指定されています。`) }
|
|
@@ -1691,9 +1703,10 @@ export class NakoParser extends NakoParserBase {
|
|
|
1691
1703
|
}
|
|
1692
1704
|
}
|
|
1693
1705
|
|
|
1694
|
-
if (this.accept(['定数', 'word', 'eq'
|
|
1695
|
-
const
|
|
1696
|
-
const
|
|
1706
|
+
if (this.accept(['定数', 'word', 'eq'])) {
|
|
1707
|
+
const constName = this.y[1]
|
|
1708
|
+
const word = this.createVar(constName, true, this.isExportDefault)
|
|
1709
|
+
const astValue = this.yCalc() || this.yNop()
|
|
1697
1710
|
return {
|
|
1698
1711
|
type: 'def_local_var',
|
|
1699
1712
|
name: (word as AstStrValue).value,
|
|
@@ -1704,12 +1717,12 @@ export class NakoParser extends NakoParserBase {
|
|
|
1704
1717
|
} as AstDefVar
|
|
1705
1718
|
}
|
|
1706
1719
|
|
|
1707
|
-
if (this.accept(['定数', 'word', '{', 'word', '}', 'eq'
|
|
1720
|
+
if (this.accept(['定数', 'word', '{', 'word', '}', 'eq'])) {
|
|
1708
1721
|
let isExport : boolean = this.isExportDefault
|
|
1709
1722
|
const attr = this.y[3].value
|
|
1710
1723
|
if (attr === '公開') { isExport = true } else if (attr === '非公開') { isExport = false } else if (attr === 'エクスポート') { isExport = true } else { this.logger.warn(`不明な定数属性『${attr}』が指定されています。`) }
|
|
1711
1724
|
const word = this.createVar(this.y[1], true, isExport)
|
|
1712
|
-
const astValue = this.
|
|
1725
|
+
const astValue = this.yCalc() || this.yNop()
|
|
1713
1726
|
return {
|
|
1714
1727
|
type: 'def_local_var',
|
|
1715
1728
|
name: (word as AstStrValue).value,
|
|
@@ -1722,20 +1735,20 @@ export class NakoParser extends NakoParserBase {
|
|
|
1722
1735
|
}
|
|
1723
1736
|
|
|
1724
1737
|
// 複数定数への代入 #563
|
|
1725
|
-
if (this.accept(['定数', this.yJSONArray, 'eq'
|
|
1738
|
+
if (this.accept(['定数', this.yJSONArray, 'eq'])) {
|
|
1726
1739
|
const names = this.y[1]
|
|
1727
1740
|
// check array
|
|
1728
1741
|
if (names && names.blocks instanceof Array) {
|
|
1729
1742
|
for (const i in names.blocks) {
|
|
1730
1743
|
if (names.blocks[i].type !== 'word') {
|
|
1731
|
-
throw NakoSyntaxError.fromNode(`複数定数の代入文${i + 1}番目でエラー。『定数[A,B,C]=[1,2,3]』の書式で記述してください。`, this.y[0])
|
|
1744
|
+
throw NakoSyntaxError.fromNode(`複数定数の代入文${Number(i) + 1}番目でエラー。『定数[A,B,C]=[1,2,3]』の書式で記述してください。`, this.y[0])
|
|
1732
1745
|
}
|
|
1733
1746
|
}
|
|
1734
1747
|
} else {
|
|
1735
1748
|
throw NakoSyntaxError.fromNode('複数定数の代入文でエラー。『定数[A,B,C]=[1,2,3]』の書式で記述してください。', this.y[0])
|
|
1736
1749
|
}
|
|
1737
1750
|
const namesAst = this._tokensToNodes(this.createVarList(names.blocks, true, this.isExportDefault))
|
|
1738
|
-
const astValue = this.
|
|
1751
|
+
const astValue = this.yCalc() || this.yNop()
|
|
1739
1752
|
return {
|
|
1740
1753
|
type: 'def_local_varlist',
|
|
1741
1754
|
names: namesAst,
|
|
@@ -1746,20 +1759,20 @@ export class NakoParser extends NakoParserBase {
|
|
|
1746
1759
|
} as AstDefVarList
|
|
1747
1760
|
}
|
|
1748
1761
|
// 複数変数への代入 #563
|
|
1749
|
-
if (this.accept(['変数', this.yJSONArray, 'eq'
|
|
1762
|
+
if (this.accept(['変数', this.yJSONArray, 'eq'])) {
|
|
1750
1763
|
const names: AstBlocks = this.y[1]
|
|
1751
1764
|
// check array
|
|
1752
1765
|
if (names && names.blocks instanceof Array) {
|
|
1753
|
-
|
|
1754
|
-
if (
|
|
1755
|
-
throw NakoSyntaxError.fromNode(`複数変数の代入文${
|
|
1766
|
+
names.blocks.forEach((block, index) => {
|
|
1767
|
+
if (block.type !== 'word') {
|
|
1768
|
+
throw NakoSyntaxError.fromNode(`複数変数の代入文${String(index + 1)}番目でエラー『変数[A,B,C]=[1,2,3]』の書式で記述してください。`, this.y[0])
|
|
1756
1769
|
}
|
|
1757
|
-
}
|
|
1770
|
+
})
|
|
1758
1771
|
} else {
|
|
1759
1772
|
throw NakoSyntaxError.fromNode('複数変数の代入文でエラー。『変数[A,B,C]=[1,2,3]』の書式で記述してください。', this.y[0])
|
|
1760
1773
|
}
|
|
1761
1774
|
const namesAst = this._tokensToNodes(this.createVarList(names.blocks as Token[], false, this.isExportDefault))
|
|
1762
|
-
const astValue = this.
|
|
1775
|
+
const astValue = this.yCalc() || this.yNop()
|
|
1763
1776
|
return {
|
|
1764
1777
|
type: 'def_local_varlist',
|
|
1765
1778
|
names: namesAst,
|
|
@@ -1773,10 +1786,10 @@ export class NakoParser extends NakoParserBase {
|
|
|
1773
1786
|
// 複数変数への代入 #563
|
|
1774
1787
|
if (this.check2(['word', 'comma', 'word'])) {
|
|
1775
1788
|
// 2 word
|
|
1776
|
-
if (this.accept(['word', 'comma', 'word', 'eq'
|
|
1789
|
+
if (this.accept(['word', 'comma', 'word', 'eq'])) {
|
|
1777
1790
|
let names = [this.y[0], this.y[2]]
|
|
1778
1791
|
names = this.createVarList(names, false, this.isExportDefault)
|
|
1779
|
-
const astValue = this.
|
|
1792
|
+
const astValue = this.yCalc() || this.yNop()
|
|
1780
1793
|
return {
|
|
1781
1794
|
type: 'def_local_varlist',
|
|
1782
1795
|
names,
|
|
@@ -1787,10 +1800,10 @@ export class NakoParser extends NakoParserBase {
|
|
|
1787
1800
|
} as AstDefVarList
|
|
1788
1801
|
}
|
|
1789
1802
|
// 3 word
|
|
1790
|
-
if (this.accept(['word', 'comma', 'word', 'comma', 'word', 'eq'
|
|
1803
|
+
if (this.accept(['word', 'comma', 'word', 'comma', 'word', 'eq'])) {
|
|
1791
1804
|
let names = [this.y[0], this.y[2], this.y[4]]
|
|
1792
1805
|
names = this.createVarList(names, false, this.isExportDefault)
|
|
1793
|
-
const astValue = this.
|
|
1806
|
+
const astValue = this.yCalc() || this.yNop()
|
|
1794
1807
|
return {
|
|
1795
1808
|
type: 'def_local_varlist',
|
|
1796
1809
|
names,
|
|
@@ -1801,10 +1814,10 @@ export class NakoParser extends NakoParserBase {
|
|
|
1801
1814
|
} as AstDefVarList
|
|
1802
1815
|
}
|
|
1803
1816
|
// 4 word
|
|
1804
|
-
if (this.accept(['word', 'comma', 'word', 'comma', 'word', 'comma', 'word', 'eq'
|
|
1817
|
+
if (this.accept(['word', 'comma', 'word', 'comma', 'word', 'comma', 'word', 'eq'])) {
|
|
1805
1818
|
let names = [this.y[0], this.y[2], this.y[4], this.y[6]]
|
|
1806
1819
|
names = this.createVarList(names, false, this.isExportDefault)
|
|
1807
|
-
const astValue = this.
|
|
1820
|
+
const astValue = this.yCalc() || this.yNop()
|
|
1808
1821
|
return {
|
|
1809
1822
|
type: 'def_local_varlist',
|
|
1810
1823
|
names,
|
|
@@ -1815,10 +1828,10 @@ export class NakoParser extends NakoParserBase {
|
|
|
1815
1828
|
} as AstDefVarList
|
|
1816
1829
|
}
|
|
1817
1830
|
// 5 word
|
|
1818
|
-
if (this.accept(['word', 'comma', 'word', 'comma', 'word', 'comma', 'word', 'comma', 'word', 'eq'
|
|
1831
|
+
if (this.accept(['word', 'comma', 'word', 'comma', 'word', 'comma', 'word', 'comma', 'word', 'eq'])) {
|
|
1819
1832
|
let names = [this.y[0], this.y[2], this.y[4], this.y[6], this.y[8]]
|
|
1820
1833
|
names = this.createVarList(names, false, this.isExportDefault)
|
|
1821
|
-
const astValue = this.
|
|
1834
|
+
const astValue = this.yCalc() || this.yNop()
|
|
1822
1835
|
return {
|
|
1823
1836
|
type: 'def_local_varlist',
|
|
1824
1837
|
names,
|
|
@@ -1841,16 +1854,16 @@ export class NakoParser extends NakoParserBase {
|
|
|
1841
1854
|
// 配列が0から始まるのであればそのまま返す
|
|
1842
1855
|
if (this.arrayIndexFrom === 0) { return node }
|
|
1843
1856
|
// 配列が1から始まるのであれば演算を加えて返す
|
|
1844
|
-
const
|
|
1857
|
+
const minusNum = {
|
|
1845
1858
|
...node,
|
|
1846
1859
|
'type': 'number',
|
|
1847
1860
|
'value': this.arrayIndexFrom
|
|
1848
|
-
}
|
|
1861
|
+
}
|
|
1849
1862
|
return {
|
|
1850
1863
|
...node,
|
|
1851
1864
|
type: 'op',
|
|
1852
1865
|
operator: '-',
|
|
1853
|
-
blocks: [node,
|
|
1866
|
+
blocks: [node, minusNum]
|
|
1854
1867
|
} as AstOperator
|
|
1855
1868
|
}
|
|
1856
1869
|
|
|
@@ -2093,7 +2106,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
2093
2106
|
...map
|
|
2094
2107
|
}
|
|
2095
2108
|
return astConst
|
|
2096
|
-
}
|
|
2109
|
+
}
|
|
2097
2110
|
|
|
2098
2111
|
/** @returns {Ast | null} */
|
|
2099
2112
|
yValue (): Ast | null {
|
|
@@ -2169,7 +2182,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
2169
2182
|
blocks: args,
|
|
2170
2183
|
josi: f.josi,
|
|
2171
2184
|
meta,
|
|
2172
|
-
asyncFn: meta.asyncFn
|
|
2185
|
+
asyncFn: !!meta.asyncFn,
|
|
2173
2186
|
...map,
|
|
2174
2187
|
end: this.peekSourceMap()
|
|
2175
2188
|
} as AstCallFunc
|
|
@@ -2194,7 +2207,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
2194
2207
|
} else { // 引数の個数が違う
|
|
2195
2208
|
throw NakoSyntaxError.fromNode(`関数『${funcToken.value}』で引数${args.length}個が指定されましたが、${meta.josi.length}個の引数を指定してください。`, funcToken)
|
|
2196
2209
|
}
|
|
2197
|
-
asyncFn = meta.asyncFn
|
|
2210
|
+
asyncFn = !!meta.asyncFn
|
|
2198
2211
|
}
|
|
2199
2212
|
return {
|
|
2200
2213
|
type: 'func',
|
|
@@ -2339,7 +2352,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
2339
2352
|
type: 'ref_prop', // プロパティ参照
|
|
2340
2353
|
name: word,
|
|
2341
2354
|
index: propList,
|
|
2342
|
-
josi
|
|
2355
|
+
josi,
|
|
2343
2356
|
...map,
|
|
2344
2357
|
end: this.peekSourceMap()
|
|
2345
2358
|
}
|
|
@@ -2390,7 +2403,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
2390
2403
|
const f = this.findVar(word.value)
|
|
2391
2404
|
if (!f) { // 変数が見つからない
|
|
2392
2405
|
if (this.funcLevel === 0 && word.value.indexOf('__') < 0) {
|
|
2393
|
-
word.value = this.modName + '__' + word.value
|
|
2406
|
+
word.value = this.modName + '__' + String(word.value)
|
|
2394
2407
|
}
|
|
2395
2408
|
} else if (f && f.scope === 'global') {
|
|
2396
2409
|
word.value = f.name
|
|
@@ -2415,39 +2428,32 @@ export class NakoParser extends NakoParserBase {
|
|
|
2415
2428
|
while (!this.isEOF()) {
|
|
2416
2429
|
while (this.check('eol')) { this.get() }
|
|
2417
2430
|
if (this.check('}')) { break }
|
|
2418
|
-
|
|
2431
|
+
|
|
2419
2432
|
// key : value
|
|
2420
2433
|
if (this.accept(['word', ':', this.yCalc])) {
|
|
2421
2434
|
this.y[0].type = 'string' // キー名の文字列記号省略の場合
|
|
2422
2435
|
a.push(this.y[0])
|
|
2423
2436
|
a.push(this.y[2])
|
|
2424
|
-
}
|
|
2425
|
-
// 'key' : value
|
|
2426
|
-
else if (this.accept(['string', ':', this.yCalc])) {
|
|
2437
|
+
} else if (this.accept(['string', ':', this.yCalc])) { // 'key' : value
|
|
2427
2438
|
a.push(this.y[0])
|
|
2428
2439
|
a.push(this.y[2])
|
|
2429
|
-
}
|
|
2430
|
-
// key
|
|
2431
|
-
else if (this.accept(['word'])) {
|
|
2440
|
+
} else if (this.accept(['word'])) { // key
|
|
2432
2441
|
const key = this.y[0]
|
|
2433
2442
|
const val = JSON.parse(JSON.stringify(key)) as Ast
|
|
2434
2443
|
key.type = 'string' // キー名の文字列記号省略の場合
|
|
2435
2444
|
a.push(key)
|
|
2436
2445
|
a.push(val)
|
|
2437
|
-
}
|
|
2438
|
-
// str or num
|
|
2439
|
-
else if (this.checkTypes(['string', 'number'])) {
|
|
2446
|
+
} else if (this.checkTypes(['string', 'number'])) { // str or num
|
|
2440
2447
|
const w = this.getCur() as Ast // Tokenを強制的にAstに変換している
|
|
2441
2448
|
a.push(w)
|
|
2442
2449
|
a.push(w)
|
|
2443
|
-
}
|
|
2444
|
-
else { throw NakoSyntaxError.fromNode('辞書オブジェクトの宣言で末尾の『}』がありません。', firstToken) }
|
|
2450
|
+
} else { throw NakoSyntaxError.fromNode('辞書オブジェクトの宣言で末尾の『}』がありません。', firstToken) }
|
|
2445
2451
|
if (this.check('comma')) { this.get() }
|
|
2446
2452
|
}
|
|
2447
2453
|
return a
|
|
2448
2454
|
}
|
|
2449
2455
|
|
|
2450
|
-
yJSONObject(): AstBlocks | Ast | null {
|
|
2456
|
+
yJSONObject (): AstBlocks | Ast | null {
|
|
2451
2457
|
const a = this.yJSONObjectRaw()
|
|
2452
2458
|
if (!a) { return null }
|
|
2453
2459
|
// 配列の直後に@や[]があるか?助詞がある場合には、別の引数の可能性があるので無視。 (例) [0,1,2]を[3,4,5]に配列***
|
|
@@ -2518,7 +2524,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
2518
2524
|
return a
|
|
2519
2525
|
}
|
|
2520
2526
|
|
|
2521
|
-
yJSONArray(): AstBlocks | Ast | null {
|
|
2527
|
+
yJSONArray (): AstBlocks | Ast | null {
|
|
2522
2528
|
// 配列を得る
|
|
2523
2529
|
const a = this.yJSONArrayRaw()
|
|
2524
2530
|
if (!a) { return null }
|
|
@@ -2605,7 +2611,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
2605
2611
|
_checkAsyncFn (node: Ast): boolean {
|
|
2606
2612
|
if (!node) { return false }
|
|
2607
2613
|
// 関数定義があれば関数
|
|
2608
|
-
if (node.type
|
|
2614
|
+
if (node.type === 'def_func' || node.type === 'def_test' || node.type === 'func_obj') {
|
|
2609
2615
|
// 関数定義でasyncFnが指定されているならtrueを返す
|
|
2610
2616
|
const def: AstDefFunc = node as AstDefFunc
|
|
2611
2617
|
if (def.asyncFn) { return true } // 既にasyncFnが指定されている
|
|
@@ -2622,7 +2628,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
2622
2628
|
}
|
|
2623
2629
|
}
|
|
2624
2630
|
// 関数呼び出しを調べて非同期処理が必要ならtrueを返す
|
|
2625
|
-
if (node.type
|
|
2631
|
+
if (node.type === 'func') {
|
|
2626
2632
|
// 関数呼び出し自体が非同期処理ならtrueを返す
|
|
2627
2633
|
const callNode: AstCallFunc = node as AstCallFunc
|
|
2628
2634
|
if (callNode.asyncFn) {
|
|
@@ -2649,7 +2655,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
2649
2655
|
return false
|
|
2650
2656
|
}
|
|
2651
2657
|
// 連文 ... 現在、効率は悪いが非同期で実行することになっている
|
|
2652
|
-
if (node.type
|
|
2658
|
+
if (node.type === 'renbun') {
|
|
2653
2659
|
return true
|
|
2654
2660
|
}
|
|
2655
2661
|
// その他
|
|
@@ -2666,7 +2672,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
2666
2672
|
/** TokenをそのままNodeに変換するメソッド(ただし簡単なものだけ対応)
|
|
2667
2673
|
* @returns {Ast[]}
|
|
2668
2674
|
*/
|
|
2669
|
-
_tokensToNodes(tokens: Token[]): Ast[] {
|
|
2675
|
+
_tokensToNodes (tokens: Token[]): Ast[] {
|
|
2670
2676
|
const nodes: Ast[] = []
|
|
2671
2677
|
for (const token of tokens) {
|
|
2672
2678
|
nodes.push(this._tokenToNode(token))
|
|
@@ -2677,9 +2683,9 @@ export class NakoParser extends NakoParserBase {
|
|
|
2677
2683
|
/** TokenをそのままNodeに変換するメソッド(ただし簡単なものだけ対応)
|
|
2678
2684
|
* @returns {Ast}
|
|
2679
2685
|
*/
|
|
2680
|
-
_tokenToNode(token: Token): Ast {
|
|
2686
|
+
_tokenToNode (token: Token): Ast {
|
|
2681
2687
|
const map = this.peekSourceMap(token)
|
|
2682
|
-
if (token.type === 'string' || token.type
|
|
2688
|
+
if (token.type === 'string' || token.type === 'number' || token.type === 'bigint') {
|
|
2683
2689
|
return this.yConst(token, map)
|
|
2684
2690
|
}
|
|
2685
2691
|
if (token.type === 'word') {
|
|
@@ -350,7 +350,7 @@ export class NakoParserBase {
|
|
|
350
350
|
switch (node.type) {
|
|
351
351
|
case 'not':
|
|
352
352
|
if (depth >= 0) {
|
|
353
|
-
const subNode: Ast = (node as AstBlocks).blocks[0]
|
|
353
|
+
const subNode: Ast = (node as AstBlocks).blocks[0]
|
|
354
354
|
return `${typeName('')}『${this.nodeToStr(subNode, { depth }, debugMode)}に演算子『not』を適用した式${debug}』`
|
|
355
355
|
} else {
|
|
356
356
|
return `${typeName('演算子')}『not』`
|
|
@@ -363,8 +363,8 @@ export class NakoParserBase {
|
|
|
363
363
|
operator = table[operator]
|
|
364
364
|
}
|
|
365
365
|
if (depth >= 0) {
|
|
366
|
-
const left: string = this.nodeToStr(node2.blocks[0]
|
|
367
|
-
const right: string = this.nodeToStr(node2.blocks[1]
|
|
366
|
+
const left: string = this.nodeToStr(node2.blocks[0], { depth }, debugMode)
|
|
367
|
+
const right: string = this.nodeToStr(node2.blocks[1], { depth }, debugMode)
|
|
368
368
|
if (node2.operator === 'eq') {
|
|
369
369
|
return `${typeName('')}『${left}と${right}が等しいかどうかの比較${debug}』`
|
|
370
370
|
}
|