nadesiko3 3.3.47 → 3.3.50
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/README.md +13 -2
- package/batch/.DS_Store +0 -0
- package/batch/command.txt +11 -0
- package/batch/command_nakopad.txt +9 -0
- package/batch/pickup_command.nako3 +2 -2
- package/core/LICENSE +21 -0
- package/core/README.md +66 -0
- package/core/batch/build_nako_version.nako3 +42 -0
- package/core/command/snako.mjs +105 -0
- package/core/command/snako.mts +116 -0
- package/core/index.mjs +21 -0
- package/core/package.json +47 -0
- package/core/sample/hello.nako3 +7 -0
- package/core/sample/hoge.mjs +4 -0
- package/core/sample/hoge.mts +6 -0
- package/core/src/nako3.mjs +864 -0
- package/core/src/nako3.mts +976 -0
- package/core/src/nako_colors.mjs +78 -0
- package/core/src/nako_colors.mts +86 -0
- package/core/src/nako_core_version.mjs +8 -0
- package/core/src/nako_core_version.mts +19 -0
- package/core/src/nako_csv.mjs +185 -0
- package/core/src/nako_csv.mts +188 -0
- package/core/src/nako_errors.mjs +173 -0
- package/core/src/nako_errors.mts +197 -0
- package/core/src/nako_from_dncl.mjs +255 -0
- package/core/src/nako_from_dncl.mts +250 -0
- package/core/src/nako_gen.mjs +1647 -0
- package/core/src/nako_gen.mts +1718 -0
- package/core/src/nako_gen_async.mjs +1659 -0
- package/core/src/nako_gen_async.mts +1732 -0
- package/core/src/nako_global.mjs +107 -0
- package/core/src/nako_global.mts +138 -0
- package/core/src/nako_indent.mjs +445 -0
- package/core/src/nako_indent.mts +492 -0
- package/core/src/nako_josi_list.mjs +38 -0
- package/core/src/nako_josi_list.mts +45 -0
- package/core/src/nako_lex_rules.mjs +253 -0
- package/core/src/nako_lex_rules.mts +260 -0
- package/core/src/nako_lexer.mjs +609 -0
- package/core/src/nako_lexer.mts +612 -0
- package/core/src/nako_logger.mjs +199 -0
- package/core/src/nako_logger.mts +232 -0
- package/core/src/nako_parser3.mjs +2439 -0
- package/core/src/nako_parser3.mts +2195 -0
- package/core/src/nako_parser_base.mjs +370 -0
- package/core/src/nako_parser_base.mts +370 -0
- package/core/src/nako_parser_const.mjs +37 -0
- package/core/src/nako_parser_const.mts +37 -0
- package/core/src/nako_prepare.mjs +304 -0
- package/core/src/nako_prepare.mts +315 -0
- package/core/src/nako_reserved_words.mjs +38 -0
- package/core/src/nako_reserved_words.mts +38 -0
- package/core/src/nako_source_mapping.mjs +207 -0
- package/core/src/nako_source_mapping.mts +262 -0
- package/core/src/nako_test.mjs +37 -0
- package/core/src/nako_types.mjs +25 -0
- package/core/src/nako_types.mts +151 -0
- package/core/src/plugin_csv.mjs +49 -0
- package/core/src/plugin_csv.mts +50 -0
- package/core/src/plugin_math.mjs +328 -0
- package/core/src/plugin_math.mts +326 -0
- package/core/src/plugin_promise.mjs +91 -0
- package/core/src/plugin_promise.mts +91 -0
- package/core/src/plugin_system.mjs +2832 -0
- package/core/src/plugin_system.mts +2690 -0
- package/core/src/plugin_test.mjs +34 -0
- package/core/src/plugin_test.mts +34 -0
- package/demo/.DS_Store +0 -0
- package/demo/extlib/.DS_Store +0 -0
- package/package.json +9 -6
- package/release/_hash.txt +24 -24
- package/release/_script-tags.txt +14 -14
- 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/editor.js +1 -1
- package/release/nako_gen_async.js +1 -1
- package/release/nako_gen_async.js.LICENSE.txt +27 -27
- package/release/stats.json +1 -1
- package/release/version.js +1 -1
- package/release/wnako3.js +1 -1
- package/release/wnako3webworker.js +1 -1
- package/release/wnako3webworker.js.LICENSE.txt +97 -97
- package/src/.DS_Store +0 -0
- package/src/cnako3mod.mjs +32 -16
- package/src/cnako3mod.mts +29 -16
- package/src/enako3.mjs +2 -3
- package/src/image_turtle-elephant.mjs +0 -3
- package/src/image_turtle-panda.mjs +0 -3
- package/src/image_turtle64.mjs +0 -3
- package/src/index.mjs +1 -1
- package/src/index.mts +1 -2
- package/src/nako_version.mjs +2 -2
- package/src/nako_version.mts +2 -2
- package/src/plugin_browser.mjs +3 -2
- package/src/plugin_browser.mts +3 -2
- package/src/plugin_httpserver.mjs +277 -0
- package/src/plugin_httpserver.mts +286 -0
- package/src/wnako3_editor.mjs +8 -8
- package/src/wnako3_editor.mts +12 -10
- package/src/wnako3mod.mjs +3 -3
- package/src/wnako3mod.mts +6 -6
- package/src/wnako3webworker.mjs +2 -1
- package/test/.DS_Store +0 -0
- package/test/async/async_basic_test.mjs +3 -3
- package/test/browser/.DS_Store +0 -0
- package/test/bundled/.DS_Store +0 -0
- package/test/bundled/test_base/.DS_Store +0 -0
- package/test/common/.DS_Store +0 -0
- package/test/common/plugin_browser_test.mjs +2 -2
- package/test/common/plugin_browser_ut_audio_test.mjs +1 -1
- package/test/common/plugin_browser_ut_color_test.mjs +1 -1
- package/test/common/plugin_browser_ut_html_test.mjs +1 -1
- package/test/common/plugin_browser_ut_system_test.mjs +1 -1
- package/test/common/plugin_markup_test.mjs +2 -1
- package/test/node/.DS_Store +0 -0
- package/test/node/async_test.mjs +2 -1
- package/test/node/error_message_test.mjs +3 -2
- package/test/node/plugin_markup_test.mjs +2 -1
- package/test/node/plugin_math_test.mjs +2 -1
- package/test/node/plugin_node_test.mjs +3 -2
- package/test/node/require_nako3_test.mjs +2 -1
- package/test/node/wnako3_editor_test.mjs +2 -2
- package/tools/.DS_Store +0 -0
- package/tools/README.md +5 -0
- package/tools/nako3edit/.DS_Store +0 -0
- package/tools/nako3edit/html/.DS_Store +0 -0
- package/tools/nako3edit/index.mjs +8 -4
- package/tools/nako3server/index.html +10 -0
- package/tools/nako3server/index.nako3 +34 -0
package/README.md
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
## 関連リポジトリへのリンク
|
|
8
8
|
|
|
9
9
|
- [なでしこ3開発リポジトリ(GitHub)](https://github.com/kujirahand/nadesiko3/)
|
|
10
|
-
- [nadesiko3core](https://github.com/kujirahand/nadesiko3core/) --- 言語コア
|
|
11
10
|
- [なでしこ3拡張プラグイン](https://nadesi.com/v3/doc/index.php?FAQ%2F%E6%8B%A1%E5%BC%B5%E3%83%97%E3%83%A9%E3%82%B0%E3%82%A4%E3%83%B3%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6&show)
|
|
12
11
|
- [nadesiko3-server](https://github.com/kujirahand/nadesiko3-server) --- Webサーバ(HTTP)
|
|
13
12
|
- [nadesiko3-websocket](https://github.com/kujirahand/nadesiko3-websocket) --- WebSocket
|
|
@@ -29,6 +28,8 @@
|
|
|
29
28
|
- [nadesiko3php - なでしこ3PHP](https://github.com/kujirahand/nadesiko3php)
|
|
30
29
|
- [nadesiko3rust - なでしこ3Rust](https://github.com/kujirahand/nadesiko3rust)
|
|
31
30
|
- [nadesiko3go - なでしこ3Go言語](https://github.com/kujirahand/nadesiko3go)
|
|
31
|
+
- 本リポジトリのサブモジュール
|
|
32
|
+
- [nadesiko3core](https://github.com/kujirahand/nadesiko3core/) --- 言語コア
|
|
32
33
|
|
|
33
34
|
## 「なでしこ3」とは
|
|
34
35
|
|
|
@@ -81,11 +82,21 @@ npm run nako3server
|
|
|
81
82
|
また、以下のコマンドを実行すると、ブラウザ上になでしこの簡易エディタが起動します。
|
|
82
83
|
|
|
83
84
|
```bash
|
|
84
|
-
git clone https://github.com/kujirahand/nadesiko3.git
|
|
85
|
+
git clone --recursive https://github.com/kujirahand/nadesiko3.git
|
|
85
86
|
cd nadesiko3
|
|
86
87
|
npm install
|
|
87
88
|
```
|
|
88
89
|
|
|
90
|
+
サブモジュールとして[`nadesiko3core`](https://github.com/kujirahand/nadesiko3core.git)を利用するので、`--recursive` を付け忘れたら以下のコマンドを実行して、サブモジュールも取得してください。
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# 以下のように --recursive 付け忘れた場合
|
|
94
|
+
git clone https://github.com/kujirahand/nadesiko3.git
|
|
95
|
+
cd nadesiko3
|
|
96
|
+
# サブモジュールを取得する
|
|
97
|
+
git submodule update --init --recursive
|
|
98
|
+
```
|
|
99
|
+
|
|
89
100
|
## 追加インストール(macOS/Linux)
|
|
90
101
|
|
|
91
102
|
必要に応じて以下のコマンドをインストールします。
|
package/batch/.DS_Store
ADDED
|
Binary file
|
package/batch/command.txt
CHANGED
|
@@ -730,6 +730,17 @@
|
|
|
730
730
|
| 関数 | ハッシュ値計算 | SをALGのENCで | データSをアルゴリズムALG(sha256/sha512/md5)のエンコーディングENC(hex/base64)でハッシュ値を計算して返す | はっしゅちけいさん | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_node.mts#L955
|
|
731
731
|
|
|
732
732
|
|
|
733
|
+
■plugin_httpserver(基本プラグイン,cnako)
|
|
734
|
+
●簡易HTTPサーバ
|
|
735
|
+
| 定数 | GETデータ | | '' | GETでーた | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_httpserver.mts#L176
|
|
736
|
+
| 関数 | 簡易HTTPサーバ起動時 | CALLBACK: EASYHTTPONSTARTをPORTの/PORTで | ポート番号PORTを指定して簡易HTTPサーバを起動して、CALLBACKを実行する。 | かんいHTTPさーばきどうしたとき | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_httpserver.mts#L181
|
|
737
|
+
| 関数 | 簡易HTTPサーバ静的パス指定 | URLをPATHに/PATHへ | 静的コンテンツのパスを指定。URLをPATHへマップする。 | かんいHTTPさーばせいてきぱすしてい | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_httpserver.mts#L200
|
|
738
|
+
| 関数 | 簡易HTTPサーバ受信時 | CALLBACK: EASYURLCALLBACKをURLに/URLへ/URLで | URLを指定して合致するリクエストが来たら処理を実行する。 | かんいHTTPさーばじゅしんしたとき | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_httpserver.mts#L215
|
|
739
|
+
| 関数 | 簡易HTTPサーバ出力 | Sを/Sと/Sの | 受信時に、データSを出力する。 | かんいHTTPさーばしゅつりょく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_httpserver.mts#L233
|
|
740
|
+
| 関数 | 簡易HTTPサーバヘッダ出力 | NOでHEADを/HEADの/HEADと | 受信時にステータスコードNOで、ヘッダHEAD(辞書形式)を出力する。 | かんいHTTPさーばへっだしゅつりょく | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_httpserver.mts#L253
|
|
741
|
+
| 関数 | 簡易HTTPサーバ移動 | URLへ/URLに | 受信時にヘッダ302(リダイレクト)を出力してURLへページを移動力する。 | かんいHTTPさーばいどう | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_httpserver.mts#L270
|
|
742
|
+
|
|
743
|
+
|
|
733
744
|
■plugin_markup(基本プラグイン,wnako,cnako)
|
|
734
745
|
●マークアップ
|
|
735
746
|
| 関数 | マークダウンHTML変換 | Sを | マークダウン形式で記述された文字列SをHTML形式に変換する | まーくだうんHTMLへんかん | https://github.com/kujirahand/nadesiko3/tree/master/src/plugin_markup.mjs#L16
|
|
@@ -716,6 +716,15 @@
|
|
|
716
716
|
- �n�b�V����
|
|
717
717
|
|�n�b�V�����ꗗ�擾,"","���p�\�ȃn�b�V�����̈ꗗ��Ԃ�",0,,����,�͂����ォ���������Ƃ�
|
|
718
718
|
|�n�b�V���l�v�Z,"S��ALG��ENC��","�f�[�^S���A���S���Y��ALG(sha256/sha512/md5)�̃G���R�[�f�B���OENC(hex/base64)�Ńn�b�V���l���v�Z���ĕԂ�",0,,����,�͂����タ��������
|
|
719
|
+
+ plugin_httpserver(��{�v���O�C��,cnako)
|
|
720
|
+
- �Ȉ�HTTP�T�[�o
|
|
721
|
+
|GET�f�[�^,"","''",0,,�ϐ�,GET�Ł[��
|
|
722
|
+
|�Ȉ�HTTP�T�[�o�N����,"CALLBACK: EASYHTTPONSTART��PORT��|PORT��","�|�[�g�ԍ�PORT���w�肵�ĊȈ�HTTP�T�[�o���N�����āACALLBACK�����s����B",0,,����,����HTTP���[���ǂ������Ƃ�
|
|
723
|
+
|�Ȉ�HTTP�T�[�o�ÓI�p�X�w��,"URL��PATH��|PATH��","�ÓI�R���e���c�̃p�X���w��BURL��PATH�փ}�b�v����B",0,,����,����HTTP���[�����Ă��ς����Ă�
|
|
724
|
+
|�Ȉ�HTTP�T�[�o��M��,"CALLBACK: EASYURLCALLBACK��URL��|URL��|URL��","URL���w�肵�č��v���郊�N�G�X�g�������珈�������s����B",0,,����,����HTTP���[���サ���Ƃ�
|
|
725
|
+
|�Ȉ�HTTP�T�[�o�o��,"S��|S��|S��","��M���ɁA�f�[�^S���o�͂���B",0,,����,����HTTP���[�����傭
|
|
726
|
+
|�Ȉ�HTTP�T�[�o�w�b�_�o��,"NO��HEAD��|HEAD��|HEAD��","��M���ɃX�e�[�^�X�R�[�hNO�ŁA�w�b�_HEAD(�����`��)���o�͂���B",0,,����,����HTTP���[�ւ��������傭
|
|
727
|
+
|�Ȉ�HTTP�T�[�o�ړ�,"URL��|URL��","��M���Ƀw�b�_302(���_�C���N�g)���o�͂���URL�փy�[�W���ړ��͂���B",0,,����,����HTTP���[���ǂ�
|
|
719
728
|
+ plugin_markup(��{�v���O�C��,wnako,cnako)
|
|
720
729
|
- �}�[�N�A�b�v
|
|
721
730
|
|�}�[�N�_�E��HTML�ϊ�,"S��","�}�[�N�_�E���`���ŋL�q���ꂽ������S��HTML�`���ɕϊ�����",0,,����,�܁[��������HTML�ւ�
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
# 基本パスを取得
|
|
10
10
|
母艦パス取得してパス抽出して基本パスに代入。
|
|
11
11
|
REPOSパス=基本パスを「../」で相対パス展開。
|
|
12
|
-
|
|
13
|
-
CORE="node_modules/nadesiko3core/src"
|
|
12
|
+
CORE="core/src"
|
|
14
13
|
|
|
15
14
|
コアプラグイン一覧は[
|
|
16
15
|
["plugin_system.mts", 'wnako,cnako,phpnako'],
|
|
@@ -23,6 +22,7 @@ CORE="node_modules/nadesiko3core/src"
|
|
|
23
22
|
['src/plugin_browser.mjs','wnako'],
|
|
24
23
|
['src/plugin_turtle.mjs', 'wnako'],
|
|
25
24
|
['src/plugin_node.mts', 'cnako,phpnako'],
|
|
25
|
+
['src/plugin_httpserver.mts', 'cnako'],
|
|
26
26
|
['src/plugin_markup.mjs', 'wnako,cnako'],
|
|
27
27
|
['src/plugin_datetime.mjs', 'wnako,cnako'],
|
|
28
28
|
['src/plugin_caniuse.mjs', 'wnako,cnako'],
|
package/core/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 kujirahand
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/core/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# 日本語プログラミング言語「なでしこ3」言語エンジン
|
|
2
|
+
|
|
3
|
+
[](LICENSE)
|
|
4
|
+
[](https://www.npmjs.com/package/nadesiko3core)
|
|
5
|
+
|
|
6
|
+
## 「なでしこ3」とは
|
|
7
|
+
|
|
8
|
+
「なでしこ3」とは、日本語のプログラミング言語です。HTML5/JavaScript(TypeScript)をベースとしているので、PC/スマホ/タブレットなど、さまざまな環境で動作させることができます。日本語プログラミング言語は、読みやすく理解しやすいのが特徴で、初めてでも楽しくプログラミングを覚えることができます。
|
|
9
|
+
|
|
10
|
+
- [なでしこ3開発リポジトリ - nadesiko3](https://github.com/kujirahand/nadesiko3)
|
|
11
|
+
- [なでしこのWebサイト](https://nadesi.com/top/)
|
|
12
|
+
|
|
13
|
+
## 本リポジトリについて
|
|
14
|
+
|
|
15
|
+
本リポジトリは、なでしこ3の言語エンジンのみを取り出したものです。最小限の構成となっています。
|
|
16
|
+
言語機能と最小限のプラグインのみを備えています。
|
|
17
|
+
|
|
18
|
+
- [なでしこの基本文法(外部サイト)](https://nadesi.com/v3/doc/index.php?%E6%96%87%E6%B3%95)
|
|
19
|
+
|
|
20
|
+
最小限のプラグイン構成
|
|
21
|
+
|
|
22
|
+
- [plugin_system](./src/plugin_system.mts) --- 言語機能の補助など基本的な関数群
|
|
23
|
+
- [plugin_math](./src/plugin_math.mts) --- 数学関数群
|
|
24
|
+
- [plugin_csv](./src/plugin_csv.mts)--- CSV処理のための関数群
|
|
25
|
+
- [plugin_promise](./src/plugin_promise.mts) --- プロミス機能を実現するための関数群
|
|
26
|
+
- [plugin_test](./src/plugin_test.mts) --- テストを記述するための関数群
|
|
27
|
+
|
|
28
|
+
# 本ライブラリの使い方
|
|
29
|
+
|
|
30
|
+
例えば、`npm install nadesiko3core`でなでしこ3言語エンジンをインストールしたら、以下のプログラムを記述します。
|
|
31
|
+
`hoge.mjs`という名前で保存します。そして、以下のようなプログラムを記述します。
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
import core from 'nadesiko3core'
|
|
35
|
+
const com = new core.NakoCompiler()
|
|
36
|
+
const g = com.run('1 + 2 * 3を表示') // ← ここになでしこのプログラム
|
|
37
|
+
console.log(g.log) // ← 「表示」した内容がlogに入っている
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
プログラムを実行するには、`node hoge.mjs`と記述すれば実行できます。
|
|
41
|
+
|
|
42
|
+
## コマンドラインから実行したい場合
|
|
43
|
+
|
|
44
|
+
コマンドラインからなでしこのプログラムを実行したい場合には、[nadesiko3](https://github.com/kujirahand/nadesiko3)リポジトリを利用してください。nadesiko3リポジトリには、コマンドライン版のなでしこ(cnako3)が含まれています。
|
|
45
|
+
|
|
46
|
+
なお、本リポジトリにも、[簡易版のコマンドラインツール(snako)](/command/snako.mts)を収録しています。以下は簡単な使い方です。
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
# ファイル sample/hello.nako3 を実行
|
|
50
|
+
$ node command/snako.mjs sample/hello.nako3
|
|
51
|
+
|
|
52
|
+
# その場でコードを実行
|
|
53
|
+
$ node command/snako.mjs -e "1+2を表示"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 簡易コマンドラインをグローバルインストールして使う場合
|
|
57
|
+
|
|
58
|
+
簡易コマンドライン(snako)を手軽に利用したい場合は、次のように実行します。
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
$ npm install -g nadesiko3core
|
|
62
|
+
$ snako -e "1+2を表示"
|
|
63
|
+
$ snako nadesiko3core/sample/hello.nako3
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env cnako3
|
|
2
|
+
# -----------------------------------------------------
|
|
3
|
+
# なでしこのバージョン情報を自動生成する
|
|
4
|
+
# -----------------------------------------------------
|
|
5
|
+
# ●説明
|
|
6
|
+
# package.json の内容を読んで ./src/nako_core_version.mts を生成
|
|
7
|
+
# -----------------------------------------------------
|
|
8
|
+
母艦パス取得してパス抽出して基本パスに代入。
|
|
9
|
+
「{基本パス}/package.json」を読んでJSONデコードして、Pに代入。
|
|
10
|
+
VER=P@"version"
|
|
11
|
+
定数[MAJOR,MINOR,PATCH]=(VERを「.」で区切る)
|
|
12
|
+
QS=『{』
|
|
13
|
+
QE=『}』
|
|
14
|
+
VS=「/**
|
|
15
|
+
* なでしこのバージョン情報
|
|
16
|
+
* package.json から自動的に作成されます。このファイルを編集しないでください。
|
|
17
|
+
*/
|
|
18
|
+
// 型定義
|
|
19
|
+
export interface NakoCoreVersion {QS}
|
|
20
|
+
version: string;
|
|
21
|
+
major: number;
|
|
22
|
+
minor: number;
|
|
23
|
+
patch: number;
|
|
24
|
+
{QE}
|
|
25
|
+
// 実際のバージョン定義 (自動生成されるので以下を編集しない)
|
|
26
|
+
const coreVersion: NakoCoreVersion = {QS}
|
|
27
|
+
version: '{VER}',
|
|
28
|
+
major: {MAJOR},
|
|
29
|
+
minor: {MINOR},
|
|
30
|
+
patch: {PATCH}
|
|
31
|
+
{QE}
|
|
32
|
+
export default coreVersion
|
|
33
|
+
」
|
|
34
|
+
保存先=「{基本パス}/src/nako_core_version.mts」
|
|
35
|
+
VSを保存先へ保存。
|
|
36
|
+
「
|
|
37
|
+
# ---------------------------------------------
|
|
38
|
+
# ● なでしこのバージョン情報を更新しました。
|
|
39
|
+
# version {VER}
|
|
40
|
+
# file: {保存先}
|
|
41
|
+
# ---------------------------------------------
|
|
42
|
+
」を表示。
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import com from '../index.mjs';
|
|
5
|
+
import * as url from 'url';
|
|
6
|
+
import { NakoGenOptions } from '../src/nako_gen.mjs';
|
|
7
|
+
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
|
8
|
+
/** コマンドラインオプション */
|
|
9
|
+
class CommandOptions {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.nodePath = '';
|
|
12
|
+
this.scriptPath = '';
|
|
13
|
+
this.filename = '';
|
|
14
|
+
this.evalStr = '';
|
|
15
|
+
this.isDebug = false;
|
|
16
|
+
this.flagConvert = false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** メイン処理 */
|
|
20
|
+
function main(argvOrg) {
|
|
21
|
+
// コマンドラインオプションを確認
|
|
22
|
+
const argv = [...argvOrg];
|
|
23
|
+
const opt = new CommandOptions();
|
|
24
|
+
opt.nodePath = argv.shift() || '';
|
|
25
|
+
opt.scriptPath = argv.shift() || '';
|
|
26
|
+
while (argv.length > 0) {
|
|
27
|
+
const arg = argv.shift() || '';
|
|
28
|
+
if (arg === '-d' || arg === '--debug') {
|
|
29
|
+
opt.isDebug = true;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (arg === '-e' || arg === '--eval') {
|
|
33
|
+
opt.evalStr = argv.shift() || '';
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (arg === '-c' || arg === '--convert') {
|
|
37
|
+
opt.flagConvert = true;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (opt.filename === '') {
|
|
41
|
+
opt.filename = arg;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// なでしこのコンパイラを生成
|
|
45
|
+
const nako = new com.NakoCompiler();
|
|
46
|
+
// 実行前にイベントを挟みたいとき
|
|
47
|
+
nako.addListener('beforeRun', (g) => {
|
|
48
|
+
g.__varslist[0]['ナデシコ種類'] = 'snako';
|
|
49
|
+
});
|
|
50
|
+
// logger を設定 --- リスナーを登録することでデバッグレベルを指定
|
|
51
|
+
const logger = nako.getLogger();
|
|
52
|
+
if (opt.isDebug) {
|
|
53
|
+
logger.addListener('trace', (data) => {
|
|
54
|
+
console.log(data.nodeConsole);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
logger.addListener('stdout', (data) => {
|
|
58
|
+
console.log(data.noColor);
|
|
59
|
+
});
|
|
60
|
+
// -e オプションを実行したとき
|
|
61
|
+
if (opt.evalStr) {
|
|
62
|
+
nako.run(opt.evalStr);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
// パラメータが空だったとき
|
|
66
|
+
if (opt.filename === '') {
|
|
67
|
+
showHelp();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
// ソースコードをファイルから読み込む
|
|
71
|
+
const code = fs.readFileSync(opt.filename, 'utf-8');
|
|
72
|
+
// -c オプションが指定されたとき
|
|
73
|
+
if (opt.flagConvert) {
|
|
74
|
+
convert(nako, code, opt);
|
|
75
|
+
}
|
|
76
|
+
// 実行
|
|
77
|
+
nako.run(code, opt.filename);
|
|
78
|
+
}
|
|
79
|
+
// -c オプションを指定したとき
|
|
80
|
+
function convert(nako, code, opt) {
|
|
81
|
+
// オプションを指定
|
|
82
|
+
const genOpt = new NakoGenOptions(false, ['nako_errors.mjs', 'nako_core_version.mjs', 'plugin_system.mjs'], 'self.__varslist[0][\'ナデシコ種類\'] = \'snako\'');
|
|
83
|
+
// スタンドアロンコードを生成
|
|
84
|
+
const js = nako.compileStandalone(code, opt.filename, genOpt);
|
|
85
|
+
const jsFilename = opt.filename + '.js';
|
|
86
|
+
fs.writeFileSync(jsFilename, js, { encoding: 'utf-8' });
|
|
87
|
+
// 必要なライブラリをコピー
|
|
88
|
+
const runtimeDir = path.join(path.dirname(jsFilename), 'nako3runtime');
|
|
89
|
+
const srcDir = path.join(__dirname, '..', 'src');
|
|
90
|
+
if (!fs.existsSync(runtimeDir)) {
|
|
91
|
+
fs.mkdirSync(runtimeDir);
|
|
92
|
+
}
|
|
93
|
+
for (const f of genOpt.importFiles) {
|
|
94
|
+
fs.copyFileSync(path.join(srcDir, f), path.join(runtimeDir, f));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** 使い方を表示 */
|
|
98
|
+
function showHelp() {
|
|
99
|
+
console.log('●なでしこ(簡易版) # v.' + com.version.version);
|
|
100
|
+
console.log('[使い方] node snako.mjs [--debug|-d] (filename)');
|
|
101
|
+
console.log('[使い方] node snako.mjs [--eval|-e] (source)');
|
|
102
|
+
console.log('[使い方] node snako.mjs [-c] (source) ... convert');
|
|
103
|
+
}
|
|
104
|
+
/** メイン処理を実行 */
|
|
105
|
+
main(process.argv);
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
import com from '../index.mjs'
|
|
5
|
+
import { NakoGlobal } from '../src/nako_global.mjs'
|
|
6
|
+
|
|
7
|
+
import * as url from 'url'
|
|
8
|
+
import { NakoGenOptions } from '../src/nako_gen.mjs'
|
|
9
|
+
import { NakoCompiler } from '../src/nako3.mjs'
|
|
10
|
+
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
|
|
11
|
+
|
|
12
|
+
/** コマンドラインオプション */
|
|
13
|
+
class CommandOptions {
|
|
14
|
+
isDebug: boolean;
|
|
15
|
+
filename: string;
|
|
16
|
+
nodePath: string;
|
|
17
|
+
scriptPath: string;
|
|
18
|
+
evalStr: string;
|
|
19
|
+
flagConvert: boolean;
|
|
20
|
+
constructor () {
|
|
21
|
+
this.nodePath = ''
|
|
22
|
+
this.scriptPath = ''
|
|
23
|
+
this.filename = ''
|
|
24
|
+
this.evalStr = ''
|
|
25
|
+
this.isDebug = false
|
|
26
|
+
this.flagConvert = false
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** メイン処理 */
|
|
31
|
+
function main (argvOrg: string[]): void {
|
|
32
|
+
// コマンドラインオプションを確認
|
|
33
|
+
const argv: string[] = [...argvOrg]
|
|
34
|
+
const opt: CommandOptions = new CommandOptions()
|
|
35
|
+
opt.nodePath = argv.shift() || ''
|
|
36
|
+
opt.scriptPath = argv.shift() || ''
|
|
37
|
+
while (argv.length > 0) {
|
|
38
|
+
const arg = argv.shift() || ''
|
|
39
|
+
if (arg === '-d' || arg === '--debug') {
|
|
40
|
+
opt.isDebug = true
|
|
41
|
+
continue
|
|
42
|
+
}
|
|
43
|
+
if (arg === '-e' || arg === '--eval') {
|
|
44
|
+
opt.evalStr = argv.shift() || ''
|
|
45
|
+
continue
|
|
46
|
+
}
|
|
47
|
+
if (arg === '-c' || arg === '--convert') {
|
|
48
|
+
opt.flagConvert = true
|
|
49
|
+
continue
|
|
50
|
+
}
|
|
51
|
+
if (opt.filename === '') { opt.filename = arg }
|
|
52
|
+
}
|
|
53
|
+
// なでしこのコンパイラを生成
|
|
54
|
+
const nako = new com.NakoCompiler()
|
|
55
|
+
// 実行前にイベントを挟みたいとき
|
|
56
|
+
nako.addListener('beforeRun', (g: NakoGlobal) => {
|
|
57
|
+
g.__varslist[0]['ナデシコ種類'] = 'snako'
|
|
58
|
+
})
|
|
59
|
+
// logger を設定 --- リスナーを登録することでデバッグレベルを指定
|
|
60
|
+
const logger = nako.getLogger()
|
|
61
|
+
if (opt.isDebug) {
|
|
62
|
+
logger.addListener('trace', (data) => { // --debug オプションを指定したとき
|
|
63
|
+
console.log(data.nodeConsole)
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
logger.addListener('stdout', (data) => { // 「表示」命令を実行したとき
|
|
67
|
+
console.log(data.noColor)
|
|
68
|
+
})
|
|
69
|
+
// -e オプションを実行したとき
|
|
70
|
+
if (opt.evalStr) {
|
|
71
|
+
nako.run(opt.evalStr)
|
|
72
|
+
return
|
|
73
|
+
}
|
|
74
|
+
// パラメータが空だったとき
|
|
75
|
+
if (opt.filename === '') {
|
|
76
|
+
showHelp()
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
// ソースコードをファイルから読み込む
|
|
80
|
+
const code: string = fs.readFileSync(opt.filename, 'utf-8')
|
|
81
|
+
// -c オプションが指定されたとき
|
|
82
|
+
if (opt.flagConvert) { convert(nako, code, opt) }
|
|
83
|
+
// 実行
|
|
84
|
+
nako.run(code, opt.filename)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// -c オプションを指定したとき
|
|
88
|
+
function convert (nako: NakoCompiler, code: string, opt: CommandOptions): void {
|
|
89
|
+
// オプションを指定
|
|
90
|
+
const genOpt = new NakoGenOptions(
|
|
91
|
+
false,
|
|
92
|
+
['nako_errors.mjs', 'nako_core_version.mjs', 'plugin_system.mjs'],
|
|
93
|
+
'self.__varslist[0][\'ナデシコ種類\'] = \'snako\'')
|
|
94
|
+
// スタンドアロンコードを生成
|
|
95
|
+
const js = nako.compileStandalone(code, opt.filename, genOpt)
|
|
96
|
+
const jsFilename = opt.filename + '.js'
|
|
97
|
+
fs.writeFileSync(jsFilename, js, { encoding: 'utf-8' })
|
|
98
|
+
// 必要なライブラリをコピー
|
|
99
|
+
const runtimeDir = path.join(path.dirname(jsFilename), 'nako3runtime')
|
|
100
|
+
const srcDir = path.join(__dirname, '..', 'src')
|
|
101
|
+
if (!fs.existsSync(runtimeDir)) { fs.mkdirSync(runtimeDir) }
|
|
102
|
+
for (const f of genOpt.importFiles) {
|
|
103
|
+
fs.copyFileSync(path.join(srcDir, f), path.join(runtimeDir, f))
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** 使い方を表示 */
|
|
108
|
+
function showHelp (): void {
|
|
109
|
+
console.log('●なでしこ(簡易版) # v.' + com.version.version)
|
|
110
|
+
console.log('[使い方] node snako.mjs [--debug|-d] (filename)')
|
|
111
|
+
console.log('[使い方] node snako.mjs [--eval|-e] (source)')
|
|
112
|
+
console.log('[使い方] node snako.mjs [-c] (source) ... convert')
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** メイン処理を実行 */
|
|
116
|
+
main(process.argv)
|
package/core/index.mjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import version from './src/nako_core_version.mjs';
|
|
2
|
+
import { NakoCompiler } from './src/nako3.mjs';
|
|
3
|
+
import { NakoLogger } from './src/nako_logger.mjs';
|
|
4
|
+
import { NakoError, NakoRuntimeError, NakoImportError } from './src/nako_errors.mjs';
|
|
5
|
+
import { NakoParser } from './src/nako_parser3.mjs';
|
|
6
|
+
import { NakoPrepare } from './src/nako_prepare.mjs';
|
|
7
|
+
export default {
|
|
8
|
+
// version
|
|
9
|
+
version,
|
|
10
|
+
// compiler
|
|
11
|
+
NakoCompiler,
|
|
12
|
+
// loggger
|
|
13
|
+
NakoLogger,
|
|
14
|
+
// error
|
|
15
|
+
NakoError,
|
|
16
|
+
NakoRuntimeError,
|
|
17
|
+
NakoImportError,
|
|
18
|
+
// tools etc..
|
|
19
|
+
NakoParser,
|
|
20
|
+
NakoPrepare
|
|
21
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nadesiko3core",
|
|
3
|
+
"version": "3.3.50",
|
|
4
|
+
"description": "Japanese Programming Language Nadesiko v3 core",
|
|
5
|
+
"main": "index.mjs",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "mocha ./test",
|
|
9
|
+
"tsc": "tsc --watch",
|
|
10
|
+
"build": "cnako3 batch/build_nako_version.nako3 && tsc",
|
|
11
|
+
"eslint": "eslint ./src/*.mts",
|
|
12
|
+
"eslint:fix": "eslint ./src/*.mts --fix"
|
|
13
|
+
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"snako": "command/snako.mjs"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/kujirahand/nadesiko3core.git"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [],
|
|
22
|
+
"author": "kujirahand",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/kujirahand/nadesiko3core/issues"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/kujirahand/nadesiko3core#readme",
|
|
28
|
+
"files": [
|
|
29
|
+
"src",
|
|
30
|
+
"batch",
|
|
31
|
+
"command",
|
|
32
|
+
"sample"
|
|
33
|
+
],
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/mocha": "^9.1.1",
|
|
36
|
+
"@types/node": "^17.0.35",
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
38
|
+
"chai": "^4.3.6",
|
|
39
|
+
"eslint": "^7.32.0",
|
|
40
|
+
"eslint-config-standard-with-typescript": "^21.0.1",
|
|
41
|
+
"eslint-plugin-import": "^2.26.0",
|
|
42
|
+
"eslint-plugin-node": "^11.1.0",
|
|
43
|
+
"eslint-plugin-promise": "^5.2.0",
|
|
44
|
+
"mocha": "^10.0.0",
|
|
45
|
+
"typescript": "^4.6.4"
|
|
46
|
+
}
|
|
47
|
+
}
|