nadesiko3 3.7.13 → 3.7.14

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.
Files changed (127) hide show
  1. package/batch/command.txt +473 -473
  2. package/batch/jsplugin2text.nako3 +2 -0
  3. package/core/package.json +1 -1
  4. package/core/src/nako3.mjs +0 -4
  5. package/core/src/nako3.mts +55 -55
  6. package/core/src/nako_ast.mjs +0 -1
  7. package/core/src/nako_ast.mts +1 -1
  8. package/core/src/nako_colors.mjs +0 -1
  9. package/core/src/nako_colors.mts +1 -1
  10. package/core/src/nako_core_version.mjs +2 -2
  11. package/core/src/nako_core_version.mts +2 -2
  12. package/core/src/nako_csv.mjs +0 -1
  13. package/core/src/nako_csv.mts +9 -9
  14. package/core/src/nako_errors.mts +8 -8
  15. package/core/src/nako_from_dncl.mts +5 -5
  16. package/core/src/nako_from_dncl2.mjs +0 -1
  17. package/core/src/nako_from_dncl2.mts +5 -5
  18. package/core/src/nako_gen.mjs +13 -15
  19. package/core/src/nako_gen.mts +224 -220
  20. package/core/src/nako_global.mts +11 -11
  21. package/core/src/nako_indent.mts +92 -92
  22. package/core/src/nako_indent_chars.mts +1 -1
  23. package/core/src/nako_indent_inline.mjs +11 -11
  24. package/core/src/nako_indent_inline.mts +20 -20
  25. package/core/src/nako_lex_rules.mjs +0 -1
  26. package/core/src/nako_lex_rules.mts +8 -8
  27. package/core/src/nako_lexer.mjs +0 -1
  28. package/core/src/nako_lexer.mts +23 -23
  29. package/core/src/nako_logger.mjs +1 -1
  30. package/core/src/nako_logger.mts +38 -38
  31. package/core/src/nako_parser3.mjs +4 -5
  32. package/core/src/nako_parser3.mts +79 -79
  33. package/core/src/nako_parser_base.mjs +1 -1
  34. package/core/src/nako_parser_base.mts +68 -68
  35. package/core/src/nako_parser_const.mjs +0 -1
  36. package/core/src/nako_parser_const.mts +1 -1
  37. package/core/src/nako_prepare.mts +12 -12
  38. package/core/src/nako_source_mapping.mts +9 -9
  39. package/core/src/nako_token.mjs +0 -1
  40. package/core/src/nako_token.mts +2 -2
  41. package/core/src/nako_tools.mjs +0 -1
  42. package/core/src/nako_tools.mts +4 -4
  43. package/core/src/nako_types.mjs +0 -1
  44. package/core/src/nako_types.mts +3 -3
  45. package/core/src/plugin_api.mjs +0 -1
  46. package/core/src/plugin_api.mts +1 -1
  47. package/core/src/plugin_csv.mjs +0 -1
  48. package/core/src/plugin_csv.mts +7 -7
  49. package/core/src/plugin_math.mjs +0 -1
  50. package/core/src/plugin_math.mts +39 -40
  51. package/core/src/plugin_promise.mjs +1 -1
  52. package/core/src/plugin_promise.mts +9 -9
  53. package/core/src/plugin_system.mjs +1 -10
  54. package/core/src/plugin_system.mts +319 -321
  55. package/core/src/plugin_test.mjs +0 -2
  56. package/core/src/plugin_test.mts +6 -6
  57. package/core/src/plugin_toml.mjs +1 -1
  58. package/core/src/plugin_toml.mts +4 -4
  59. package/core/test/flow_test.mjs +22 -0
  60. package/package.json +31 -34
  61. package/release/_hash.txt +24 -24
  62. package/release/_script-tags.txt +16 -16
  63. package/release/command_cnako3.json +1 -1
  64. package/release/edit_main.js +33 -21
  65. package/release/edit_main.js.map +4 -4
  66. package/release/editor.js +33 -21
  67. package/release/plugin_keigo.js.map +2 -2
  68. package/release/plugin_turtle.js.map +2 -2
  69. package/release/plugin_weykturtle3d.js.map +2 -2
  70. package/release/version.js +29 -17
  71. package/release/version_main.js +29 -17
  72. package/release/version_main.js.map +4 -4
  73. package/release/wnako3.js +51 -44
  74. package/release/wnako3.js.map +3 -3
  75. package/release/wnako3webworker.js +45 -38
  76. package/release/wnako3webworker.js.map +2 -2
  77. package/src/cnako3.mts +1 -1
  78. package/src/cnako3mod.mjs +4 -7
  79. package/src/cnako3mod.mts +24 -24
  80. package/src/commander_ja.mts +8 -8
  81. package/src/deno_wrapper.mjs +0 -1
  82. package/src/deno_wrapper.mts +5 -5
  83. package/src/nako_version.mjs +2 -2
  84. package/src/nako_version.mts +2 -2
  85. package/src/plugin_browser.mjs +21 -29
  86. package/src/plugin_browser.mts +30 -35
  87. package/src/plugin_browser_ajax.mts +27 -27
  88. package/src/plugin_browser_audio.mjs +0 -1
  89. package/src/plugin_browser_audio.mts +11 -11
  90. package/src/plugin_browser_camera.mts +8 -8
  91. package/src/plugin_browser_canvas.mjs +0 -2
  92. package/src/plugin_browser_canvas.mts +34 -34
  93. package/src/plugin_browser_chart.mjs +0 -1
  94. package/src/plugin_browser_chart.mts +13 -13
  95. package/src/plugin_browser_color.mts +2 -2
  96. package/src/plugin_browser_crypto.mts +5 -5
  97. package/src/plugin_browser_dialog.mts +4 -4
  98. package/src/plugin_browser_dom_basic.mts +42 -42
  99. package/src/plugin_browser_dom_event.mjs +0 -1
  100. package/src/plugin_browser_dom_event.mts +27 -28
  101. package/src/plugin_browser_dom_parts.mjs +0 -2
  102. package/src/plugin_browser_dom_parts.mts +31 -31
  103. package/src/plugin_browser_geolocation.mts +3 -3
  104. package/src/plugin_browser_hotkey.mts +3 -3
  105. package/src/plugin_browser_html.mts +4 -4
  106. package/src/plugin_browser_in_worker.mts +1 -1
  107. package/src/plugin_browser_location.mts +2 -2
  108. package/src/plugin_browser_speech.mts +7 -7
  109. package/src/plugin_browser_storage.mts +11 -11
  110. package/src/plugin_browser_system.mts +2 -2
  111. package/src/plugin_browser_websocket.mts +6 -6
  112. package/src/plugin_httpserver.mts +17 -17
  113. package/src/plugin_keigo.mts +5 -5
  114. package/src/plugin_node.mjs +7 -48
  115. package/src/plugin_node.mts +114 -145
  116. package/src/plugin_turtle.mts +143 -143
  117. package/src/plugin_weykturtle3d.mjs +0 -3
  118. package/src/plugin_weykturtle3d.mts +135 -135
  119. package/src/plugin_weykturtle3d_three.mjs +0 -1
  120. package/src/plugin_weykturtle3d_three.mts +1 -1
  121. package/src/plugin_weykturtle3d_threeutil.mts +3 -3
  122. package/src/wnako3.mjs +0 -1
  123. package/src/wnako3.mts +1 -1
  124. package/src/wnako3_editor.mjs +0 -2
  125. package/src/wnako3_editor.mts +132 -132
  126. package/src/wnako3mod.mjs +0 -5
  127. package/src/wnako3mod.mts +19 -19
@@ -1,5 +1,5 @@
1
- /* eslint-disable @typescript-eslint/restrict-template-expressions */
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
1
+
2
+
3
3
  /**
4
4
  * パーサーが生成した中間オブジェクトを実際のJavaScriptのコードに変換する。
5
5
  * なお速度優先で忠実にJavaScriptのコードを生成する。
@@ -45,7 +45,7 @@ export class NakoGenOptions {
45
45
  importFiles: string[]
46
46
  codeStandalone: string
47
47
  codeEnv: string
48
- constructor (isTest = false, importFiles: string[] = [], codeStandalone = '', convEnv = '') {
48
+ constructor(isTest = false, importFiles: string[] = [], codeStandalone = '', convEnv = '') {
49
49
  this.isTest = isTest
50
50
  this.codeStandalone = codeStandalone
51
51
  this.codeEnv = convEnv
@@ -90,7 +90,7 @@ export class NakoGen {
90
90
  /** constructor
91
91
  * @param com コンパイラのインスタンス
92
92
  */
93
- constructor (com: NakoCompiler) {
93
+ constructor(com: NakoCompiler) {
94
94
  /**
95
95
  * 出力するJavaScriptコードのヘッダー部分で定義する必要のある関数。fnはjsのコード。
96
96
  * プラグイン関数は含まれない。
@@ -178,7 +178,7 @@ export class NakoGen {
178
178
  this.debugOption = com.debugOption
179
179
  }
180
180
 
181
- static isValidIdentifier (name: string) {
181
+ static isValidIdentifier(name: string) {
182
182
  // TODO: いらなそうな部分は削る
183
183
  // https://stackoverflow.com/a/9337047
184
184
  // eslint-disable-next-line no-misleading-character-class
@@ -188,7 +188,7 @@ export class NakoGen {
188
188
  /**
189
189
  * com.__varslistを元に、this.varslistSetを設定
190
190
  */
191
- setVarslistSet (varslist: Map<string, any>[]): VarsSet[] {
191
+ setVarslistSet(varslist: Map<string, any>[]): VarsSet[] {
192
192
  const vlist: VarsSet[] = []
193
193
  // 変数名の一覧をVarsSetに格納 (0: システム変数, 1: グローバル変数, 2: ローカル変数) 0と1のみ移す
194
194
  for (let i = 0; i <= 1; i++) {
@@ -203,7 +203,7 @@ export class NakoGen {
203
203
  /**
204
204
  * 改行を埋め込む
205
205
  */
206
- convLineno (node: Ast, forceUpdate = false, incLine = 0): string {
206
+ convLineno(node: Ast, forceUpdate = false, incLine = 0): string {
207
207
  // スピードモードでは行番号を埋め込まない
208
208
  if (this.speedMode.lineNumbers > 0) { return '' }
209
209
 
@@ -254,7 +254,7 @@ export class NakoGen {
254
254
  * ローカル変数の取得用JavaScriptコードを生成する。
255
255
  * @param {string} name
256
256
  */
257
- varname_get (name: string): string {
257
+ varname_get(name: string): string {
258
258
  if (this.varslistSet.length === 3) {
259
259
  // グローバル
260
260
  return `__self.__varslist[${2}].get(${JSON.stringify(name)})`
@@ -269,7 +269,7 @@ export class NakoGen {
269
269
  * @param {string} name
270
270
  * @param {string} jsvalue
271
271
  */
272
- varname_set (name: string, jsvalue: string): string {
272
+ varname_set(name: string, jsvalue: string): string {
273
273
  if (this.varslistSet.length === 3) {
274
274
  return `__self.__varslist[2].set(${JSON.stringify(name)}, (${jsvalue}))`
275
275
  } else {
@@ -282,7 +282,7 @@ export class NakoGen {
282
282
  * @param {string} name
283
283
  * @param {string} jsvalue
284
284
  */
285
- varname_set_sys (name: string, jsvalue: string): string {
285
+ varname_set_sys(name: string, jsvalue: string): string {
286
286
  return `__self.__setSysVar(${JSON.stringify(name)}, (${jsvalue}))`
287
287
  }
288
288
 
@@ -290,7 +290,7 @@ export class NakoGen {
290
290
  * @param {string} name
291
291
  * @returns {string}
292
292
  */
293
- static getFuncName (name: string): string {
293
+ static getFuncName(name: string): string {
294
294
  if (name.indexOf('__') >= 0) { // スコープがある場合
295
295
  const a = name.split('__')
296
296
  const scope = a[0]
@@ -303,13 +303,13 @@ export class NakoGen {
303
303
  }
304
304
 
305
305
  /** @param {Ast} node */
306
- static convPrint (node: Ast): string {
307
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
306
+ static convPrint(node: Ast): string {
307
+
308
308
  return `__print(${node});`
309
309
  }
310
310
 
311
311
  /** @param {AstStrValue} node */
312
- convRequire (node: AstStrValue): string {
312
+ convRequire(node: AstStrValue): string {
313
313
  const moduleName = node.value
314
314
  return this.convLineno(node, false) +
315
315
  `__module['${moduleName}'] = require('${moduleName}');\n`
@@ -321,7 +321,7 @@ export class NakoGen {
321
321
  * @param com
322
322
  * @param opt
323
323
  */
324
- getDefFuncCode (com: NakoCompiler, opt: NakoGenOptions): string {
324
+ getDefFuncCode(com: NakoCompiler, opt: NakoGenOptions): string {
325
325
  let code = ''
326
326
  // よく使う変数のショートカット
327
327
  // jsInit の部分に設定するコード
@@ -375,7 +375,7 @@ export class NakoGen {
375
375
  * プラグイン・オブジェクトを追加
376
376
  * @param po プラグイン・オブジェクト
377
377
  */
378
- addPlugin (po: FuncList): void {
378
+ addPlugin(po: FuncList): void {
379
379
  return this.__self.addPlugin(po)
380
380
  }
381
381
 
@@ -384,7 +384,7 @@ export class NakoGen {
384
384
  * @param name オブジェクト名
385
385
  * @param po 関数リスト
386
386
  */
387
- addPluginObject (name: string, po: FuncList): void {
387
+ addPluginObject(name: string, po: FuncList): void {
388
388
  this.__self.addPluginObject(name, po)
389
389
  }
390
390
 
@@ -394,7 +394,7 @@ export class NakoGen {
394
394
  * @param path ファイルパス
395
395
  * @param po 登録するオブジェクト
396
396
  */
397
- addPluginFile (objName: string, path: string, po: FuncList): void {
397
+ addPluginFile(objName: string, path: string, po: FuncList): void {
398
398
  this.__self.addPluginFile(objName, path, po)
399
399
  }
400
400
 
@@ -404,7 +404,7 @@ export class NakoGen {
404
404
  * @param josi 助詞
405
405
  * @param fn 関数
406
406
  */
407
- addFunc (key: string, josi: FuncArgs, fn: any) {
407
+ addFunc(key: string, josi: FuncArgs, fn: any) {
408
408
  this.__self.addFunc(key, josi, fn)
409
409
  }
410
410
 
@@ -413,14 +413,14 @@ export class NakoGen {
413
413
  * @param key プラグイン関数の関数名
414
414
  * @returns プラグイン・オブジェクト
415
415
  */
416
- getFunc (key: string) {
416
+ getFunc(key: string) {
417
417
  return this.__self.getFunc(key)
418
418
  }
419
419
 
420
420
  /**
421
421
  * 関数を先に登録してしまう
422
422
  */
423
- registerFunction (ast: Ast) {
423
+ registerFunction(ast: Ast) {
424
424
  if (ast.type !== 'block') { throw NakoSyntaxError.fromNode('構文解析に失敗しています。構文は必ずblockが先頭になります', ast) }
425
425
 
426
426
  /** 関数一覧 */
@@ -432,14 +432,14 @@ export class NakoGen {
432
432
  if (!t.name) { throw new Error('[System Error] 関数の定義で関数名が指定されていません') }
433
433
  const name: string = t.name
434
434
  this.usedFuncSet.add(name)
435
- // eslint-disable-next-line @typescript-eslint/no-empty-function
435
+
436
436
  this.__self.__varslist[1].set(name, () => { }) // 事前に適当な値を設定
437
437
  this.varslistSet[1].names.add(name) // global
438
438
  const meta = t.meta
439
439
  if (!meta) { throw new Error('[System Error] 関数の定義で関数名のメタ情報が指定されていません') }
440
440
  this.nakoFuncList.set(name, {
441
441
  josi: meta.josi,
442
- // eslint-disable-next-line @typescript-eslint/no-empty-function
442
+
443
443
  fn: () => {},
444
444
  type: 'func',
445
445
  asyncFn: !!t.asyncFn,
@@ -477,7 +477,7 @@ export class NakoGen {
477
477
  * @param node
478
478
  * @param opt
479
479
  */
480
- convGen (node: Ast, opt: NakoGenOptions): string {
480
+ convGen(node: Ast, opt: NakoGenOptions): string {
481
481
  const result = this.convLineno(node, false) + this._convGen(node, true)
482
482
  if (opt.isTest) {
483
483
  return ''
@@ -490,7 +490,7 @@ export class NakoGen {
490
490
  * @param {Ast} node
491
491
  * @param {boolean} isExpression
492
492
  */
493
- _convGen (node: Ast|null, isExpression: boolean): string {
493
+ _convGen(node: Ast|null, isExpression: boolean): string {
494
494
  if (!node) { return '' }
495
495
  let code = ''
496
496
  if (node instanceof Array) {
@@ -505,147 +505,147 @@ export class NakoGen {
505
505
  if (typeof (node) !== 'object') { return '' + String(node) }
506
506
  // switch
507
507
  switch (node.type) {
508
- case 'nop':
509
- break
510
- case 'block':
511
- code += this.convBlock(node as AstBlocks)
512
- break
513
- case 'comment':
514
- case 'eol':
515
- code += this.convComment(node as AstEol)
516
- break
517
- case 'run_mode':
518
- code += this.convRunMode(node as AstStrValue)
519
- break
520
- case 'break':
521
- code += this.convCheckLoop(node, 'break')
522
- break
523
- case 'continue':
524
- code += this.convCheckLoop(node, 'continue')
525
- break
526
- case 'end':
527
- code += '__v0.get(\'終\')(__self);'
528
- break
529
- case 'number':
530
- code += (node as AstConst).value
531
- break
532
- case 'bigint':
533
- code += (node as AstConst).value
534
- break
535
- case 'string':
536
- code += this.convString(node as AstConst)
537
- break
538
- case 'def_local_var':
539
- code += this.convDefLocalVar(node as AstDefVar)
540
- break
541
- case 'def_local_varlist':
542
- code += this.convDefLocalVarlist(node as AstDefVarList)
543
- break
544
- case 'let':
545
- code += this.convLet(node as AstLet)
546
- break
547
- case 'let_prop':
548
- code += this.convLetProp(node as AstLet)
549
- break
550
- case 'ref_prop':
551
- code += this.convRefProp(node as AstLet)
552
- break
553
- case 'inc':
554
- code += this.convInc(node as AstBlocks)
555
- break
556
- case 'word':
557
- case 'variable':
558
- code += this.convGetVar(node as AstStrValue)
559
- break
560
- case 'op':
561
- case 'calc':
562
- code += this.convOp(node as AstOperator)
563
- break
564
- case 'renbun':
565
- code += this.convRenbun(node as AstOperator)
566
- break
567
- case 'not':
568
- code += '((' + this._convGen((node as AstBlocks).blocks[0], true) + ')?false:true)'
569
- break
570
- case 'func':
571
- case 'func_pointer':
572
- case 'calc_func':
573
- code += this.convCallFunc(node as AstCallFunc, isExpression)
574
- break
575
- case 'if':
576
- code += this.convIf(node as AstIf)
577
- break
578
- case 'for':
579
- code += this.convFor(node as AstFor)
580
- break
581
- case 'foreach': // 反復
582
- code += this.convForeach(node as AstForeach)
583
- break
584
- case 'repeat_times': // 回
585
- code += this.convRepeatTimes(node as AstRepeatTimes)
586
- break
587
- case 'speed_mode':
588
- code += this.convSpeedMode(node as AstBlocks, isExpression)
589
- break
590
- case 'performance_monitor':
591
- code += this.convPerformanceMonitor(node as AstBlocks, isExpression)
592
- break
593
- case 'while':
594
- code += this.convWhile(node as AstWhile)
595
- break
596
- case 'atohantei':
597
- code += this.convAtohantei(node as AstAtohantei)
598
- break
599
- case 'switch':
600
- code += this.convSwitch(node as AstSwitch)
601
- break
602
- case 'let_array':
603
- code += this.convLetArray(node as AstLetArray)
604
- break
605
- case 'ref_array':
606
- code += this.convRefArray(node)
607
- break
608
- case 'ref_array_value':
609
- code += this.convRefArrayValue(node as AstOperator)
610
- break
611
- case 'json_array':
612
- code += this.convJsonArray(node as AstBlocks)
613
- break
614
- case 'json_obj':
615
- code += this.convJsonObj(node as AstBlocks)
616
- break
617
- case 'bool':
618
- code += ((node as AstConst).value) ? 'true' : 'false'
619
- break
620
- case 'null':
621
- code += 'null'
622
- break
623
- case 'def_test':
624
- code += this.convDefTest(node as AstDefFunc)
625
- break
626
- case 'def_func':
627
- code += this.convDefFunc(node as AstDefFunc)
628
- break
629
- case 'func_obj':
630
- code += this.convFuncObj(node as AstDefFunc)
631
- break
632
- case 'return':
633
- code += this.convReturn(node as AstBlocks)
634
- break
635
- case 'try_except':
636
- code += this.convTryExcept(node as AstBlocks)
637
- break
638
- case 'require':
639
- code += this.convRequire(node as AstStrValue)
640
- break
641
- default:
642
- throw new Error('System Error: unknown_type=' + node.type)
508
+ case 'nop':
509
+ break
510
+ case 'block':
511
+ code += this.convBlock(node as AstBlocks)
512
+ break
513
+ case 'comment':
514
+ case 'eol':
515
+ code += this.convComment(node as AstEol)
516
+ break
517
+ case 'run_mode':
518
+ code += this.convRunMode(node as AstStrValue)
519
+ break
520
+ case 'break':
521
+ code += this.convCheckLoop(node, 'break')
522
+ break
523
+ case 'continue':
524
+ code += this.convCheckLoop(node, 'continue')
525
+ break
526
+ case 'end':
527
+ code += '__v0.get(\'終\')(__self);'
528
+ break
529
+ case 'number':
530
+ code += (node as AstConst).value
531
+ break
532
+ case 'bigint':
533
+ code += (node as AstConst).value
534
+ break
535
+ case 'string':
536
+ code += this.convString(node as AstConst)
537
+ break
538
+ case 'def_local_var':
539
+ code += this.convDefLocalVar(node as AstDefVar)
540
+ break
541
+ case 'def_local_varlist':
542
+ code += this.convDefLocalVarlist(node as AstDefVarList)
543
+ break
544
+ case 'let':
545
+ code += this.convLet(node as AstLet)
546
+ break
547
+ case 'let_prop':
548
+ code += this.convLetProp(node as AstLet)
549
+ break
550
+ case 'ref_prop':
551
+ code += this.convRefProp(node as AstLet)
552
+ break
553
+ case 'inc':
554
+ code += this.convInc(node as AstBlocks)
555
+ break
556
+ case 'word':
557
+ case 'variable':
558
+ code += this.convGetVar(node as AstStrValue)
559
+ break
560
+ case 'op':
561
+ case 'calc':
562
+ code += this.convOp(node as AstOperator)
563
+ break
564
+ case 'renbun':
565
+ code += this.convRenbun(node as AstOperator)
566
+ break
567
+ case 'not':
568
+ code += '((' + this._convGen((node as AstBlocks).blocks[0], true) + ')?false:true)'
569
+ break
570
+ case 'func':
571
+ case 'func_pointer':
572
+ case 'calc_func':
573
+ code += this.convCallFunc(node as AstCallFunc, isExpression)
574
+ break
575
+ case 'if':
576
+ code += this.convIf(node as AstIf)
577
+ break
578
+ case 'for':
579
+ code += this.convFor(node as AstFor)
580
+ break
581
+ case 'foreach': // 反復
582
+ code += this.convForeach(node as AstForeach)
583
+ break
584
+ case 'repeat_times': // 回
585
+ code += this.convRepeatTimes(node as AstRepeatTimes)
586
+ break
587
+ case 'speed_mode':
588
+ code += this.convSpeedMode(node as AstBlocks, isExpression)
589
+ break
590
+ case 'performance_monitor':
591
+ code += this.convPerformanceMonitor(node as AstBlocks, isExpression)
592
+ break
593
+ case 'while':
594
+ code += this.convWhile(node as AstWhile)
595
+ break
596
+ case 'atohantei':
597
+ code += this.convAtohantei(node as AstAtohantei)
598
+ break
599
+ case 'switch':
600
+ code += this.convSwitch(node as AstSwitch)
601
+ break
602
+ case 'let_array':
603
+ code += this.convLetArray(node as AstLetArray)
604
+ break
605
+ case 'ref_array':
606
+ code += this.convRefArray(node)
607
+ break
608
+ case 'ref_array_value':
609
+ code += this.convRefArrayValue(node as AstOperator)
610
+ break
611
+ case 'json_array':
612
+ code += this.convJsonArray(node as AstBlocks)
613
+ break
614
+ case 'json_obj':
615
+ code += this.convJsonObj(node as AstBlocks)
616
+ break
617
+ case 'bool':
618
+ code += ((node as AstConst).value) ? 'true' : 'false'
619
+ break
620
+ case 'null':
621
+ code += 'null'
622
+ break
623
+ case 'def_test':
624
+ code += this.convDefTest(node as AstDefFunc)
625
+ break
626
+ case 'def_func':
627
+ code += this.convDefFunc(node as AstDefFunc)
628
+ break
629
+ case 'func_obj':
630
+ code += this.convFuncObj(node as AstDefFunc)
631
+ break
632
+ case 'return':
633
+ code += this.convReturn(node as AstBlocks)
634
+ break
635
+ case 'try_except':
636
+ code += this.convTryExcept(node as AstBlocks)
637
+ break
638
+ case 'require':
639
+ code += this.convRequire(node as AstStrValue)
640
+ break
641
+ default:
642
+ throw new Error('System Error: unknown_type=' + node.type)
643
643
  }
644
644
  return code
645
645
  }
646
646
 
647
647
  /** 変数を検索 */
648
- findVar (name: string, jsvalue: string|null = null): FindVarResult|null {
648
+ findVar(name: string, jsvalue: string|null = null): FindVarResult|null {
649
649
  // __vars ? (ローカル変数)
650
650
  if (this.varslistSet.length > 3 && this.varsSet.names.has(name)) {
651
651
  return {
@@ -678,7 +678,7 @@ export class NakoGen {
678
678
  * @param {string} name
679
679
  * @param {Ast} position
680
680
  */
681
- genVar (name: string, position: Ast): string {
681
+ genVar(name: string, position: Ast): string {
682
682
  const res = this.findVar(name)
683
683
  const lno = position.line
684
684
  if (res === null) {
@@ -715,14 +715,14 @@ export class NakoGen {
715
715
  return res.js
716
716
  }
717
717
 
718
- convGetVar (node: AstStrValue): string {
718
+ convGetVar(node: AstStrValue): string {
719
719
  // 変数名を得る
720
720
  const name = node.value
721
721
  // 変数を取得するコードを生成
722
722
  return this.genVar(name, node)
723
723
  }
724
724
 
725
- convBlock (node: AstBlocks): string {
725
+ convBlock(node: AstBlocks): string {
726
726
  let code = ''
727
727
  for (const block of node.blocks) {
728
728
  code += this._convGen(block, false)
@@ -730,17 +730,14 @@ export class NakoGen {
730
730
  return code
731
731
  }
732
732
 
733
- convComment (node: AstEol): string {
733
+ convComment(node: AstEol): string {
734
734
  let commentSrc = String(node.comment)
735
735
  // コメントの改行や空行を無効化
736
736
  commentSrc = commentSrc.replace(/\n/g, '¶')
737
737
  commentSrc = commentSrc.replace(/\*\//g, '*/')
738
738
  commentSrc = commentSrc.replace(/(^\s+|\s+$)/g, '')
739
739
  // コメントの行番号を得る
740
- let lineNo = this.convLineno(node, false)
741
- if (node.line === 0) {
742
- lineNo = '' // 0行目なら行番号は更新なし
743
- }
740
+ const lineNo = this.convLineno(node, false)
744
741
  if (commentSrc === '' && lineNo === '') { return ';' }
745
742
  if (commentSrc === '') {
746
743
  return ';' + lineNo + '\n'
@@ -748,7 +745,7 @@ export class NakoGen {
748
745
  return ';' + lineNo + '//' + commentSrc + '\n'
749
746
  }
750
747
 
751
- convRunMode (node: AstStrValue): string {
748
+ convRunMode(node: AstStrValue): string {
752
749
  const mode = node.value
753
750
  let isStrict = false
754
751
  if (mode === '厳しくチェック') {
@@ -763,7 +760,7 @@ export class NakoGen {
763
760
  return `/* 実行モード: ${mode} */`
764
761
  }
765
762
 
766
- convReturn (node: AstBlocks): string {
763
+ convReturn(node: AstBlocks): string {
767
764
  // 関数の中であれば利用可能
768
765
  if (this.varsSet.names.has('!関数')) { throw NakoSyntaxError.fromNode('『戻る』がありますが、関数定義内のみで使用可能です。', node) }
769
766
 
@@ -793,7 +790,7 @@ export class NakoGen {
793
790
  }
794
791
  }
795
792
 
796
- getConstPoolsTemplateId (msg: string): number {
793
+ getConstPoolsTemplateId(msg: string): number {
797
794
  let id = this.constPoolsTemplate.indexOf(msg)
798
795
  if (id < 0) {
799
796
  id = this.constPoolsTemplate.length
@@ -802,7 +799,7 @@ export class NakoGen {
802
799
  return id
803
800
  }
804
801
 
805
- addConstPool (msg: string, args: string[], file: any, line: any): number {
802
+ addConstPool(msg: string, args: string[], file: any, line: any): number {
806
803
  // file
807
804
  file = String(file)
808
805
  const fileNo = this.getConstPoolsTemplateId(file)
@@ -820,7 +817,7 @@ export class NakoGen {
820
817
  return poolIndex
821
818
  }
822
819
 
823
- convCheckLoop (node: Ast, cmd: string): string {
820
+ convCheckLoop(node: Ast, cmd: string): string {
824
821
  // ループの中であれば利用可能
825
822
  if (!this.flagLoop) {
826
823
  const cmdj = (cmd === 'continue') ? '続ける' : '抜ける'
@@ -829,7 +826,7 @@ export class NakoGen {
829
826
  return this.convLineno(node) + cmd + ';'
830
827
  }
831
828
 
832
- convDefFuncCommon (node: AstDefFunc, name: string): string {
829
+ convDefFuncCommon(node: AstDefFunc, name: string): string {
833
830
  // 定義中の関数名を記録
834
831
  this.defFuncName = name
835
832
  // 変数をJS変数に展開するかどうか (TODO)
@@ -929,7 +926,7 @@ export class NakoGen {
929
926
  // 既に generate で作成済みのはず(念のため)
930
927
  this.nakoFuncList.set(name, {
931
928
  josi: node.meta.josi,
932
- // eslint-disable-next-line @typescript-eslint/no-empty-function
929
+
933
930
  fn: () => {},
934
931
  type: 'func',
935
932
  asyncFn: false,
@@ -1000,7 +997,7 @@ export class NakoGen {
1000
997
  return code
1001
998
  }
1002
999
 
1003
- convDefTest (node: AstDefFunc): string {
1000
+ convDefTest(node: AstDefFunc): string {
1004
1001
  const name = node.name
1005
1002
  let code = `__tests.push({ name: '${name}', f: () => {\n`
1006
1003
 
@@ -1024,7 +1021,7 @@ export class NakoGen {
1024
1021
  return ''
1025
1022
  }
1026
1023
 
1027
- convDefFunc (node: AstDefFunc): string {
1024
+ convDefFunc(node: AstDefFunc): string {
1028
1025
  // ※ [関数定義のメモ]
1029
1026
  // ※ 関数の定義はプログラムの冒頭に移される。
1030
1027
  // ※ そのため、生成されたコードはここでは返さない
@@ -1035,11 +1032,11 @@ export class NakoGen {
1035
1032
  return ''
1036
1033
  }
1037
1034
 
1038
- convFuncObj (node: AstDefFunc): string {
1035
+ convFuncObj(node: AstDefFunc): string {
1039
1036
  return '/*convFuncObj*/' + this.convDefFuncCommon(node, '')
1040
1037
  }
1041
1038
 
1042
- convJsonObj (node: AstBlocks): string {
1039
+ convJsonObj(node: AstBlocks): string {
1043
1040
  const resultArray = []
1044
1041
  const list = node.blocks
1045
1042
  for (let i = 0; i < list.length / 2; i++) {
@@ -1053,7 +1050,7 @@ export class NakoGen {
1053
1050
  return '{' + resultArray.join(', ') + '}'
1054
1051
  }
1055
1052
 
1056
- convJsonArray (node: AstBlocks): string {
1053
+ convJsonArray(node: AstBlocks): string {
1057
1054
  const list = node.blocks
1058
1055
  const codelist = list.map((e: Ast) => {
1059
1056
  return this._convGen(e, true)
@@ -1061,7 +1058,7 @@ export class NakoGen {
1061
1058
  return '[' + codelist.join(',') + ']'
1062
1059
  }
1063
1060
 
1064
- convRefArray (node: Ast): string {
1061
+ convRefArray(node: Ast): string {
1065
1062
  let code = ''
1066
1063
  code = this._convGen(node.name as Ast, true)
1067
1064
  const list: Ast[] | undefined = node.index
@@ -1073,7 +1070,7 @@ export class NakoGen {
1073
1070
  return code
1074
1071
  }
1075
1072
 
1076
- convRefArrayValue (node: AstOperator): string {
1073
+ convRefArrayValue(node: AstOperator): string {
1077
1074
  let code = ''
1078
1075
  const op: string = node.name ? String(node.name) : '???'
1079
1076
  const val: Ast|undefined = node.index ? node.index.shift() : undefined
@@ -1096,7 +1093,7 @@ export class NakoGen {
1096
1093
  return `/* [WARNING] convRefArrayOperator::UnknownOperator [${op2}] */` + code
1097
1094
  }
1098
1095
 
1099
- convLetArray (node: AstLetArray): string {
1096
+ convLetArray(node: AstLetArray): string {
1100
1097
  const id = this.loopId++
1101
1098
  const valueNode: Ast = node.blocks[0]
1102
1099
  const indexNodes: Ast[] = node.blocks.slice(1)
@@ -1131,7 +1128,7 @@ export class NakoGen {
1131
1128
  let value = null
1132
1129
  if (this.speedMode.invalidSore === 0) { value = this.varname_get('それ') }
1133
1130
  if (valueNode.type !== 'nop') { value = this._convGen(valueNode, true) }
1134
- if (value == null) {
1131
+ if (value === null) {
1135
1132
  throw NakoSyntaxError.fromNode('代入する先の変数名がありません。', node)
1136
1133
  }
1137
1134
  code += ' = ' + value + ';\n'
@@ -1140,7 +1137,7 @@ export class NakoGen {
1140
1137
  return src
1141
1138
  }
1142
1139
 
1143
- convGenLoop (node: Ast): string {
1140
+ convGenLoop(node: Ast): string {
1144
1141
  const tmpflag = this.flagLoop
1145
1142
  this.flagLoop = true
1146
1143
  try {
@@ -1150,7 +1147,7 @@ export class NakoGen {
1150
1147
  }
1151
1148
  }
1152
1149
 
1153
- convFor (node: AstFor): string {
1150
+ convFor(node: AstFor): string {
1154
1151
  const astFrom = node.blocks[0]
1155
1152
  const astTo = node.blocks[1]
1156
1153
  const astInc = node.blocks[2]
@@ -1199,7 +1196,7 @@ export class NakoGen {
1199
1196
  `const ${varTemp} = ${temp};\n` +
1200
1197
  `const ${varFrom} = ${kara};\n` +
1201
1198
  `const ${varTo} = ${made};\n` +
1202
- `if (${varFrom} <= ${varTo}) { // up\n` +
1199
+ `if (${varFrom} < ${varTo}) { // up\n` +
1203
1200
  ` if (${String(flagUp)}) {` +
1204
1201
  ` for (let ${varI} = ${varFrom}; ${varI} <= ${varTo}; ${varI}+= ${inc}) {\n` +
1205
1202
  ` ${sorePrefex};${loopVarSetter}\n` +
@@ -1208,7 +1205,7 @@ export class NakoGen {
1208
1205
  ' // for block end\n' +
1209
1206
  ' };\n' +
1210
1207
  ' };\n' +
1211
- '} else { // down\n' +
1208
+ `} else if (${varFrom} > ${varTo}) { // down\n` +
1212
1209
  ` if (${String(flagDown)}) {` +
1213
1210
  ` for (let ${varI} = ${varFrom}; ${varI} >= ${varTo}; ${varI}-= ${inc}) {\n` +
1214
1211
  ` ${sorePrefex};${loopVarSetter}\n` +
@@ -1217,12 +1214,19 @@ export class NakoGen {
1217
1214
  ' // for block end\n' +
1218
1215
  ' }\n' +
1219
1216
  ' };\n' +
1217
+ '} else { // from == to\n' +
1218
+ ` for (let ${varI} = ${varFrom}; ${varI} <= ${varTo}; ${varI}+= 1) {\n` +
1219
+ ` ${sorePrefex};${loopVarSetter}\n` +
1220
+ ' // for block begin\n' +
1221
+ ` ${block}\n` +
1222
+ ' // for block end\n' +
1223
+ ' };\n' +
1220
1224
  '};\n' +
1221
1225
  `//[/convFor id=${idLoop}]\n`
1222
1226
  return code
1223
1227
  }
1224
1228
 
1225
- convForeach (node: AstForeach): string {
1229
+ convForeach(node: AstForeach): string {
1226
1230
  const exprAst = node.blocks[0]
1227
1231
  const blockAst = node.blocks[1]
1228
1232
  // foreachのIDを取得
@@ -1296,7 +1300,7 @@ export class NakoGen {
1296
1300
  return code
1297
1301
  }
1298
1302
 
1299
- convRepeatTimes (node: AstRepeatTimes): string {
1303
+ convRepeatTimes(node: AstRepeatTimes): string {
1300
1304
  // ループのIDを取得
1301
1305
  const id = this.loopId++
1302
1306
  const varI = `$nako_i${id}`
@@ -1333,7 +1337,7 @@ export class NakoGen {
1333
1337
  * @param {Ast} node
1334
1338
  * @param {boolean} isExpression
1335
1339
  */
1336
- convSpeedMode (node: AstBlocks, isExpression: boolean): string {
1340
+ convSpeedMode(node: AstBlocks, isExpression: boolean): string {
1337
1341
  if (!node.options) { return '' }
1338
1342
  const prev = { ...this.speedMode }
1339
1343
  if (node.options['行番号無し']) {
@@ -1359,7 +1363,7 @@ export class NakoGen {
1359
1363
  * @param {Ast} node
1360
1364
  * @param {boolean} isExpression
1361
1365
  */
1362
- convPerformanceMonitor (node: AstBlocks, isExpression: boolean): string {
1366
+ convPerformanceMonitor(node: AstBlocks, isExpression: boolean): string {
1363
1367
  const prev = { ...this.performanceMonitor }
1364
1368
  if (!node.options) { return '' }
1365
1369
  if (node.options['ユーザ関数']) {
@@ -1378,7 +1382,7 @@ export class NakoGen {
1378
1382
  }
1379
1383
  }
1380
1384
 
1381
- convWhile (node: AstWhile): string {
1385
+ convWhile(node: AstWhile): string {
1382
1386
  const exprAst = node.blocks[0]
1383
1387
  const blockAst = node.blocks[1]
1384
1388
  const cond = this._convGen(exprAst, true)
@@ -1393,7 +1397,7 @@ export class NakoGen {
1393
1397
  return code
1394
1398
  }
1395
1399
 
1396
- convAtohantei (node: AstAtohantei): string {
1400
+ convAtohantei(node: AstAtohantei): string {
1397
1401
  const id = this.loopId++
1398
1402
  const varId = `$nako_i${id}`
1399
1403
  const cond = this._convGen(node.blocks[0], true)
@@ -1407,7 +1411,7 @@ export class NakoGen {
1407
1411
  return this.convLineno(node, false) + code
1408
1412
  }
1409
1413
 
1410
- convSwitch (node: AstSwitch): string {
1414
+ convSwitch(node: AstSwitch): string {
1411
1415
  const expr: string = this._convGen(node.blocks[0], true)
1412
1416
  const defaultStr = this._convGen(node.blocks[1], false)
1413
1417
  let body = ''
@@ -1430,7 +1434,7 @@ export class NakoGen {
1430
1434
  return this.convLineno(node, false) + code
1431
1435
  }
1432
1436
 
1433
- convIf (node: AstIf): string {
1437
+ convIf(node: AstIf): string {
1434
1438
  const exprAst = node.blocks[0]
1435
1439
  const trueAst = node.blocks[1]
1436
1440
  const falseAst = node.blocks[2]
@@ -1456,7 +1460,7 @@ export class NakoGen {
1456
1460
  return code
1457
1461
  }
1458
1462
 
1459
- convFuncGetArgsCalcType (_funcName: string, _func: any, node: AstCallFunc): [any, any] {
1463
+ convFuncGetArgsCalcType(_funcName: string, _func: any, node: AstCallFunc): [any, any] {
1460
1464
  const args = []
1461
1465
  const opts: {[key: string]: boolean} = {}
1462
1466
  const nodeArgs = (node.blocks) ? node.blocks : []
@@ -1475,7 +1479,7 @@ export class NakoGen {
1475
1479
  return [args, opts]
1476
1480
  }
1477
1481
 
1478
- getPluginList () {
1482
+ getPluginList() {
1479
1483
  const r = []
1480
1484
  for (const name in this.__self.__module) { r.push(name) }
1481
1485
  return r
@@ -1487,7 +1491,7 @@ export class NakoGen {
1487
1491
  * @param {boolean} isExpression
1488
1492
  * @returns string コード
1489
1493
  */
1490
- convCallFunc (node: AstCallFunc, isExpression: boolean): string {
1494
+ convCallFunc(node: AstCallFunc, isExpression: boolean): string {
1491
1495
  const funcName = NakoGen.getFuncName(node.name)
1492
1496
  const res = this.findVar(funcName)
1493
1497
  if (res === null) {
@@ -1723,7 +1727,7 @@ export class NakoGen {
1723
1727
  return code
1724
1728
  }
1725
1729
 
1726
- convRenbun (node: AstOperator): string {
1730
+ convRenbun(node: AstOperator): string {
1727
1731
  const right = this._convGen(node.blocks[1], true)
1728
1732
  const left = this._convGen(node.blocks[0], false)
1729
1733
  this.numAsyncFn++
@@ -1731,7 +1735,7 @@ export class NakoGen {
1731
1735
  return `/*[連文]*/await (async function(){ ${left}; return ${right} }).call(this)/*[/連文]*/`
1732
1736
  }
1733
1737
 
1734
- convOp (node: AstOperator): string {
1738
+ convOp(node: AstOperator): string {
1735
1739
  // トークン名からJS演算子への変換 - 単純な変換が可能なものをここで定義
1736
1740
  const OP_TBL: {[key: string]: string} = {
1737
1741
  '&': '+""+',
@@ -1772,7 +1776,7 @@ export class NakoGen {
1772
1776
  return `(${left} ${op} ${right})`
1773
1777
  }
1774
1778
 
1775
- convInc (node: AstBlocks): string {
1779
+ convInc(node: AstBlocks): string {
1776
1780
  // idを得る
1777
1781
  const id = this.loopId++
1778
1782
  const valueVar = `$nako_v${id}`
@@ -1820,7 +1824,7 @@ export class NakoGen {
1820
1824
  return code
1821
1825
  }
1822
1826
 
1823
- convLet (node: AstLet): string {
1827
+ convLet(node: AstLet): string {
1824
1828
  const astValue = node.blocks[0]
1825
1829
  // もし値が省略されていたら、変数「それ」に代入する
1826
1830
  let value = null
@@ -1838,7 +1842,7 @@ export class NakoGen {
1838
1842
  value = this._convGen(astValue, true)
1839
1843
  }
1840
1844
  // 戻り値の検証
1841
- if (value == null) {
1845
+ if (value === null) {
1842
1846
  throw NakoSyntaxError.fromNode('代入する先の変数名がありません。', node)
1843
1847
  }
1844
1848
 
@@ -1861,7 +1865,7 @@ export class NakoGen {
1861
1865
  }
1862
1866
 
1863
1867
  // プロパティへの代入式 (#1793)
1864
- convLetProp (node: AstLet): string {
1868
+ convLetProp(node: AstLet): string {
1865
1869
  if (!node.index || node.index.length === 0) { throw NakoSyntaxError.fromNode('代入する先のプロパティ名がありません。', node) }
1866
1870
  if (!node.blocks || node.blocks.length === 0) { throw NakoSyntaxError.fromNode('代入する値がありません。', node) }
1867
1871
  const propList = node.index as AstStrValue[]
@@ -1913,7 +1917,7 @@ export class NakoGen {
1913
1917
  }
1914
1918
 
1915
1919
  // プロパティへの参照 (#1793)
1916
- convRefProp (node: Ast): string {
1920
+ convRefProp(node: Ast): string {
1917
1921
  const name = this._convGen(node.name as Ast, true)
1918
1922
  const list: Ast[] | undefined = node.index
1919
1923
  if (!list || list.length <= 0) {
@@ -1923,7 +1927,7 @@ export class NakoGen {
1923
1927
  }
1924
1928
 
1925
1929
  // プロパティへの参照のコード生成部分 (#1793)
1926
- convRefProp_genCode (name: string, propList: AstStrValue[]): string {
1930
+ convRefProp_genCode(name: string, propList: AstStrValue[]): string {
1927
1931
  let code
1928
1932
  if (propList.length <= 1) {
1929
1933
  const propKey = propList[0].value
@@ -1955,7 +1959,7 @@ export class NakoGen {
1955
1959
  return code
1956
1960
  }
1957
1961
 
1958
- convDefLocalVar (node: AstDefVar): string {
1962
+ convDefLocalVar(node: AstDefVar): string {
1959
1963
  const astValue = node.blocks[0]
1960
1964
  let value = '0'
1961
1965
  if (astValue.type !== 'nop') {
@@ -1976,7 +1980,7 @@ export class NakoGen {
1976
1980
  }
1977
1981
 
1978
1982
  // #563 複数変数への代入
1979
- convDefLocalVarlist (node: AstDefVarList): string {
1983
+ convDefLocalVarlist(node: AstDefVarList): string {
1980
1984
  let code = ''
1981
1985
  const vtype = node.vartype // 変数 or 定数
1982
1986
  // 初期値を取得
@@ -2013,7 +2017,7 @@ export class NakoGen {
2013
2017
  '/*[/convDefLocalVarlist]*/\n'
2014
2018
  }
2015
2019
 
2016
- convString (node: AstConst): string {
2020
+ convString(node: AstConst): string {
2017
2021
  let value = String(node.value)
2018
2022
  value = value.replace(/\\/g, '\\\\')
2019
2023
  value = value.replace(/"/g, '\\"')
@@ -2022,7 +2026,7 @@ export class NakoGen {
2022
2026
  return '"' + value + '"'
2023
2027
  }
2024
2028
 
2025
- convTryExcept (node: AstBlocks): string {
2029
+ convTryExcept(node: AstBlocks): string {
2026
2030
  const block = this._convGen(node.blocks[0], false)
2027
2031
  const errBlock = this._convGen(node.blocks[1], false)
2028
2032
  return this.convLineno(node, false) +
@@ -2032,11 +2036,11 @@ export class NakoGen {
2032
2036
  `${errBlock}}\n`
2033
2037
  }
2034
2038
 
2035
- getUsedFuncSet (): Set<string> {
2039
+ getUsedFuncSet(): Set<string> {
2036
2040
  return this.usedFuncSet
2037
2041
  }
2038
2042
 
2039
- getPluginInitCode (): string {
2043
+ getPluginInitCode(): string {
2040
2044
  // プラグインの初期化関数を実行する
2041
2045
  let code = ''
2042
2046
  let pluginCode = ''
@@ -2154,7 +2158,7 @@ __codeJS__
2154
2158
  * @param ast
2155
2159
  * @param opt
2156
2160
  */
2157
- export function generateJS (com: NakoCompiler, ast: Ast, opt: NakoGenOptions): NakoGenResult {
2161
+ export function generateJS(com: NakoCompiler, ast: Ast, opt: NakoGenOptions): NakoGenResult {
2158
2162
  // NakoGenのインスタンスを作成
2159
2163
  const gen = new NakoGen(com)
2160
2164
 
@@ -2276,7 +2280,7 @@ ${js}
2276
2280
  }
2277
2281
  }
2278
2282
  // template
2279
- function replaceTemplateCode (template: string, values: any): string {
2283
+ function replaceTemplateCode(template: string, values: any): string {
2280
2284
  for (const key in values) {
2281
2285
  const pat = `__${key}__`
2282
2286
  const val = values[key]
@@ -2286,7 +2290,7 @@ function replaceTemplateCode (template: string, values: any): string {
2286
2290
  }
2287
2291
 
2288
2292
  // clean generated code
2289
- function cleanGeneratedCode (code: string, indent = 0): string {
2293
+ function cleanGeneratedCode(code: string, indent = 0): string {
2290
2294
  // 1. 無意味な改行やセミコロンを削除
2291
2295
  // 2. 行頭の空白やセミコロンを削除
2292
2296
  // 3. indent分インデントを追加
@@ -2319,7 +2323,7 @@ function cleanGeneratedCode (code: string, indent = 0): string {
2319
2323
  * 文字列リテラル内のセミコロンと改行は保護する (#2153)
2320
2324
  * JavaScriptの文字列リテラル、正規表現、テンプレートリテラル、コメントを考慮
2321
2325
  */
2322
- function removeDuplicateChars (code: string): string {
2326
+ function removeDuplicateChars(code: string): string {
2323
2327
  const result: string[] = []
2324
2328
  let i = 0
2325
2329
  let inString = false
@@ -2441,7 +2445,7 @@ function removeDuplicateChars (code: string): string {
2441
2445
  }
2442
2446
 
2443
2447
  // 文字列・正規表現・テンプレートリテラルの開始チェック
2444
- if (ch === '"' || ch === "'") {
2448
+ if (ch === '"' || ch === '\'') {
2445
2449
  inString = true
2446
2450
  stringDelimiter = ch
2447
2451
  result.push(ch)
@@ -2506,7 +2510,7 @@ function removeDuplicateChars (code: string): string {
2506
2510
  * @param str 対象文字列
2507
2511
  * @returns トリムした文字列
2508
2512
  */
2509
- function trim (str: string): string {
2513
+ function trim(str: string): string {
2510
2514
  str = String(str)
2511
2515
  return str.replace(/^\s+|\s+$/g, '')
2512
2516
  }