nadesiko3 3.2.52 → 3.3.3

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 (178) hide show
  1. package/README.md +1 -1
  2. package/bin/cnako3 +1 -1
  3. package/bin/cnako3.bat +1 -1
  4. package/demo/browsers.html +9 -10
  5. package/demo/flow.html +1 -0
  6. package/demo/runscript3.html +35 -0
  7. package/demo/turtle3.html +18 -17
  8. package/demo/turtle3d.html +1 -1
  9. package/demo/turtle3d2.html +1 -1
  10. package/doc/browsers.md +9 -10
  11. package/package.json +58 -57
  12. package/release/_hash.txt +57 -52
  13. package/release/_script-tags.txt +14 -13
  14. package/release/command.json +1 -1
  15. package/release/command.json.js +1 -1
  16. package/release/command_cnako3.json +1 -1
  17. package/release/command_list.json +1 -1
  18. package/release/editor.js +1 -1
  19. package/release/editor.js.LICENSE.txt +9 -12
  20. package/release/nako_gen_async.js +1 -1
  21. package/release/nako_gen_async.js.LICENSE.txt +10 -666
  22. package/release/plugin_caniuse.js +1 -1
  23. package/release/plugin_caniuse.js.LICENSE.txt +9 -425
  24. package/release/plugin_csv.js +1 -1
  25. package/release/plugin_csv.js.LICENSE.txt +3 -419
  26. package/release/plugin_datetime.js +1 -1
  27. package/release/plugin_datetime.js.LICENSE.txt +6 -530
  28. package/release/plugin_kansuji.js +1 -1
  29. package/release/plugin_kansuji.js.LICENSE.txt +3 -559
  30. package/release/plugin_markup.js +1 -1
  31. package/release/plugin_markup.js.LICENSE.txt +4 -420
  32. package/release/plugin_turtle.js +1 -1
  33. package/release/plugin_turtle.js.LICENSE.txt +12 -500
  34. package/release/plugin_webworker.js +1 -1
  35. package/release/plugin_webworker.js.LICENSE.txt +3 -563
  36. package/release/plugin_weykturtle3d.js +1 -0
  37. package/release/plugin_weykturtle3d.js.LICENSE.txt +3 -0
  38. package/release/stats.json +1 -1
  39. package/release/version.js +1 -1
  40. package/release/version.js.LICENSE.txt +9 -12
  41. package/release/wnako3.js +1 -1
  42. package/release/wnako3.js.LICENSE.txt +1 -1
  43. package/release/wnako3webworker.js +1 -1
  44. package/release/wnako3webworker.js.LICENSE.txt +1 -1117
  45. package/src/browsers.mjs +1 -0
  46. package/src/browsers.txt +15 -15
  47. package/src/browsers_agents.mjs +1 -0
  48. package/src/cnako3.mjs +13 -0
  49. package/src/{cnako3.js → cnako3mod.mjs} +119 -101
  50. package/src/{commander_ja.js → commander_ja.mjs} +16 -11
  51. package/src/{enako3.js → enako3.mjs} +0 -0
  52. package/src/{era.json → era.mjs} +1 -1
  53. package/src/image_turtle-elephant.mjs +5 -0
  54. package/src/image_turtle-panda.mjs +5 -0
  55. package/src/image_turtle64.mjs +5 -0
  56. package/src/index.mjs +9 -0
  57. package/src/{nako3.js → nako3.mjs} +69 -57
  58. package/src/{nako3_assert.js → nako3_assert.mjs} +7 -6
  59. package/src/{nako3server.js → nako3server.mjs} +12 -5
  60. package/src/{nako_colors.js → nako_colors.mjs} +1 -1
  61. package/src/{nako_errors.js → nako_errors.mjs} +10 -20
  62. package/src/{nako_from_dncl.js → nako_from_dncl.mjs} +11 -8
  63. package/src/{nako_gen.js → nako_gen.mjs} +93 -87
  64. package/src/{nako_gen_async.js → nako_gen_async.mjs} +5 -8
  65. package/src/{nako_global.js → nako_global.mjs} +4 -5
  66. package/src/{nako_indent.js → nako_indent.mjs} +29 -25
  67. package/src/{nako_josi_list.js → nako_josi_list.mjs} +16 -14
  68. package/src/nako_lex_rules.mjs +244 -0
  69. package/src/{nako_lexer.js → nako_lexer.mjs} +7 -10
  70. package/src/{nako_logger.js → nako_logger.mjs} +3 -4
  71. package/src/{nako_parser3.js → nako_parser3.mjs} +5 -5
  72. package/src/{nako_parser_base.js → nako_parser_base.mjs} +1 -9
  73. package/src/{nako_parser_const.js → nako_parser_const.mjs} +2 -6
  74. package/src/{nako_prepare.js → nako_prepare.mjs} +46 -8
  75. package/src/{nako_reserved_words.js → nako_reserved_words.mjs} +1 -1
  76. package/src/{nako_source_mapping.js → nako_source_mapping.mjs} +4 -11
  77. package/src/{nako_test.js → nako_test.mjs} +0 -0
  78. package/src/nako_version.mjs +7 -0
  79. package/src/{plugin_browser.js → plugin_browser.mjs} +30 -30
  80. package/src/{plugin_browser_ajax.js → plugin_browser_ajax.mjs} +7 -7
  81. package/src/{plugin_browser_audio.js → plugin_browser_audio.mjs} +1 -1
  82. package/src/{plugin_browser_canvas.js → plugin_browser_canvas.mjs} +1 -1
  83. package/src/{plugin_browser_chart.js → plugin_browser_chart.mjs} +1 -1
  84. package/src/{plugin_browser_color.js → plugin_browser_color.mjs} +1 -1
  85. package/src/{plugin_browser_crypto.js → plugin_browser_crypto.mjs} +1 -1
  86. package/src/{plugin_browser_dialog.js → plugin_browser_dialog.mjs} +1 -1
  87. package/src/{plugin_browser_dom_basic.js → plugin_browser_dom_basic.mjs} +1 -1
  88. package/src/{plugin_browser_dom_event.js → plugin_browser_dom_event.mjs} +1 -1
  89. package/src/{plugin_browser_dom_parts.js → plugin_browser_dom_parts.mjs} +1 -1
  90. package/src/{plugin_browser_geolocation.js → plugin_browser_geolocation.mjs} +1 -1
  91. package/src/{plugin_browser_hotkey.js → plugin_browser_hotkey.mjs} +2 -2
  92. package/src/{plugin_browser_html.js → plugin_browser_html.mjs} +1 -1
  93. package/src/{plugin_browser_in_worker.js → plugin_browser_in_worker.mjs} +4 -4
  94. package/src/{plugin_browser_location.js → plugin_browser_location.mjs} +1 -1
  95. package/src/{plugin_browser_speech.js → plugin_browser_speech.mjs} +1 -1
  96. package/src/{plugin_browser_storage.js → plugin_browser_storage.mjs} +1 -1
  97. package/src/{plugin_browser_system.js → plugin_browser_system.mjs} +1 -1
  98. package/src/{plugin_browser_websocket.js → plugin_browser_websocket.mjs} +1 -1
  99. package/src/{plugin_caniuse.js → plugin_caniuse.mjs} +8 -3
  100. package/src/{plugin_csv.js → plugin_csv.mjs} +4 -5
  101. package/src/{plugin_datetime.js → plugin_datetime.mjs} +19 -26
  102. package/src/{plugin_express.js → plugin_express.mjs} +4 -3
  103. package/src/{plugin_kansuji.js → plugin_kansuji.mjs} +1 -1
  104. package/src/{plugin_keigo.js → plugin_keigo.mjs} +1 -1
  105. package/src/{plugin_markup.js → plugin_markup.mjs} +6 -6
  106. package/src/{plugin_math.js → plugin_math.mjs} +1 -4
  107. package/src/{plugin_node.js → plugin_node.mjs} +25 -57
  108. package/src/{plugin_promise.js → plugin_promise.mjs} +1 -3
  109. package/src/{plugin_system.js → plugin_system.mjs} +32 -15
  110. package/src/{plugin_test.js → plugin_test.mjs} +1 -3
  111. package/src/{plugin_turtle.js → plugin_turtle.mjs} +5 -4
  112. package/src/{plugin_webworker.js → plugin_webworker.mjs} +3 -3
  113. package/src/{plugin_weykturtle3d.js → plugin_weykturtle3d.mjs} +1 -3
  114. package/src/{plugin_worker.js → plugin_worker.mjs} +4 -1
  115. package/src/{wnako3.js → wnako3.mjs} +24 -14
  116. package/src/{wnako3_editor.js → wnako3_editor.mjs} +28 -22
  117. package/src/{wnako3webworker.js → wnako3webworker.mjs} +0 -0
  118. package/test/async/{async_basic_test.js → async_basic_test.mjs} +3 -4
  119. package/test/browser/karma.config.js +9 -0
  120. package/test/browser/test/plugin_browser_test.js +2 -2
  121. package/test/browser/test/plugin_turtle_test.js +2 -2
  122. package/test/browser/test/plugin_webworker_test.js +3 -3
  123. package/test/browser/test/require_test.js +2 -2
  124. package/test/common/{array_test.js → array_test.mjs} +3 -3
  125. package/test/common/{basic_test.js → basic_test.mjs} +3 -13
  126. package/test/common/{calc_test.js → calc_test.mjs} +2 -2
  127. package/test/common/{debug_test.js → debug_test.mjs} +2 -2
  128. package/test/common/{dncl_test.js → dncl_test.mjs} +3 -3
  129. package/test/common/{error_test.js → error_test.mjs} +2 -2
  130. package/test/common/{flow_test.js → flow_test.mjs} +2 -2
  131. package/test/common/{func_call.js → func_call.mjs} +3 -3
  132. package/test/common/{func_test.js → func_test.mjs} +2 -2
  133. package/test/common/{indent_test.js → indent_test.mjs} +3 -2
  134. package/test/common/{lex_test.js → lex_test.mjs} +2 -2
  135. package/test/common/{literal_test.js → literal_test.mjs} +3 -2
  136. package/test/common/{nako_logger_test.js → nako_logger_test.mjs} +3 -3
  137. package/test/common/{plugin_browser_test.js → plugin_browser_test.mjs} +4 -4
  138. package/test/common/{plugin_browser_ut_audio_test.js → plugin_browser_ut_audio_test.mjs} +4 -4
  139. package/test/common/{plugin_browser_ut_color_test.js → plugin_browser_ut_color_test.mjs} +2 -2
  140. package/test/common/{plugin_browser_ut_dialog_test.js → plugin_browser_ut_dialog_test.mjs} +3 -3
  141. package/test/common/{plugin_browser_ut_html_test.js → plugin_browser_ut_html_test.mjs} +2 -2
  142. package/test/common/{plugin_browser_ut_system_test.js → plugin_browser_ut_system_test.mjs} +2 -2
  143. package/test/common/{plugin_csv_test.js → plugin_csv_test.mjs} +3 -3
  144. package/test/common/{plugin_datetime_test.js → plugin_datetime_test.mjs} +4 -4
  145. package/test/common/{plugin_kansuji_test.js → plugin_kansuji_test.mjs} +3 -3
  146. package/test/common/{plugin_markup_test.js → plugin_markup_test.mjs} +3 -3
  147. package/test/common/{plugin_promise_test.js → plugin_promise_test.mjs} +2 -2
  148. package/test/common/{plugin_system_test.js → plugin_system_test.mjs} +2 -2
  149. package/test/common/{prepare_test.js → prepare_test.mjs} +2 -2
  150. package/test/common/{re_test.js → re_test.mjs} +2 -2
  151. package/test/common/{variable_scope_test.js → variable_scope_test.mjs} +2 -2
  152. package/test/karma.config.js +3 -3
  153. package/test/node/{async_test.js → async_test.mjs} +4 -2
  154. package/test/node/{commander_ja_test.js → commander_ja_test.mjs} +17 -12
  155. package/test/node/{error_message_test.js → error_message_test.mjs} +13 -10
  156. package/test/node/node_test.mjs +57 -0
  157. package/test/node/{plugin_browser_ut_ajax_test.js → plugin_browser_ut_ajax_test.mjs} +7 -5
  158. package/test/node/{plugin_browser_ut_location_test.js → plugin_browser_ut_location_test.mjs} +3 -3
  159. package/test/node/{plugin_markup_test.js → plugin_markup_test.mjs} +6 -7
  160. package/test/node/{plugin_math_test.js → plugin_math_test.mjs} +5 -5
  161. package/test/node/{plugin_node_test.js → plugin_node_test.mjs} +11 -7
  162. package/test/node/{plugin_test.js → plugin_test.mjs} +11 -5
  163. package/test/node/{require_nako3_test.js → require_nako3_test.mjs} +19 -12
  164. package/test/node/{side_effects_test.js → side_effects_test.mjs} +24 -13
  165. package/test/node/{wnako3_editor_test.js → wnako3_editor_test.mjs} +16 -9
  166. package/tools/nako3edit/html/daisyui/LICENSE +22 -0
  167. package/tools/nako3edit/html/daisyui/full.css +1 -0
  168. package/tools/nako3edit/html/daisyui/tailwind.min.css +1 -0
  169. package/tools/nako3edit/html/daisyui/version_2.14.1 +1 -0
  170. package/tools/nako3edit/html/edit.html +104 -19
  171. package/tools/nako3edit/html/files.html +84 -8
  172. package/tools/nako3edit/html/nako3edit.css +6 -7
  173. package/tools/nako3edit/index.nako3 +45 -6
  174. package/tools/nako3edit/{run.js → run.mjs} +8 -2
  175. package/src/index.js +0 -5
  176. package/src/nako_lex_rules.js +0 -260
  177. package/src/nako_version.js +0 -8
  178. package/test/node/node_test.js +0 -43
@@ -1,260 +0,0 @@
1
- /**
2
- * なでしこ3字句解析のためのルール
3
- */
4
-
5
- const kanakanji = /^[\u3005\u4E00-\u9FCF_a-zA-Z0-9ァ-ヶー\u2460-\u24FF\u2776-\u277F\u3251-\u32BF]+/
6
- const nakoJosiList = require('./nako_josi_list')
7
- const josiRE = nakoJosiList.josiRE
8
- const removeJosiMap = nakoJosiList.removeJosiMap
9
- const hira = /^[ぁ-ん]/
10
- const allHiragana = /^[ぁ-ん]+$/
11
- const wordHasIjoIka = /^.+(以上|以下|超|未満)$/
12
- const unitRE = /^(円|ドル|元|歩|㎡|坪|度|℃|°|個|つ|本|冊|才|歳|匹|枚|皿|セット|羽|人|件|行|列|機|品|m|mm|cm|km|g|kg|t|px|dot|pt|em|b|mb|kb|gb)/
13
-
14
- const errorRead = (ch) => {
15
- return function () { throw new Error('突然の『' + ch + '』があります。') }
16
- }
17
-
18
- module.exports = {
19
- rules: [
20
- // 上から順にマッチさせていく
21
- { name: 'ここまで', pattern: /^;;;/ }, // #925
22
- { name: 'eol', pattern: /^\n/ },
23
- { name: 'eol', pattern: /^;/ },
24
- // eslint-disable-next-line no-control-regex
25
- { name: 'space', pattern: /^(\x20|\x09|・)+/ }, // #877,#1015
26
- { name: 'comma', pattern: /^,/ },
27
- { name: 'line_comment', pattern: /^#[^\n]*/ },
28
- { name: 'line_comment', pattern: /^\/\/[^\n]*/ },
29
- { name: 'range_comment', pattern: /^\/\*/, cbParser: cbRangeComment },
30
- { name: 'def_test', pattern: /^●テスト:/ },
31
- { name: 'def_func', pattern: /^●/ },
32
- // 数値の判定 --- この後nako_lexerにて単位を読む処理が入る(#994)
33
- { name: 'number', pattern: /^0[xX][0-9a-fA-F]+(_[0-9a-fA-F]+)*/, readJosi: true, cb: parseNumber },
34
- { name: 'number', pattern: /^0[oO][0-7]+(_[0-7]+)*/, readJosi: true, cb: parseNumber },
35
- { name: 'number', pattern: /^0[bB][0-1]+(_[0-1]+)*/, readJosi: true, cb: parseNumber },
36
- // 下の三つは小数点が挟まっている場合、小数点から始まっている場合、小数点がない場合の十進法の数値にマッチします
37
- { name: 'number', pattern: /^\d+(_\d+)*\.(\d+(_\d+)*)?([eE][+|-]?\d+(_\d+)*)?/, readJosi: true, cb: parseNumber },
38
- { name: 'number', pattern: /^\.\d+(_\d+)*([eE][+|-]?\d+(_\d+)*)?/, readJosi: true, cb: parseNumber },
39
- { name: 'number', pattern: /^\d+(_\d+)*([eE][+|-]?\d+(_\d+)*)?/, readJosi: true, cb: parseNumber },
40
- { name: 'ここから', pattern: /^(ここから),?/ },
41
- { name: 'ここまで', pattern: /^(ここまで|💧)/ },
42
- { name: 'もし', pattern: /^もしも?/ },
43
- // 「ならば」は助詞として定義している
44
- { name: '違えば', pattern: /^違(えば)?/ },
45
- // 「回」「間」「繰返」「反復」「抜」「続」「戻」「代入」「条件分岐」などは replaceWord で word から変換
46
- // @see nako_reserved_words.js
47
- { name: 'shift_r0', pattern: /^>>>/ },
48
- { name: 'shift_r', pattern: /^>>/ },
49
- { name: 'shift_l', pattern: /^<</ },
50
- { name: '===', pattern: /^===/ }, // #999
51
- { name: '!==', pattern: /^!==/ }, // #999
52
- { name: 'gteq', pattern: /^(≧|>=|=>)/ },
53
- { name: 'lteq', pattern: /^(≦|<=|=<)/ },
54
- { name: 'noteq', pattern: /^(≠|<>|!=)/ },
55
- { name: '←', pattern: /^(←|<--)/ }, // 関数呼び出し演算子 #891 #899
56
- { name: 'eq', pattern: /^(=|🟰)/ },
57
- { name: 'line_comment', pattern: /^(!|💡)(インデント構文|ここまでだるい)[^\n]*/ }, // #1184
58
- { name: 'not', pattern: /^(!|💡)/ }, // #1184
59
- { name: 'gt', pattern: /^>/ },
60
- { name: 'lt', pattern: /^</ },
61
- { name: 'and', pattern: /^(かつ|&&)/ },
62
- { name: 'or', pattern: /^(または|或いは|あるいは|\|\|)/ },
63
- { name: '@', pattern: /^@/ },
64
- { name: '+', pattern: /^\+/ },
65
- { name: '-', pattern: /^-/ },
66
- { name: '*', pattern: /^(×|\*)/ },
67
- { name: '÷÷', pattern: /^÷÷/ }, // 整数の割り算
68
- { name: '÷', pattern: /^(÷|\/)/ }, // 普通の割り算
69
- { name: '%', pattern: /^%/ },
70
- { name: '^', pattern: /^\^/ },
71
- { name: '&', pattern: /^&/ },
72
- { name: '[', pattern: /^\[/ },
73
- { name: ']', pattern: /^]/, readJosi: true },
74
- { name: '(', pattern: /^\(/ },
75
- { name: ')', pattern: /^\)/, readJosi: true },
76
- { name: '|', pattern: /^\|/ },
77
- { name: 'string', pattern: /^🌿/, cbParser: src => cbString('🌿', '🌿', src) },
78
- { name: 'string_ex', pattern: /^🌴/, cbParser: src => cbString('🌴', '🌴', src) },
79
- { name: 'string_ex', pattern: /^「/, cbParser: src => cbString('「', '」', src) },
80
- { name: 'string', pattern: /^『/, cbParser: src => cbString('『', '』', src) },
81
- { name: 'string_ex', pattern: /^“/, cbParser: src => cbString('“', '”', src) },
82
- { name: 'string_ex', pattern: /^"/, cbParser: src => cbString('"', '"', src) },
83
- { name: 'string', pattern: /^'/, cbParser: src => cbString('\'', '\'', src) },
84
- { name: '」', pattern: /^」/, cbParser: errorRead('」') }, // error
85
- { name: '』', pattern: /^』/, cbParser: errorRead('』') }, // error
86
- { name: 'func', pattern: /^\{関数\},?/ },
87
- { name: '{', pattern: /^\{/ },
88
- { name: '}', pattern: /^\}/, readJosi: true },
89
- { name: ':', pattern: /^:/ },
90
- { name: '_eol', pattern: /^_\s*\n/ },
91
- { name: 'dec_lineno', pattern: /^‰/ },
92
- // 絵文字変数 = (絵文字)英数字*
93
- { name: 'word', pattern: /^[\uD800-\uDBFF][\uDC00-\uDFFF][_a-zA-Z0-9]*/, readJosi: true },
94
- { name: 'word', pattern: /^[\u1F60-\u1F6F][_a-zA-Z0-9]*/, readJosi: true }, // 絵文字
95
- { name: 'word', pattern: /^《.+?》/, readJosi: true }, // 《特別名前トークン》(#672)
96
- // 単語句
97
- {
98
- name: 'word',
99
- pattern: /^[_a-zA-Z\u3005\u4E00-\u9FCFぁ-んァ-ヶ\u2460-\u24FF\u2776-\u277F\u3251-\u32BF]/,
100
- cbParser: cbWordParser
101
- }
102
- ],
103
- trimOkurigana,
104
- unitRE
105
- }
106
-
107
- // eslint-disable-next-line no-unused-vars
108
- function parseInt2 (s) {
109
- const ss = s.substring(2)
110
- return parseInt(ss, 2)
111
- }
112
- // eslint-disable-next-line no-unused-vars
113
- function parseInt8 (s) {
114
- const ss = s.substring(2)
115
- return parseInt(ss, 8)
116
- }
117
-
118
- function cbRangeComment (src) {
119
- let res = ''
120
- const josi = ''
121
- let numEOL = 0
122
- src = src.substr(2) // skip /*
123
- const i = src.indexOf('*/')
124
- if (i < 0) { // not found
125
- res = src
126
- src = ''
127
- } else {
128
- res = src.substr(0, i)
129
- src = src.substr(i + 2)
130
- }
131
- // 改行を数える
132
- for (let i = 0; i < res.length; i++) { if (res.charAt(i) === '\n') { numEOL++ } }
133
-
134
- res = res.replace(/(^\s+|\s+$)/, '') // trim
135
- return { src: src, res: res, josi: josi, numEOL: numEOL }
136
- }
137
-
138
- /**
139
- * @param {string} src
140
- */
141
- function cbWordParser (src, isTrimOkurigana = true) {
142
- /*
143
- kanji = [\u3005\u4E00-\u9FCF]
144
- hiragana = [ぁ-ん]
145
- katakana = [ァ-ヶー]
146
- emoji = [\u1F60-\u1F6F]
147
- uni_extra = [\uD800-\uDBFF] [\uDC00-\uDFFF]
148
- alphabet = [_a-zA-Z]
149
- numchars = [0-9]
150
- */
151
- let res = ''
152
- let josi = ''
153
- while (src !== '') {
154
- if (res.length > 0) {
155
- // 助詞の判定
156
- const j = josiRE.exec(src)
157
- if (j) {
158
- josi = j[0].replace(/^\s+/, '')
159
- src = src.substr(j[0].length)
160
- // 助詞の直後にある「,」を飛ばす #877
161
- if (src.charAt(0) === ',') { src = src.substr(1) }
162
- break
163
- }
164
- }
165
- // カタカナ漢字英数字か?
166
- const m = kanakanji.exec(src)
167
- if (m) {
168
- res += m[0]
169
- src = src.substr(m[0].length)
170
- continue
171
- }
172
- // ひらがな?
173
- const h = hira.test(src)
174
- if (h) {
175
- res += src.charAt(0)
176
- src = src.substr(1)
177
- continue
178
- }
179
- break // other chars
180
- }
181
- // 「間」の特殊ルール (#831)
182
- // 「等しい間」や「一致する間」なら「間」をsrcに戻す。ただし「システム時間」はそのままにする。
183
- if (/[ぁ-ん]間$/.test(res)) {
184
- src = res.charAt(res.length - 1) + src
185
- res = res.slice(0, -1)
186
- }
187
- // 「以上」「以下」「超」「未満」 #918
188
- const ii = wordHasIjoIka.exec(res)
189
- if (ii) {
190
- src = ii[1] + josi + src
191
- josi = ''
192
- res = res.substr(0, res.length - ii[1].length)
193
- }
194
- // 助詞「こと」「である」「です」などは「**すること」のように使うので削除 #936 #939 #974
195
- if (removeJosiMap[josi]) { josi = '' }
196
-
197
- // 漢字カタカナ英語から始まる語句 --- 送り仮名を省略
198
- if (isTrimOkurigana) {
199
- res = trimOkurigana(res)
200
- }
201
- // 助詞だけの語句の場合
202
- if (res === '' && josi !== '') {
203
- res = josi
204
- josi = ''
205
- }
206
- return { src: src, res: res, josi: josi, numEOL: 0 }
207
- }
208
-
209
- function cbString (beginTag, closeTag, src) {
210
- let res = ''
211
- let josi = ''
212
- let numEOL = 0
213
- src = src.substr(beginTag.length) // skip beginTag
214
- const i = src.indexOf(closeTag)
215
- if (i < 0) { // not found
216
- res = src
217
- src = ''
218
- } else {
219
- res = src.substr(0, i)
220
- src = src.substr(i + closeTag.length)
221
- // res の中に beginTag があればエラーにする #953
222
- if (res.indexOf(beginTag) >= 0) {
223
- if (beginTag === '『') {
224
- throw new Error('「『」で始めた文字列の中に「『」を含めることはできません。')
225
- } else {
226
- throw new Error(`『${beginTag}』で始めた文字列の中に『${beginTag}』を含めることはできません。`)
227
- }
228
- }
229
- }
230
- // 文字列直後の助詞を取得
231
- const j = josiRE.exec(src)
232
- if (j) {
233
- josi = j[0].replace(/^\s+/, '')
234
- src = src.substr(j[0].length)
235
- // 助詞の後のカンマ #877
236
- if (src.charAt(0) === ',') { src = src.substr(1) }
237
- }
238
- // 助詞「こと」「である」「です」などは「**すること」のように使うので削除 #936 #939 #974
239
- if (removeJosiMap[josi]) { josi = '' }
240
-
241
- // 改行を数える
242
- for (let i = 0; i < res.length; i++) { if (res.charAt(i) === '\n') { numEOL++ } }
243
-
244
- return { src: src, res: res, josi: josi, numEOL: numEOL }
245
- }
246
-
247
- function trimOkurigana (s) {
248
- // ひらがなから始まらない場合、送り仮名を削除。(例)置換する
249
- if (!hira.test(s)) {
250
- return s.replace(/[ぁ-ん]+/g, '')
251
- }
252
- // 全てひらがな? (例) どうぞ
253
- if (allHiragana.test(s)) { return s }
254
- // 末尾のひらがなのみ (例)お願いします →お願
255
- return s.replace(/[ぁ-ん]+$/g, '')
256
- }
257
-
258
- function parseNumber (n) {
259
- return Number(n.replace(/_/g, ''))
260
- }
@@ -1,8 +0,0 @@
1
- // なでしこバージョン
2
- const nakoVersion = {
3
- version: '3.2.52',
4
- major: 3,
5
- minor: 2,
6
- patch: 52
7
- }
8
- module.exports = nakoVersion
@@ -1,43 +0,0 @@
1
- const assert = require('assert')
2
- const child_process = require('child_process')
3
- const path = require('path')
4
- const fs = require ('fs')
5
-
6
- const cnako3 = path.join(__dirname, '../../src/cnako3.js')
7
- const packagejson = require('../../package.json')
8
- const debug = false
9
-
10
- describe('node_test(cnako)', () => {
11
- const cmp = (code, exRes) => {
12
- const result = child_process.execSync(`node ${cnako3} -e "${code}"`).toString().replace(/\s+$/, '')
13
- if (debug) {
14
- console.log('code=' + code)
15
- console.log('result=' + result)
16
- }
17
- assert.strictEqual(result, exRes)
18
- }
19
- // --- バージョンチェック ---
20
- it('ナデシコバージョン:src/plugin_system.jsを正しく設定しているか?', () => {
21
- cmp('ナデシコバージョンを表示', packagejson.version)
22
- cmp('ナデシコ種類を表示', 'cnako3')
23
- })
24
- // --- test ---
25
- it('print simple', () => {
26
- cmp('3を表示', '3')
27
- cmp('1+2*3を表示', '7')
28
- cmp('A=30;「--{A}--」を表示', '--30--')
29
- }).timeout(15000)
30
-
31
- it('単独で実行できるプログラムの出力 - Node.js', function () {
32
- if (process.env.NODE_ENV === 'test') {return this.skip()}
33
- const stderr = child_process.spawnSync('node', [cnako3, '-c', path.join(__dirname, 'add_test.nako3')]).stderr
34
- try {
35
- if (stderr) { console.error(stderr.toString()) }
36
- const p = child_process.spawnSync('node', [path.join(__dirname, 'add_test.js')])
37
- if (p.stderr) { console.error(p.stderr.toString()) }
38
- assert.strictEqual(p.stdout.toString(), '3\n')
39
- } finally {
40
- fs.unlinkSync(path.join(__dirname, 'add_test.js'))
41
- }
42
- })
43
- })