nadesiko3 3.3.48 → 3.3.49

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 (105) hide show
  1. package/core/.editorconfig +6 -0
  2. package/core/.eslintrc.cjs +33 -0
  3. package/core/.github/dependabot.yml +7 -0
  4. package/core/.github/workflows/nodejs.yml +37 -0
  5. package/core/.github/workflows/super-linter.yml +61 -0
  6. package/core/.github/workflows/textlint.yml +199 -0
  7. package/core/LICENSE +21 -0
  8. package/core/README.md +66 -0
  9. package/core/batch/build_nako_version.nako3 +42 -0
  10. package/core/command/snako.mjs +105 -0
  11. package/core/command/snako.mts +116 -0
  12. package/core/index.mjs +21 -0
  13. package/core/index.mts +21 -0
  14. package/core/package.json +47 -0
  15. package/core/sample/hello.nako3 +7 -0
  16. package/core/sample/hoge.mjs +4 -0
  17. package/core/sample/hoge.mts +6 -0
  18. package/core/src/nako3.mjs +858 -0
  19. package/core/src/nako3.mts +967 -0
  20. package/core/src/nako_colors.mjs +78 -0
  21. package/core/src/nako_colors.mts +86 -0
  22. package/core/src/nako_core_version.mjs +8 -0
  23. package/core/src/nako_core_version.mts +19 -0
  24. package/core/src/nako_csv.mjs +185 -0
  25. package/core/src/nako_csv.mts +188 -0
  26. package/core/src/nako_errors.mjs +173 -0
  27. package/core/src/nako_errors.mts +197 -0
  28. package/core/src/nako_from_dncl.mjs +255 -0
  29. package/core/src/nako_from_dncl.mts +250 -0
  30. package/core/src/nako_gen.mjs +1648 -0
  31. package/core/src/nako_gen.mts +1719 -0
  32. package/core/src/nako_gen_async.mjs +1659 -0
  33. package/core/src/nako_gen_async.mts +1732 -0
  34. package/core/src/nako_global.mjs +107 -0
  35. package/core/src/nako_global.mts +138 -0
  36. package/core/src/nako_indent.mjs +445 -0
  37. package/core/src/nako_indent.mts +492 -0
  38. package/core/src/nako_josi_list.mjs +38 -0
  39. package/core/src/nako_josi_list.mts +45 -0
  40. package/core/src/nako_lex_rules.mjs +253 -0
  41. package/core/src/nako_lex_rules.mts +260 -0
  42. package/core/src/nako_lexer.mjs +609 -0
  43. package/core/src/nako_lexer.mts +612 -0
  44. package/core/src/nako_logger.mjs +199 -0
  45. package/core/src/nako_logger.mts +232 -0
  46. package/core/src/nako_parser3.mjs +2439 -0
  47. package/core/src/nako_parser3.mts +2195 -0
  48. package/core/src/nako_parser_base.mjs +370 -0
  49. package/core/src/nako_parser_base.mts +370 -0
  50. package/core/src/nako_parser_const.mjs +37 -0
  51. package/core/src/nako_parser_const.mts +37 -0
  52. package/core/src/nako_prepare.mjs +304 -0
  53. package/core/src/nako_prepare.mts +315 -0
  54. package/core/src/nako_reserved_words.mjs +38 -0
  55. package/core/src/nako_reserved_words.mts +38 -0
  56. package/core/src/nako_source_mapping.mjs +207 -0
  57. package/core/src/nako_source_mapping.mts +262 -0
  58. package/core/src/nako_test.mjs +37 -0
  59. package/core/src/nako_types.mjs +25 -0
  60. package/core/src/nako_types.mts +151 -0
  61. package/core/src/plugin_csv.mjs +49 -0
  62. package/core/src/plugin_csv.mts +50 -0
  63. package/core/src/plugin_math.mjs +328 -0
  64. package/core/src/plugin_math.mts +326 -0
  65. package/core/src/plugin_promise.mjs +91 -0
  66. package/core/src/plugin_promise.mts +91 -0
  67. package/core/src/plugin_system.mjs +2832 -0
  68. package/core/src/plugin_system.mts +2690 -0
  69. package/core/src/plugin_test.mjs +34 -0
  70. package/core/src/plugin_test.mts +34 -0
  71. package/core/test/array_test.mjs +34 -0
  72. package/core/test/basic_test.mjs +344 -0
  73. package/core/test/calc_test.mjs +140 -0
  74. package/core/test/core_module_test.mjs +23 -0
  75. package/core/test/debug_test.mjs +16 -0
  76. package/core/test/dncl_test.mjs +94 -0
  77. package/core/test/error_message_test.mjs +210 -0
  78. package/core/test/error_test.mjs +16 -0
  79. package/core/test/flow_test.mjs +373 -0
  80. package/core/test/func_call.mjs +160 -0
  81. package/core/test/func_test.mjs +149 -0
  82. package/core/test/indent_test.mjs +364 -0
  83. package/core/test/lex_test.mjs +168 -0
  84. package/core/test/literal_test.mjs +73 -0
  85. package/core/test/nako_lexer_test.mjs +35 -0
  86. package/core/test/nako_logger_test.mjs +76 -0
  87. package/core/test/nako_logger_test.mts +78 -0
  88. package/core/test/plugin_csv_test.mjs +38 -0
  89. package/core/test/plugin_promise_test.mjs +18 -0
  90. package/core/test/plugin_system_test.mjs +630 -0
  91. package/core/test/prepare_test.mjs +96 -0
  92. package/core/test/re_test.mjs +22 -0
  93. package/core/test/side_effects_test.mjs +92 -0
  94. package/core/test/variable_scope_test.mjs +149 -0
  95. package/core/tsconfig.json +101 -0
  96. package/package.json +4 -2
  97. package/release/_hash.txt +12 -12
  98. package/release/_script-tags.txt +14 -14
  99. package/release/editor.js +1 -1
  100. package/release/stats.json +1 -1
  101. package/release/version.js +1 -1
  102. package/release/wnako3.js +1 -1
  103. package/src/nako_version.mjs +2 -2
  104. package/src/nako_version.mts +2 -2
  105. package/test/async/async_basic_test.mjs +3 -3
@@ -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
+ };
package/core/index.mts 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.47",
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
+ }
@@ -0,0 +1,7 @@
1
+ 「こんにちは」と表示。
2
+ 1 + 2 × 3を表示。
3
+ 2に3を掛けて、1を足して表示。
4
+ 「{今日} {今}」を表示。
5
+ ナデシコ種類を表示。
6
+ ナデシコバージョンを表示。
7
+
@@ -0,0 +1,4 @@
1
+ import core from '../index.mjs';
2
+ const com = new core.NakoCompiler();
3
+ const g = com.run('1 + 2 * 3を表示');
4
+ console.log(g.log);
@@ -0,0 +1,6 @@
1
+ import core from '../index.mjs'
2
+ const com = new core.NakoCompiler()
3
+ const g = com.run('1 + 2 * 3を表示')
4
+ console.log(g.log)
5
+
6
+