nadesiko3 3.6.29 → 3.6.32
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 +107 -32
- package/core/package.json +1 -1
- package/core/src/nako_gen.mjs +52 -21
- package/core/src/nako_gen.mts +50 -24
- package/core/src/nako_lex_rules.mjs +5 -2
- package/core/src/nako_lex_rules.mts +5 -2
- package/core/src/nako_lexer.mjs +14 -5
- package/core/src/nako_lexer.mts +14 -5
- package/core/src/nako_parser3.mjs +37 -22
- package/core/src/nako_parser3.mts +36 -22
- package/core/test/basic_test.mjs +13 -0
- package/package.json +1 -1
- package/release/_hash.txt +28 -28
- package/release/_script-tags.txt +33 -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 +5 -5
- package/release/edit_main.js.map +3 -3
- package/release/editor.js +5 -5
- package/release/version.js +1 -1
- package/release/version_main.js +1 -1
- package/release/version_main.js.map +1 -1
- package/release/wnako3.js +97 -97
- package/release/wnako3.js.map +3 -3
- package/release/wnako3webworker.js +78 -78
- package/release/wnako3webworker.js.map +3 -3
- package/src/nako_version.mjs +2 -2
- package/src/nako_version.mts +2 -2
- package/src/plugin_browser.mjs +15 -0
- package/src/plugin_browser.mts +13 -0
- package/src/plugin_browser_api.mts +1 -0
- package/src/plugin_browser_dom_basic.mjs +109 -0
- package/src/plugin_browser_dom_basic.mts +100 -0
- package/src/plugin_browser_dom_parts.mjs +2 -34
- package/src/plugin_browser_dom_parts.mts +3 -34
- package/tools/nako3edit/html/plugins.html +5 -5
package/batch/command.txt
CHANGED
|
@@ -384,41 +384,116 @@
|
|
|
384
384
|
|
|
385
385
|
|
|
386
386
|
■plugin_turtle(基本プラグイン,wnako)
|
|
387
|
-
●タートルグラフィックス・カメ描画
|
|
388
|
-
| 関数 | カメ作成 | | タートルグラフィックスを開始してカメのIDを返す | かめさくせい | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L427
|
|
389
|
-
| 関数 | ゾウ作成 | | ゾウの画像でタートルグラフィックスを開始してIDを返す | ぞうさくせい | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L436
|
|
390
|
-
| 関数 | パンダ作成 | | パンダの画像でタートルグラフィックスを開始してIDを返す | ぱんださくせい | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L445
|
|
391
|
-
| 関数 | カメ操作対象設定 | IDに/IDへ/IDの | IDを指定して操作対象となるカメを変更する | かめそうさたいしょうせってい | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L454
|
|
392
|
-
| 変数 | カメ描画先 | | '#turtle_cv' | かめびょうがさき | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L459
|
|
393
|
-
| 変数 | カメ画像URL | | turtleImage | かめがぞうURL | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L460
|
|
394
|
-
| 関数 | カメ画像変更 | URLに/URLへ | カメの画像をURLに変更する | かめがぞうへんこう | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L465
|
|
395
|
-
| 定数 | カメ速度 | | 100 | かめそくど | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L471
|
|
396
|
-
| 関数 | カメ速度設定 | Vに/Vへ | カメの動作速度vに設定(大きいほど遅い) | かめそくどせってい | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L476
|
|
397
|
-
| 関数 | カメ移動 | XYに/XYへ | カメの位置を[x,y]へ移動する | かめいどう | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L484
|
|
398
|
-
| 関数 | カメ起点移動 | XYに/XYへ | カメの描画起点位置を[x,y]へ移動する | かめきてんいどう | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L494
|
|
399
|
-
| 関数 | カメ進 | Vだけ | カメの位置をVだけ進める | かめすすむ | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L504
|
|
400
|
-
| 関数 | カメ戻 | Vだけ | カメの位置をVだけ戻す | かめもどる | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L514
|
|
401
|
-
| 関数 | カメ角度設定 | Vに/Vへ/Vの | カメの向きをDEGに設定する | かめかくどせってい | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L524
|
|
402
|
-
| 関数 | カメ右回転 | Vだけ | カメの向きをDEGだけ右に向ける | かめみぎかいてん | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L534
|
|
403
|
-
| 関数 | カメ左回転 | Vだけ | カメの向きをDEGだけ左に向ける | かめひだりかいてん | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L544
|
|
404
|
-
| 関数 | カメペン色設定 | Cに/Cへ | カメのペン描画色をCに設定する | かめぺんいろせってい | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L554
|
|
405
|
-
| 関数 | カメペンサイズ設定 | Wに/Wへ | カメペンのサイズをWに設定する | かめぺんさいずせってい | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L564
|
|
406
|
-
| 関数 | カメペン設定 | Wに/Wへ | カメペンを使うかどうかをV(オン/オフ)に設定する | かめぺんせってい | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L573
|
|
407
|
-
| 関数 | カメパス開始 | | カメで明示的にパスの描画を開始する | かめぱすかいし | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L582
|
|
408
|
-
| 関数 | カメパス閉 | | カメでパスを明示的に閉じる(省略可能) | かめぱすとじる | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L591
|
|
409
|
-
| 関数 | カメパス線引 | | カメでパスを閉じて、カメペン色設定で指定した色で枠線を引く | かめぱすせんひく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L600
|
|
410
|
-
| 関数 | カメパス塗 | | カメでパスを閉じて、カメ塗り色設定で指定した色で塗りつぶす | かめぱすぬる | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L609
|
|
411
|
-
| 関数 | カメ文字描画 | Sを/Sと/Sの | カメの位置に文字Sを描画 | かめもじびょうが | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L618
|
|
412
|
-
| 関数 | カメ文字設定 | Sに/Sへ/Sで | カメ文字描画で描画するテキストサイズやフォント(48px serif)などを設定 | かめもじせってい | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L627
|
|
413
|
-
| 関数 | カメ塗色設定 | Cに/Cへ | カメパスの塗り色をCに設定する | かめぬりいろせってい | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L642
|
|
414
|
-
| 関数 | カメ全消去 | | 表示しているカメと描画内容を全部消去する | かめぜんしょうきょ | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L652
|
|
415
|
-
| 関数 | カメコマンド実行 | CMDの/CMDを | カメにコマンドSを実行する。コマンドは改行か「;」で区切る。コマンドと引数は「=」で区切り引数はかカンマで区切る | かめこまんどじっこう | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L661
|
|
416
|
-
| 関数 | カメ非表示 | | カメの画像を非表示にする。描画に影響しない。 | かめひひょうじ | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L678
|
|
417
|
-
| 関数 | カメ表示 | | 非表示にしたカメを表示する。 | かめひょうじ | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L688
|
|
418
|
-
| 関数 | カメクリック時 | FUNCを | 操作対象のカメをクリックした時のイベントを設定する | かめくりっくしたとき | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_turtle.mts#L698
|
|
419
387
|
|
|
420
388
|
|
|
421
389
|
■plugin_node(基本プラグイン,cnako,phpnako)
|
|
390
|
+
●ファイル入出力
|
|
391
|
+
| 関数 | 開 | Fを/Fから | ファイルFを開く(非同期関数) | ひらく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L199
|
|
392
|
+
| 関数 | 読 | Fを/Fから | ファイFSを開く(非同期関数) | よむ | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L217
|
|
393
|
+
| 関数 | バイナリ読 | Sを/Sから | ファイルSをバイナリ(Buffer)として開く | ばいなりよむ | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L234
|
|
394
|
+
| 関数 | 保存 | SをFへ/Fに | データSをファイルFヘ書き込む(文字コードはUTF-8)(非同期関数) | ほぞん | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L243
|
|
395
|
+
| 関数 | SJISファイル読 | Sを/Sから | SJIS形式のファイルSを読み込む | SJISふぁいるよむ | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L265
|
|
396
|
+
| 関数 | SJISファイル保存 | SをFへ/Fに | SをSJIS形式でファイルFへ書き込む | SJISふぁいるほぞん | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L276
|
|
397
|
+
| 関数 | EUCファイル読 | Sを/Sから | euc-jp形式のファイルSを読み込む | EUCふぁいるよむ | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L287
|
|
398
|
+
| 関数 | EUCファイル保存 | SをFへ/Fに | Sをeuc-jp形式でファイルFへ書き込む | EUCふぁいるほぞん | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L297
|
|
399
|
+
| 関数 | 起動待機 | Sを | シェルコマンドSを起動し実行終了まで待機する | きどうたいき | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L307
|
|
400
|
+
| 関数 | 起動 | Sを | シェルコマンドSを起動 | きどう | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L316
|
|
401
|
+
| 関数 | 起動時 | CALLBACKでSを | シェルコマンドSを起動 | きどうしたとき | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L328
|
|
402
|
+
| 関数 | ブラウザ起動 | URLを | ブラウザでURLを起動 | ぶらうざきどう | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L338
|
|
403
|
+
| 関数 | ファイル列挙 | Sの/Sを/Sで | パスSのファイル名(フォルダ名)一覧を取得する。ワイルドカード可能。「*.jpg;*.png」など複数の拡張子を指定可能。 | ふぁいるれっきょ | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L346
|
|
404
|
+
| 関数 | 全ファイル列挙 | Sの/Sを/Sで | パスS以下の全ファイル名を取得する。ワイルドカード可能。「*.jpg;*.png」のように複数の拡張子を指定可能。 | ぜんふぁいるれっきょ | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L365
|
|
405
|
+
| 関数 | 存在 | PATHが/PATHの | ファイルPATHが存在するか確認して返す | そんざい | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L410
|
|
406
|
+
| 関数 | フォルダ存在 | PATHが/PATHの | ディレクトリPATHが存在するか確認して返す | ふぉるだそんざい | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L418
|
|
407
|
+
| 関数 | フォルダ作成 | PATHの/PATHを/PATHに/PATHへ | ディレクトリPATHを作成して返す(再帰的に作成) | ふぉるださくせい | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L426
|
|
408
|
+
| 関数 | ファイルコピー | AからBに/AをBへ | パスAをパスBへファイルコピーする | ふぁいるこぴー | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L434
|
|
409
|
+
| 関数 | ファイルコピー時 | CALLBACKでAからBに/AをBへ | パスAをパスBへファイルコピーしてcallbackを実行 | ふぁいるこぴーしたとき | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L442
|
|
410
|
+
| 関数 | ファイル移動 | AからBに/AをBへ | パスAをパスBへ移動する | ふぁいるいどう | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L454
|
|
411
|
+
| 関数 | ファイル移動時 | CALLBACKでAからBに/AをBへ | パスAをパスBへ移動してcallbackを実行 | ふぁいるいどうしたとき | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L462
|
|
412
|
+
| 関数 | ファイル削除 | PATHの/PATHを | パスPATHを削除する | ふぁいるさくじょ | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L474
|
|
413
|
+
| 関数 | ファイル削除時 | CALLBACKでPATHの/PATHを | パスPATHを削除してcallbackを実行 | ふぁいるさくじょしたとき | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L482
|
|
414
|
+
| 関数 | ファイル情報取得 | PATHの/PATHから | パスPATHの情報を調べてオブジェクトで返す | ふぁいるじょうほうしゅとく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L494
|
|
415
|
+
| 関数 | ファイルサイズ取得 | PATHの/PATHから | パスPATHのファイルサイズを調べて返す | ふぁいるさいずしゅとく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L502
|
|
416
|
+
●パス操作
|
|
417
|
+
| 関数 | ファイル名抽出 | Sから/Sの | フルパスのファイル名Sからファイル名部分を抽出して返す | ふぁいるめいちゅうしゅつ | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L513
|
|
418
|
+
| 関数 | パス抽出 | Sから/Sの | ファイル名Sからパス部分を抽出して返す | ぱすちゅうしゅつ | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L521
|
|
419
|
+
| 関数 | 絶対パス変換 | Aを/Aの | 相対パスから絶対パスに変換して返す | ぜったいぱすへんかん | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L529
|
|
420
|
+
| 関数 | 相対パス展開 | AをBで | ファイル名AからパスBを展開して返す | そうたいぱすてんかい | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L537
|
|
421
|
+
●フォルダ取得
|
|
422
|
+
| 関数 | カレントディレクトリ取得 | | カレントディレクトリを返す | かれんとでぃれくとりしゅとく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L546
|
|
423
|
+
| 関数 | カレントディレクトリ変更 | DIRに/DIRへ | カレントディレクトリをDIRに変更する | かれんとでぃれくとりへんこう | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L555
|
|
424
|
+
| 関数 | 作業フォルダ取得 | | カレントディレクトリを返す | さぎょうふぉるだしゅとく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L564
|
|
425
|
+
| 関数 | 作業フォルダ変更 | DIRに/DIRへ | カレントディレクトリをDIRに変更する | さぎょうふぉるだへんこう | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L573
|
|
426
|
+
| 関数 | ホームディレクトリ取得 | | ホームディレクトリを取得して返す | ほーむでぃれくとりしゅとく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L582
|
|
427
|
+
| 関数 | デスクトップ | | デスクトップパスを取得して返す | ですくとっぷ | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L590
|
|
428
|
+
| 関数 | マイドキュメント | | マイドキュメントのパスを取得して返す | まいどきゅめんと | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L599
|
|
429
|
+
| 定数 | 母艦パス | | '' | ぼかんぱす | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L604
|
|
430
|
+
| 関数 | 母艦パス取得 | | スクリプトのあるディレクトリを返す | ぼかんぱすしゅとく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L609
|
|
431
|
+
| 関数 | テンポラリフォルダ | | テンポラリフォルダのパスを取得して返す | てんぽらりふぉるだ | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L617
|
|
432
|
+
| 関数 | 一時フォルダ作成 | DIRに/DIRへ | 指定のフォルダに作業用の一時フォルダを作成して取得して返す | いちじふぉるださくせい | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L626
|
|
433
|
+
●環境変数
|
|
434
|
+
| 関数 | 環境変数取得 | Sの | 環境変数Sを返す | かんきょうへんすうしゅとく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L639
|
|
435
|
+
| 関数 | 環境変数一覧取得 | | 環境変数の一覧を返す | かんきょうへんすういちらんしゅとく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L647
|
|
436
|
+
●圧縮・解凍
|
|
437
|
+
| 定数 | 圧縮解凍ツールパス | | '7z' | あっしゅくかいとうつーるぱす | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L652
|
|
438
|
+
| 関数 | 圧縮解凍ツールパス変更 | Vに/Vへ | 圧縮解凍に使うツールを取得変更する | あっしゅくかいとうつーるぱすへんこう | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L657
|
|
439
|
+
| 関数 | 解凍 | AをBに/AからBへ | (v1非互換)ZIPファイルAをBに解凍(実行には7-zipが必要-https://goo.gl/LmKswH) | かいとう | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L666
|
|
440
|
+
| 関数 | 解凍時 | CALLBACKでAをBに/AからBへ | 解凍処理を行い、処理が完了したときにcallback処理を実行 | かいとうしたとき | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L679
|
|
441
|
+
| 関数 | 圧縮 | AをBに/AからBへ | (v1非互換)ファイルAをBにZIP圧縮(実行には7-zipが必要-https://goo.gl/LmKswH) | あっしゅく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L695
|
|
442
|
+
| 関数 | 圧縮時 | CALLBACKでAをBに/AからBへ | 圧縮処理を行い完了したときにcallback処理を指定 | あっしゅくしたとき | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L708
|
|
443
|
+
●Nodeプロセス
|
|
444
|
+
| 関数 | 終 | | Nodeでプログラム実行を強制終了する | おわる | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L725
|
|
445
|
+
| 関数 | 強制終了時 | FUNCを | Nodeでctrl+cでプログラムの実行が終了した時FUNCを実行する。もしFUNCが偽を返すと終了しない。非同期処理のとき動作する(#1010) | きょうせいしゅうりょうしたとき | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L734
|
|
446
|
+
| 関数 | 終了 | | Nodeでプログラム実行を強制終了する | しゅうりょう | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L749
|
|
447
|
+
| 関数 | OS取得 | | OSプラットフォームを返す(darwin/win32/linux) | OSしゅとく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L758
|
|
448
|
+
| 関数 | OSアーキテクチャ取得 | | OSアーキテクチャを返す | OSあーきてくちゃしゅとく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L766
|
|
449
|
+
●コマンドラインと標準入出力
|
|
450
|
+
| 定数 | コマンドライン | | '' | こまんどらいん | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L771
|
|
451
|
+
| 定数 | ナデシコランタイム | | '' | なでしこらんたいむ | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L772
|
|
452
|
+
| 定数 | ナデシコランタイムパス | | '' | なでしこらんたいむぱす | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L773
|
|
453
|
+
| 関数 | 標準入力取得時 | CALLBACK(Fを | 標準入力を一行取得した時に、変数『対象』に取得した文字列を代入し、無名関数(あるいは、文字列で関数名を指定)F(s: string)を実行する | ひょうじゅんにゅうりょくしゅとくしたとき | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L778
|
|
454
|
+
| 関数 | 尋 | MSGと/MSGを | 標準入力を一行取得する(非同期関数) | たずねる | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L796
|
|
455
|
+
| 関数 | 文字尋 | MSGと/MSGを | 標準入力を一行取得する。ただし自動で数値に変換しない(非同期関数) | もじたずねる | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L814
|
|
456
|
+
| 関数 | 標準入力全取得 | | 標準入力を全部取得して返す(非同期関数) | ひょうじゅんにゅうりょくぜんしゅとく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L827
|
|
457
|
+
●テスト
|
|
458
|
+
| 関数 | ASSERT等 | AとBが | mochaによるテストで、ASSERTでAとBが正しいことを報告する | ASSERTひとしい | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L845
|
|
459
|
+
●ネットワーク
|
|
460
|
+
| 関数 | 自分IPアドレス取得 | | ネットワークアダプターからIPアドレス(IPv4)を取得して配列で返す | じぶんIPあどれすしゅとく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L854
|
|
461
|
+
| 関数 | 自分IPV6アドレス取得 | | ネットワークアダプターからIPアドレス(IPv6)を取得して配列で返す | じぶんIPV6あどれすしゅとく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L876
|
|
462
|
+
●Ajax
|
|
463
|
+
| 関数 | AJAX送信時 | CALLBACKのURLまで/URLへ/URLに | 非同期通信(Ajax)でURLにデータを送信し、成功するとcallbackが実行される。その際『対象』にデータが代入される。 | AJAXそうしんしたとき | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L896
|
|
464
|
+
| 関数 | AJAX受信時 | CALLBACKでURLから/URLを | 非同期通信(Ajax)でURLにデータを送信し、成功するとcallbackが実行される。その際『対象』にデータが代入される。 | AJAXそうしんしたとき | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L915
|
|
465
|
+
| 関数 | GET送信時 | CALLBACKのURLまで/URLへ/URLに | 非同期通信(Ajax)でURLにデータを送信し、成功するとcallbackが実行される。その際『対象』にデータが代入される。 | GETそうしんしたとき | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L924
|
|
466
|
+
| 関数 | POST送信時 | CALLBACKのURLまでPARAMSを/URLへ/URLに | AjaxでURLにPARAMSをPOST送信し『対象』にデータを設定 | POSTそうしんしたとき | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L933
|
|
467
|
+
| 関数 | POSTフォーム送信時 | CALLBACKのURLまでPARAMSを/URLへ/URLに | AjaxでURLにPARAMSをフォームとしてPOST送信し『対象』にデータを設定 | POSTふぉーむそうしんしたとき | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L962
|
|
468
|
+
| 関数 | AJAX失敗時 | CALLBACKの | Ajax命令でエラーが起きたとき | AJAXえらーしっぱいしたとき | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L987
|
|
469
|
+
| 定数 | AJAXオプション | | '' | Ajax関連のオプションを指定 | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L991
|
|
470
|
+
| 関数 | AJAXオプション設定 | OPTIONに/OPTIONへ/OPTIONと | Ajax命令でオプションを設定 | AJAXおぷしょんせってい | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L996
|
|
471
|
+
| 関数 | AJAX保障送信 | URLまで/URLへ/URLに | 非同期通信(Ajax)でURLにデータの送信を開始する非同期処理オブジェクト(Promise)を作成する。 | AJAXほしょうそうしん | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L1005
|
|
472
|
+
| 関数 | HTTP保障取得 | URLの/URLから/URLを | 非同期通信(Ajax)でURLにデータの送信を開始する非同期処理オブジェクト(Promise)を作成する。 | HTTPほしょうしゅとく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L1016
|
|
473
|
+
| 関数 | GET保障送信 | URLまで/URLへ/URLに | 非同期通信(Ajax)でURLにデータの送信を開始する非同期処理オブジェクト(Promise)を作成する。 | GETほしょうそうしん | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L1025
|
|
474
|
+
| 関数 | POST保障送信 | URLまでPARAMSを/URLへ/URLに | 非同期通信(Ajax)でURLにPARAMSをPOST送信を開始する非同期処理オブジェクト(Promise)を作成する。 | POSTほしょうそうしん | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L1034
|
|
475
|
+
| 関数 | POSTフォーム保障送信 | URLまでPARAMSを/URLへ/URLに | 非同期通信(Ajax)でURLにPARAMSをフォームとしてPOST送信を開始する非同期処理オブジェクト(Promise)を作成する。 | POSTふぉーむほしょうそうしん | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L1057
|
|
476
|
+
| 関数 | AJAX内容取得 | RESからTYPEで | 非同期通信(Ajax)の応答から内容を指定した形式で取り出すための非同期処理オブジェクト(Promise)を返す。 | AJAXないようしゅとく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L1073
|
|
477
|
+
| 関数 | AJAX受信 | URLから/URLを | 「!非同期モード」で非同期通信(Ajax)でURLからデータを受信する。『AJAXオプション』を指定できる。結果は変数『対象』に入る | AJAXじゅしん | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L1098
|
|
478
|
+
| 関数 | POSTデータ生成 | PARAMSの/PARAMSを | 辞書形式のデータPARAMSをkey=value&key=value...の形式に変換する | POSTでーたせいせい | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L1120
|
|
479
|
+
| 関数 | POST送信 | URLまでPARAMSを/URLへ/URLに | 非同期通信(AJAX)でPOSTメソッドにてURLへPARAMS(辞書型)を送信して応答を戻す。(非同期関数) | POSTそうしん | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L1135
|
|
480
|
+
| 関数 | POSTフォーム送信 | URLまでPARAMSを/URLへ/URLに | 非同期通信(AJAX)でURLにPARAMS(辞書型)をフォームとしてPOSTメソッドにてURLへ送信し応答を返す。(非同期関数) | POSTふぉーむそうしん | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L1160
|
|
481
|
+
●新AJAX
|
|
482
|
+
| 関数 | AJAXテキスト取得 | URLから | AJAXでURLにアクセスしテキスト形式で結果を得る。送信時AJAXオプションの値を参照。(非同期関数) | AJAXてきすとしゅとく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L1184
|
|
483
|
+
| 関数 | AJAX_JSON取得 | URLから | AJAXでURLにアクセスしJSONの結果を得て、送信時AJAXオプションの値を参照。(非同期関数) | AJAX_JSONしゅとく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L1199
|
|
484
|
+
| 関数 | AJAXバイナリ取得 | URLから | AJAXでURLにアクセスしバイナリ(arrayBuffer)形式で結果を得る。送信時AJAXオプションの値を参照。(非同期関数) | AJAXばいなりしゅとく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L1213
|
|
485
|
+
●LINE
|
|
486
|
+
| 関数 | LINE送信 | TOKENへMESSAGEを/TOKENに | LINEにメッセージを送信する。先にLINE Notifyのページで宛先のトークンを取得する。TOKENへMESSAGEをLINE送信する。(非同期関数) | LINEそうしん | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L1228
|
|
487
|
+
| 関数 | LINE画像送信 | TOKENへIMAGEFILEとMESSAGEを/TOKENに | LINEにメッセージを送信する。先にLINE Notifyのページで宛先のトークンを取得する。TOKENへIMAGE_FILEとMESSAGEをLINE画像送信する。(非同期関数) | LINEがぞうそうしん | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L1250
|
|
488
|
+
●文字コード
|
|
489
|
+
| 関数 | 文字コード変換サポート判定 | CODEの/CODEを | 文字コードCODEをサポートしているか確認 | もじこーどさぽーとはんてい | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L1274
|
|
490
|
+
| 関数 | SJIS変換 | STRに/STRへ/STRを | (v1非互換)文字列をShift_JISのバイナリバッファに変換 | SJISへんかん | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L1282
|
|
491
|
+
| 関数 | SJIS取得 | BUFから/BUFを/BUFで | Shift_JISのバイナリバッファを文字列に変換 | SJISしゅとく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L1291
|
|
492
|
+
| 関数 | エンコーディング変換 | SをCODEへ/CODEで | 文字列SをCODEへ変換してバイナリバッファを返す | えんこーでぃんぐへんかん | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L1300
|
|
493
|
+
| 関数 | エンコーディング取得 | BUFをCODEから/CODEで | バイナリバッファBUFをCODEから変換して返す | えんこーでぃんぐしゅとく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L1309
|
|
494
|
+
●ハッシュ関数
|
|
495
|
+
| 関数 | ハッシュ関数一覧取得 | | 利用可能なハッシュ関数の一覧を返す | はっしゅかんすういちらんしゅとく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L1319
|
|
496
|
+
| 関数 | ハッシュ値計算 | SをALGのENCで | データSをアルゴリズムALG(sha256/sha512/md5)のエンコーディングENC(hex/base64)でハッシュ値を計算して返す | はっしゅちけいさん | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L1327
|
|
422
497
|
|
|
423
498
|
|
|
424
499
|
■plugin_httpserver(基本プラグイン,cnako)
|
package/core/package.json
CHANGED
package/core/src/nako_gen.mjs
CHANGED
|
@@ -983,17 +983,6 @@ export class NakoGen {
|
|
|
983
983
|
}
|
|
984
984
|
return code;
|
|
985
985
|
}
|
|
986
|
-
convRefProp(node) {
|
|
987
|
-
const name = this._convGen(node.name, true);
|
|
988
|
-
const list = node.index;
|
|
989
|
-
if (!list || list.length <= 0) {
|
|
990
|
-
throw NakoSyntaxError.fromNode('プロパティがありません。', node);
|
|
991
|
-
}
|
|
992
|
-
const prop = list[0].value;
|
|
993
|
-
const code = `( (function(){ if (${name}.__getProp) { return ${name}.__getProp('${prop}', __self) } ` +
|
|
994
|
-
`else { return ${name}['${prop}'] } })() )`;
|
|
995
|
-
return code;
|
|
996
|
-
}
|
|
997
986
|
convLetArray(node) {
|
|
998
987
|
const id = this.loopId++;
|
|
999
988
|
const valueNode = node.blocks[0];
|
|
@@ -1771,15 +1760,13 @@ export class NakoGen {
|
|
|
1771
1760
|
if (!node.blocks || node.blocks.length == 0) {
|
|
1772
1761
|
throw NakoSyntaxError.fromNode('代入する値がありません。', node);
|
|
1773
1762
|
}
|
|
1774
|
-
const
|
|
1775
|
-
const
|
|
1776
|
-
|
|
1777
|
-
if (astProp) {
|
|
1778
|
-
prop = astProp.value;
|
|
1779
|
-
}
|
|
1780
|
-
else {
|
|
1763
|
+
const propList = node.index;
|
|
1764
|
+
const propTopAst = propList.pop();
|
|
1765
|
+
if (propTopAst === undefined) {
|
|
1781
1766
|
throw NakoSyntaxError.fromNode('代入する先のプロパティ名がありません。', node);
|
|
1782
1767
|
}
|
|
1768
|
+
const propTop = (typeof propTopAst.value === 'string') ? propTopAst.value : '';
|
|
1769
|
+
const astValue = node.blocks[0];
|
|
1783
1770
|
let value = null;
|
|
1784
1771
|
// 値のプログラムを生成
|
|
1785
1772
|
if (astValue) {
|
|
@@ -1796,12 +1783,56 @@ export class NakoGen {
|
|
|
1796
1783
|
if (res === null) {
|
|
1797
1784
|
throw NakoSyntaxError.fromNode(`変数『${name}』が見当たりません。`, node);
|
|
1798
1785
|
}
|
|
1786
|
+
// 変数のプロパティ
|
|
1787
|
+
let nameJs = res.js;
|
|
1788
|
+
if (propList.length > 0) {
|
|
1789
|
+
for (const prop of propList) {
|
|
1790
|
+
if (typeof prop.value === 'string') {
|
|
1791
|
+
nameJs += `['${prop.value}']`;
|
|
1792
|
+
}
|
|
1793
|
+
else {
|
|
1794
|
+
throw NakoSyntaxError.fromNode(`変数『${nameJs}』以下のプロパティにアクセスできません。`, node);
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1799
1798
|
// プロパティへの代入式を作る
|
|
1800
|
-
|
|
1801
|
-
code += `
|
|
1802
|
-
code += `else { ${propVar} = ${value} };`;
|
|
1799
|
+
code += `if (typeof ${nameJs}.__setProp === 'function') { ${nameJs}.__setProp('${propTop}', ${value}, __self); } `;
|
|
1800
|
+
code += `else { ${nameJs}['${propTop}'] = ${value} };`;
|
|
1803
1801
|
return ';' + this.convLineno(node, false) + code + '\n';
|
|
1804
1802
|
}
|
|
1803
|
+
// プロパティへの参照 (#1793)
|
|
1804
|
+
convRefProp(node) {
|
|
1805
|
+
const name = this._convGen(node.name, true);
|
|
1806
|
+
const list = node.index;
|
|
1807
|
+
if (!list || list.length <= 0) {
|
|
1808
|
+
throw NakoSyntaxError.fromNode('プロパティがありません。', node);
|
|
1809
|
+
}
|
|
1810
|
+
let code;
|
|
1811
|
+
const propList = list;
|
|
1812
|
+
if (propList.length <= 1) {
|
|
1813
|
+
const propKey = propList[0].value;
|
|
1814
|
+
const code_call = `${name}.__getProp('${propKey}', __self)`;
|
|
1815
|
+
const code_prop = `${name}['${propKey}']`;
|
|
1816
|
+
const code_if = `if (${name}.__getProp) { return ${code_call} } else { return ${code_prop} }`;
|
|
1817
|
+
code = `( (()=>{ ${code_if} })() )`;
|
|
1818
|
+
}
|
|
1819
|
+
else {
|
|
1820
|
+
const arrs = [];
|
|
1821
|
+
const keys = [];
|
|
1822
|
+
for (let i = 0; i < propList.length; i++) {
|
|
1823
|
+
const propKey = propList[i].value;
|
|
1824
|
+
keys.push(`['${propKey}']`);
|
|
1825
|
+
arrs.push(`'${propKey}'`);
|
|
1826
|
+
}
|
|
1827
|
+
const keyStr = keys.join('');
|
|
1828
|
+
const arrStr = '[' + arrs.join(',') + ']';
|
|
1829
|
+
const code_call = `${name}.__getProp(${arrStr}, __self)`;
|
|
1830
|
+
const code_prop = `${name}${keyStr}`;
|
|
1831
|
+
const code_if = `if (${name}.__getProp) { return ${code_call} } else { return ${code_prop} }`;
|
|
1832
|
+
code = `( (()=>{ ${code_if} })() )`;
|
|
1833
|
+
}
|
|
1834
|
+
return code;
|
|
1835
|
+
}
|
|
1805
1836
|
convDefLocalVar(node) {
|
|
1806
1837
|
const astValue = node.blocks[0];
|
|
1807
1838
|
let value = '0';
|
package/core/src/nako_gen.mts
CHANGED
|
@@ -1059,19 +1059,6 @@ export class NakoGen {
|
|
|
1059
1059
|
return code
|
|
1060
1060
|
}
|
|
1061
1061
|
|
|
1062
|
-
convRefProp (node: Ast): string {
|
|
1063
|
-
const name = this._convGen(node.name as Ast, true)
|
|
1064
|
-
const list: Ast[] | undefined = node.index
|
|
1065
|
-
if (!list || list.length <= 0) {
|
|
1066
|
-
throw NakoSyntaxError.fromNode('プロパティがありません。', node)
|
|
1067
|
-
}
|
|
1068
|
-
const prop = (list[0] as AstStrValue).value
|
|
1069
|
-
const code =
|
|
1070
|
-
`( (function(){ if (${name}.__getProp) { return ${name}.__getProp('${prop}', __self) } ` +
|
|
1071
|
-
`else { return ${name}['${prop}'] } })() )`
|
|
1072
|
-
return code
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
1062
|
convLetArray (node: AstLetArray): string {
|
|
1076
1063
|
const id = this.loopId++
|
|
1077
1064
|
const valueNode: Ast = node.blocks[0]
|
|
@@ -1834,14 +1821,11 @@ export class NakoGen {
|
|
|
1834
1821
|
convLetProp(node: AstLet): string {
|
|
1835
1822
|
if (!node.index || node.index.length == 0) { throw NakoSyntaxError.fromNode('代入する先のプロパティ名がありません。', node) }
|
|
1836
1823
|
if (!node.blocks || node.blocks.length == 0) { throw NakoSyntaxError.fromNode('代入する値がありません。', node) }
|
|
1837
|
-
const
|
|
1824
|
+
const propList = node.index as AstStrValue[]
|
|
1825
|
+
const propTopAst = propList.pop()
|
|
1826
|
+
if (propTopAst === undefined) { throw NakoSyntaxError.fromNode('代入する先のプロパティ名がありません。', node) }
|
|
1827
|
+
const propTop = (typeof propTopAst.value === 'string') ? propTopAst.value : ''
|
|
1838
1828
|
const astValue = node.blocks[0]
|
|
1839
|
-
let prop = ''
|
|
1840
|
-
if (astProp) {
|
|
1841
|
-
prop = (astProp as AstStrValue).value
|
|
1842
|
-
} else {
|
|
1843
|
-
throw NakoSyntaxError.fromNode('代入する先のプロパティ名がありません。', node)
|
|
1844
|
-
}
|
|
1845
1829
|
let value = null
|
|
1846
1830
|
// 値のプログラムを生成
|
|
1847
1831
|
if (astValue) {
|
|
@@ -1849,7 +1833,6 @@ export class NakoGen {
|
|
|
1849
1833
|
} else {
|
|
1850
1834
|
throw NakoSyntaxError.fromNode('代入する値がありません。', node)
|
|
1851
1835
|
}
|
|
1852
|
-
|
|
1853
1836
|
// 変数名
|
|
1854
1837
|
const name: string = node.name
|
|
1855
1838
|
const res = this.findVar(name, value)
|
|
@@ -1858,12 +1841,55 @@ export class NakoGen {
|
|
|
1858
1841
|
if (res === null) {
|
|
1859
1842
|
throw NakoSyntaxError.fromNode(`変数『${name}』が見当たりません。`, node)
|
|
1860
1843
|
}
|
|
1844
|
+
// 変数のプロパティ
|
|
1845
|
+
let nameJs = res.js
|
|
1846
|
+
if (propList.length > 0) {
|
|
1847
|
+
for (const prop of propList) {
|
|
1848
|
+
if (typeof prop.value === 'string') {
|
|
1849
|
+
nameJs += `['${prop.value}']`
|
|
1850
|
+
} else {
|
|
1851
|
+
throw NakoSyntaxError.fromNode(
|
|
1852
|
+
`変数『${nameJs}』以下のプロパティにアクセスできません。`, node)
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1861
1856
|
// プロパティへの代入式を作る
|
|
1862
|
-
|
|
1863
|
-
code += `
|
|
1864
|
-
code += `else { ${propVar} = ${value} };`
|
|
1857
|
+
code += `if (typeof ${nameJs}.__setProp === 'function') { ${nameJs}.__setProp('${propTop}', ${value}, __self); } `
|
|
1858
|
+
code += `else { ${nameJs}['${propTop}'] = ${value} };`
|
|
1865
1859
|
return ';' + this.convLineno(node, false) + code + '\n'
|
|
1866
1860
|
}
|
|
1861
|
+
// プロパティへの参照 (#1793)
|
|
1862
|
+
convRefProp(node: Ast): string {
|
|
1863
|
+
const name = this._convGen(node.name as Ast, true)
|
|
1864
|
+
const list: Ast[] | undefined = node.index
|
|
1865
|
+
if (!list || list.length <= 0) {
|
|
1866
|
+
throw NakoSyntaxError.fromNode('プロパティがありません。', node)
|
|
1867
|
+
}
|
|
1868
|
+
let code
|
|
1869
|
+
const propList = list as AstStrValue[]
|
|
1870
|
+
if (propList.length <= 1) {
|
|
1871
|
+
const propKey = propList[0].value
|
|
1872
|
+
const code_call = `${name}.__getProp('${propKey}', __self)`
|
|
1873
|
+
const code_prop = `${name}['${propKey}']`
|
|
1874
|
+
const code_if = `if (${name}.__getProp) { return ${code_call} } else { return ${code_prop} }`
|
|
1875
|
+
code = `( (()=>{ ${code_if} })() )`
|
|
1876
|
+
} else {
|
|
1877
|
+
const arrs = []
|
|
1878
|
+
const keys = []
|
|
1879
|
+
for (let i = 0; i < propList.length; i++) {
|
|
1880
|
+
const propKey = propList[i].value
|
|
1881
|
+
keys.push(`['${propKey}']`)
|
|
1882
|
+
arrs.push(`'${propKey}'`)
|
|
1883
|
+
}
|
|
1884
|
+
const keyStr = keys.join('')
|
|
1885
|
+
const arrStr = '[' + arrs.join(',') + ']'
|
|
1886
|
+
const code_call = `${name}.__getProp(${arrStr}, __self)`
|
|
1887
|
+
const code_prop = `${name}${keyStr}`
|
|
1888
|
+
const code_if = `if (${name}.__getProp) { return ${code_call} } else { return ${code_prop} }`
|
|
1889
|
+
code = `( (()=>{ ${code_if} })() )`
|
|
1890
|
+
}
|
|
1891
|
+
return code
|
|
1892
|
+
}
|
|
1867
1893
|
|
|
1868
1894
|
convDefLocalVar(node: AstDefVar): string {
|
|
1869
1895
|
const astValue = node.blocks[0]
|
|
@@ -11,7 +11,10 @@ const wordSpecial = /^(かつ|または)/;
|
|
|
11
11
|
const errorRead = (ch) => {
|
|
12
12
|
return function () { throw new Error('突然の『' + ch + '』があります。'); };
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
// 数値の後の単位は自動的に省略されるルール (#994)
|
|
15
|
+
export const unitRE = /^(円|ドル|元|歩|㎡|坪|度|℃|°|個|つ|本|冊|才|歳|匹|枚|皿|セット|羽|人|件|行|列|機|品|m|mm|cm|km|g|kg|t|b|mb|kb|gb)/;
|
|
16
|
+
// CSSの単位であれば自動的に文字列に変換するルール (#1811)
|
|
17
|
+
export const cssUnitRE = /^(px|em|ex|rem|vw|vh|vmin|vmax)/;
|
|
15
18
|
/** トークンに区切るルールの一覧 */
|
|
16
19
|
export const rules = [
|
|
17
20
|
// 上から順にマッチさせていく
|
|
@@ -81,7 +84,7 @@ export const rules = [
|
|
|
81
84
|
{ name: ')', pattern: /^\)/, readJosi: true },
|
|
82
85
|
{ name: '|', pattern: /^\|/ },
|
|
83
86
|
{ name: '??', pattern: /^\?\?/ }, // 「表示」のエイリアス #1745
|
|
84
|
-
{ name: '$', pattern:
|
|
87
|
+
{ name: '$', pattern: /^(\$|\.)/ }, // プロパティアクセス (#1793)(#1807)
|
|
85
88
|
{ name: 'string', pattern: /^🌿/, cbParser: src => cbString('🌿', '🌿', src) },
|
|
86
89
|
{ name: 'string_ex', pattern: /^🌴/, cbParser: src => cbString('🌴', '🌴', src) },
|
|
87
90
|
{ name: 'string_ex', pattern: /^「/, cbParser: src => cbString('「', '」', src) },
|
|
@@ -15,7 +15,10 @@ const errorRead = (ch: string): any => {
|
|
|
15
15
|
return function () { throw new Error('突然の『' + ch + '』があります。') }
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
// 数値の後の単位は自動的に省略されるルール (#994)
|
|
19
|
+
export const unitRE = /^(円|ドル|元|歩|㎡|坪|度|℃|°|個|つ|本|冊|才|歳|匹|枚|皿|セット|羽|人|件|行|列|機|品|m|mm|cm|km|g|kg|t|b|mb|kb|gb)/
|
|
20
|
+
// CSSの単位であれば自動的に文字列に変換するルール (#1811)
|
|
21
|
+
export const cssUnitRE = /^(px|em|ex|rem|vw|vh|vmin|vmax)/
|
|
19
22
|
|
|
20
23
|
export interface NakoLexParseResult {
|
|
21
24
|
src: string;
|
|
@@ -101,7 +104,7 @@ export const rules: NakoLexRule[] = [
|
|
|
101
104
|
{ name: ')', pattern: /^\)/, readJosi: true },
|
|
102
105
|
{ name: '|', pattern: /^\|/ },
|
|
103
106
|
{ name: '??', pattern: /^\?\?/ }, // 「表示」のエイリアス #1745
|
|
104
|
-
{ name: '$', pattern:
|
|
107
|
+
{ name: '$', pattern: /^(\$|\.)/ }, // プロパティアクセス (#1793)(#1807)
|
|
105
108
|
{ name: 'string', pattern: /^🌿/, cbParser: src => cbString('🌿', '🌿', src) },
|
|
106
109
|
{ name: 'string_ex', pattern: /^🌴/, cbParser: src => cbString('🌴', '🌴', src) },
|
|
107
110
|
{ name: 'string_ex', pattern: /^「/, cbParser: src => cbString('「', '」', src) },
|
package/core/src/nako_lexer.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import { isIndentChars } from './nako_indent_chars.mjs';
|
|
|
10
10
|
// 助詞の一覧
|
|
11
11
|
import { josiRE, removeJosiMap, tararebaMap, josiListExport } from './nako_josi_list.mjs';
|
|
12
12
|
// 字句解析ルールの一覧
|
|
13
|
-
import { rules, unitRE } from './nako_lex_rules.mjs';
|
|
13
|
+
import { rules, unitRE, cssUnitRE } from './nako_lex_rules.mjs';
|
|
14
14
|
import { NakoLexerError, InternalLexerError } from './nako_errors.mjs';
|
|
15
15
|
export class NakoLexer {
|
|
16
16
|
/**
|
|
@@ -578,6 +578,7 @@ export class NakoLexer {
|
|
|
578
578
|
if (!m) {
|
|
579
579
|
continue;
|
|
580
580
|
}
|
|
581
|
+
let ruleName = rule.name;
|
|
581
582
|
ok = true;
|
|
582
583
|
// 空白ならスキップ
|
|
583
584
|
if (rule.name === 'space') {
|
|
@@ -676,6 +677,14 @@ export class NakoLexer {
|
|
|
676
677
|
src = src.substring(um[0].length);
|
|
677
678
|
column += m[0].length;
|
|
678
679
|
}
|
|
680
|
+
// CSSの単位なら自動的に文字列として認識させる #1811
|
|
681
|
+
const cssUnit = cssUnitRE.exec(src);
|
|
682
|
+
if (cssUnit) {
|
|
683
|
+
ruleName = 'string';
|
|
684
|
+
src = src.substring(cssUnit[0].length);
|
|
685
|
+
column += m[0].length;
|
|
686
|
+
value += cssUnit[0];
|
|
687
|
+
}
|
|
679
688
|
}
|
|
680
689
|
let josi = '';
|
|
681
690
|
if (rule.readJosi) {
|
|
@@ -699,7 +708,7 @@ export class NakoLexer {
|
|
|
699
708
|
}
|
|
700
709
|
}
|
|
701
710
|
}
|
|
702
|
-
switch (
|
|
711
|
+
switch (ruleName) {
|
|
703
712
|
case 'def_test': {
|
|
704
713
|
isDefTest = true;
|
|
705
714
|
break;
|
|
@@ -713,12 +722,12 @@ export class NakoLexer {
|
|
|
713
722
|
}
|
|
714
723
|
}
|
|
715
724
|
// ここまで‰(#682) を処理
|
|
716
|
-
if (
|
|
725
|
+
if (ruleName === 'dec_lineno') {
|
|
717
726
|
line--;
|
|
718
727
|
continue;
|
|
719
728
|
}
|
|
720
729
|
result.push({
|
|
721
|
-
type:
|
|
730
|
+
type: ruleName,
|
|
722
731
|
value,
|
|
723
732
|
indent,
|
|
724
733
|
line: lineCurrent,
|
|
@@ -729,7 +738,7 @@ export class NakoLexer {
|
|
|
729
738
|
preprocessedCodeLength: (srcLength - src.length) - srcOffset
|
|
730
739
|
});
|
|
731
740
|
// 改行のとき次の行のインデントを調べる。なお、改行の後は必ずcolumnが1になる。インデント構文のため、一行に2つ以上の文を含むときを考慮する。(core #66)
|
|
732
|
-
if (
|
|
741
|
+
if (ruleName === 'eol' && column === 1) {
|
|
733
742
|
const ia = this.countIndent(src);
|
|
734
743
|
indent = ia[0];
|
|
735
744
|
column += ia[1];
|
package/core/src/nako_lexer.mts
CHANGED
|
@@ -14,7 +14,7 @@ import { isIndentChars } from './nako_indent_chars.mjs'
|
|
|
14
14
|
import { josiRE, removeJosiMap, tararebaMap, josiListExport } from './nako_josi_list.mjs'
|
|
15
15
|
|
|
16
16
|
// 字句解析ルールの一覧
|
|
17
|
-
import { rules, unitRE, NakoLexParseResult } from './nako_lex_rules.mjs'
|
|
17
|
+
import { rules, unitRE, cssUnitRE, NakoLexParseResult } from './nako_lex_rules.mjs'
|
|
18
18
|
import { NakoLexerError, InternalLexerError } from './nako_errors.mjs'
|
|
19
19
|
|
|
20
20
|
import { FuncList, FuncArgs, ExportMap, FuncListItem } from './nako_types.mjs'
|
|
@@ -563,6 +563,7 @@ export class NakoLexer {
|
|
|
563
563
|
// 正規表現でマッチ
|
|
564
564
|
const m = rule.pattern.exec(src)
|
|
565
565
|
if (!m) { continue }
|
|
566
|
+
let ruleName = rule.name
|
|
566
567
|
ok = true
|
|
567
568
|
// 空白ならスキップ
|
|
568
569
|
if (rule.name === 'space') {
|
|
@@ -673,6 +674,14 @@ export class NakoLexer {
|
|
|
673
674
|
src = src.substring(um[0].length)
|
|
674
675
|
column += m[0].length
|
|
675
676
|
}
|
|
677
|
+
// CSSの単位なら自動的に文字列として認識させる #1811
|
|
678
|
+
const cssUnit = cssUnitRE.exec(src)
|
|
679
|
+
if (cssUnit) {
|
|
680
|
+
ruleName = 'string'
|
|
681
|
+
src = src.substring(cssUnit[0].length)
|
|
682
|
+
column += m[0].length
|
|
683
|
+
value += cssUnit[0]
|
|
684
|
+
}
|
|
676
685
|
}
|
|
677
686
|
|
|
678
687
|
let josi = ''
|
|
@@ -696,7 +705,7 @@ export class NakoLexer {
|
|
|
696
705
|
}
|
|
697
706
|
}
|
|
698
707
|
|
|
699
|
-
switch (
|
|
708
|
+
switch (ruleName) {
|
|
700
709
|
case 'def_test': {
|
|
701
710
|
isDefTest = true
|
|
702
711
|
break
|
|
@@ -710,13 +719,13 @@ export class NakoLexer {
|
|
|
710
719
|
}
|
|
711
720
|
}
|
|
712
721
|
// ここまで‰(#682) を処理
|
|
713
|
-
if (
|
|
722
|
+
if (ruleName === 'dec_lineno') {
|
|
714
723
|
line--
|
|
715
724
|
continue
|
|
716
725
|
}
|
|
717
726
|
|
|
718
727
|
result.push({
|
|
719
|
-
type:
|
|
728
|
+
type: ruleName,
|
|
720
729
|
value,
|
|
721
730
|
indent,
|
|
722
731
|
line: lineCurrent,
|
|
@@ -727,7 +736,7 @@ export class NakoLexer {
|
|
|
727
736
|
preprocessedCodeLength: (srcLength - src.length) - srcOffset
|
|
728
737
|
})
|
|
729
738
|
// 改行のとき次の行のインデントを調べる。なお、改行の後は必ずcolumnが1になる。インデント構文のため、一行に2つ以上の文を含むときを考慮する。(core #66)
|
|
730
|
-
if (
|
|
739
|
+
if (ruleName === 'eol' && column === 1) {
|
|
731
740
|
const ia = this.countIndent(src)
|
|
732
741
|
indent = ia[0]
|
|
733
742
|
column += ia[1]
|