nadesiko3 3.7.21 → 3.7.22

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 (155) hide show
  1. package/batch/command.txt +370 -334
  2. package/batch/jsplugin2text.nako3 +1 -1
  3. package/batch/pickup_command.nako3 +12 -0
  4. package/core/command/snako.mts +5 -1
  5. package/core/deno/snako.ts +5 -1
  6. package/core/package-lock.json +382 -21
  7. package/core/package.json +4 -4
  8. package/core/src/nako3.mts +178 -614
  9. package/core/src/nako_basic_plugins.mts +39 -0
  10. package/core/src/nako_core_version.mts +2 -2
  11. package/core/src/nako_csv.mts +0 -1
  12. package/core/src/nako_event.mts +49 -0
  13. package/core/src/nako_gen.mts +291 -202
  14. package/core/src/nako_indent_inline.mts +2 -2
  15. package/core/src/nako_lex_rules.mts +1 -1
  16. package/core/src/nako_parser3.mts +106 -165
  17. package/core/src/nako_parser_async.mts +97 -0
  18. package/core/src/nako_parser_base.mts +4 -55
  19. package/core/src/nako_parser_message.mts +105 -0
  20. package/core/src/nako_parser_operator.mts +93 -0
  21. package/core/src/nako_plugin_manager.mts +260 -0
  22. package/core/src/nako_require.mts +292 -0
  23. package/core/src/nako_runner.mts +191 -0
  24. package/core/src/nako_tokenizer.mts +221 -0
  25. package/core/src/plugin_csv.mts +1 -1
  26. package/core/src/plugin_system.mts +34 -3259
  27. package/core/src/plugin_system_array.mts +699 -0
  28. package/core/src/plugin_system_datetime.mts +368 -0
  29. package/core/src/plugin_system_debug.mts +403 -0
  30. package/core/src/plugin_system_dict.mts +85 -0
  31. package/core/src/plugin_system_json.mts +73 -0
  32. package/core/src/plugin_system_math.mts +383 -0
  33. package/core/src/plugin_system_regexp.mts +120 -0
  34. package/core/src/plugin_system_stdio.mts +86 -0
  35. package/core/src/plugin_system_string.mts +666 -0
  36. package/core/src/plugin_system_timer.mts +152 -0
  37. package/core/src/plugin_system_types.mts +151 -0
  38. package/core/src/plugin_system_url.mts +193 -0
  39. package/core/src/plugin_toml.mts +3 -3
  40. package/core/test/fixtures/README.md +39 -0
  41. package/core/test/fixtures/make_parser_ast_golden.mjs +31 -0
  42. package/core/test/fixtures/parser_ast_golden.json +8027 -0
  43. package/core/test/fixtures/parser_corpus.mjs +120 -0
  44. package/core/test/indent_test.mjs +6 -0
  45. package/core/test/nako_basic_plugins_test.mjs +44 -0
  46. package/core/test/nako_event_test.mjs +85 -0
  47. package/core/test/nako_gen_perf_test.mjs +178 -0
  48. package/core/test/nako_parser_async_test.mjs +112 -0
  49. package/core/test/nako_parser_test.mjs +160 -0
  50. package/core/test/nako_plugin_manager_test.mjs +185 -0
  51. package/core/test/nako_require_test.mjs +153 -0
  52. package/core/test/nako_runner_test.mjs +114 -0
  53. package/core/test/nako_tokenizer_test.mjs +115 -0
  54. package/core/test/plugin_system_debug_test.mjs +141 -0
  55. package/core/test/plugin_system_split_test.mjs +179 -0
  56. package/core/test/plugin_system_test.mjs +6 -0
  57. package/core/tsconfig.json +0 -1
  58. package/package.json +17 -21
  59. package/release/_hash.txt +36 -36
  60. package/release/_script-tags.txt +16 -16
  61. package/release/command.json +1 -1
  62. package/release/command.json.js +1 -1
  63. package/release/command_cnako3.json +1 -1
  64. package/release/command_list.json +1 -1
  65. package/release/edit_main.js +6 -6
  66. package/release/edit_main.js.map +3 -3
  67. package/release/editor.js +6 -6
  68. package/release/plugin_keigo.js.map +3 -3
  69. package/release/plugin_markup.js +46 -46
  70. package/release/plugin_markup.js.map +3 -3
  71. package/release/plugin_weykturtle3d.js +1 -1
  72. package/release/plugin_weykturtle3d.js.map +3 -3
  73. package/release/version.js +2 -2
  74. package/release/version_main.js +2 -2
  75. package/release/version_main.js.map +1 -1
  76. package/release/wnako3.js +186 -213
  77. package/release/wnako3.js.map +4 -4
  78. package/release/wnako3webworker.js +172 -199
  79. package/release/wnako3webworker.js.map +4 -4
  80. package/src/cnako3mod.mjs +7 -2
  81. package/src/cnako3mod.mts +7 -2
  82. package/src/nako_version.mjs +2 -2
  83. package/src/nako_version.mts +2 -2
  84. package/src/plugin_browser_ajax.mjs +4 -4
  85. package/src/plugin_browser_ajax.mts +4 -4
  86. package/src/plugin_browser_audio.mjs +10 -10
  87. package/src/plugin_browser_audio.mts +10 -10
  88. package/src/plugin_browser_camera.mjs +4 -4
  89. package/src/plugin_browser_camera.mts +4 -4
  90. package/src/plugin_browser_canvas.mjs +2 -2
  91. package/src/plugin_browser_canvas.mts +2 -2
  92. package/src/plugin_browser_crypto.mjs +3 -3
  93. package/src/plugin_browser_crypto.mts +3 -3
  94. package/src/plugin_browser_dom_event.mjs +1 -1
  95. package/src/plugin_browser_dom_event.mts +1 -1
  96. package/src/plugin_browser_geolocation.mjs +1 -1
  97. package/src/plugin_browser_geolocation.mts +1 -1
  98. package/src/plugin_browser_hotkey.mjs +1 -1
  99. package/src/plugin_browser_hotkey.mts +1 -1
  100. package/src/plugin_browser_html.mjs +1 -1
  101. package/src/plugin_browser_html.mts +1 -1
  102. package/src/plugin_browser_location.mjs +1 -1
  103. package/src/plugin_browser_location.mts +1 -1
  104. package/src/plugin_browser_speech.mjs +1 -1
  105. package/src/plugin_browser_speech.mts +1 -1
  106. package/src/plugin_browser_storage.mjs +2 -2
  107. package/src/plugin_browser_storage.mts +2 -2
  108. package/src/plugin_httpserver.mjs +3 -3
  109. package/src/plugin_httpserver.mts +3 -3
  110. package/src/plugin_keigo.mjs +2 -2
  111. package/src/plugin_keigo.mts +2 -2
  112. package/src/plugin_node.mjs +48 -48
  113. package/src/plugin_node.mts +53 -53
  114. package/src/plugin_weykturtle3d.mjs +56 -56
  115. package/src/plugin_weykturtle3d.mts +56 -56
  116. package/src/wnako3.mjs +1 -1
  117. package/src/wnako3.mts +1 -1
  118. package/src/wnako3_editor.mjs +5 -5
  119. package/src/wnako3_editor.mts +5 -5
  120. package/src/wnako3mod.mjs +2 -2
  121. package/src/wnako3mod.mts +2 -2
  122. package/core/src/nako3.mjs +0 -1021
  123. package/core/src/nako_ast.mjs +0 -4
  124. package/core/src/nako_colors.mjs +0 -77
  125. package/core/src/nako_core_version.mjs +0 -8
  126. package/core/src/nako_csv.mjs +0 -193
  127. package/core/src/nako_errors.mjs +0 -166
  128. package/core/src/nako_from_dncl.mjs +0 -285
  129. package/core/src/nako_from_dncl2.mjs +0 -347
  130. package/core/src/nako_gen.mjs +0 -2500
  131. package/core/src/nako_global.mjs +0 -138
  132. package/core/src/nako_indent.mjs +0 -442
  133. package/core/src/nako_indent_chars.mjs +0 -29
  134. package/core/src/nako_indent_inline.mjs +0 -361
  135. package/core/src/nako_josi_list.mjs +0 -47
  136. package/core/src/nako_lex_rules.mjs +0 -319
  137. package/core/src/nako_lexer.mjs +0 -794
  138. package/core/src/nako_logger.mjs +0 -221
  139. package/core/src/nako_parser3.mjs +0 -3250
  140. package/core/src/nako_parser_base.mjs +0 -403
  141. package/core/src/nako_parser_const.mjs +0 -37
  142. package/core/src/nako_prepare.mjs +0 -329
  143. package/core/src/nako_reserved_words.mjs +0 -42
  144. package/core/src/nako_source_mapping.mjs +0 -207
  145. package/core/src/nako_test.mjs +0 -37
  146. package/core/src/nako_token.mjs +0 -1
  147. package/core/src/nako_tools.mjs +0 -53
  148. package/core/src/nako_types.mjs +0 -14
  149. package/core/src/plugin_api.mjs +0 -4
  150. package/core/src/plugin_csv.mjs +0 -97
  151. package/core/src/plugin_math.mjs +0 -352
  152. package/core/src/plugin_promise.mjs +0 -102
  153. package/core/src/plugin_system.mjs +0 -3810
  154. package/core/src/plugin_test.mjs +0 -52
  155. package/core/src/plugin_toml.mjs +0 -39
@@ -1,4 +0,0 @@
1
- /**
2
- * 抽象構文木( Abstract Syntax Tree )を定義したもの
3
- */
4
- export {};
@@ -1,77 +0,0 @@
1
- /**
2
- * ブラウザとNode.jsでテキストへの色付けを共通化するためのコード
3
- */
4
- /**
5
- * ANSI escape code の一部
6
- */
7
- const color = { reset: '\x1b[0m', bold: '\x1b[1m', black: '\x1b[30m', red: '\x1b[31m', green: '\x1b[32m', yellow: '\x1b[33m', blue: '\x1b[34m', magenta: '\x1b[35m', cyan: '\x1b[36m', white: '\x1b[37m' };
8
- // 30 ~ 37
9
- const colorNames = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'];
10
- /** @param {string} t */
11
- const escapeHTML = (t) => t.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#039;');
12
- /**
13
- * ANSI escape code で色付けしたテキストを、HTMLやブラウザのconsole.log用のフォーマットに変換する。
14
- * たとえば `convertColorTextFormat(`foo${color.red}bar`).html` で `"foobar"` の `"bar"` の部分が赤く表示されるHTMLを取得できる。
15
- * @param {string} text
16
- * @returns {{ nodeConsole: string, noColor: string, html: string, browserConsole: string[] }}
17
- */
18
- const convertColorTextFormat = (text) => {
19
- // textから [ANSI escape code](https://en.wikipedia.org/wiki/ANSI_escape_code) を削除して、色の無いテキストを作る。
20
- // eslint-disable-next-line no-control-regex
21
- const noColor = text.replace(/\x1b\[\d+m/g, '');
22
- // nodeConsoleからbrowserConsoleを作る
23
- /** @type {string[]} */
24
- const browserConsoleStyles = [];
25
- let consoleColor = 'inherit'; // 文字色
26
- let consoleFontWeight = 'inherit'; // 文字の太さ
27
- // /\x1b\[(\d+)m/ で正規表現マッチし、それぞれを %c で置換すると同時に browserConsoleStyles にCSSでの表現をpushする。
28
- // console.log(browserConsoleText, ...browserConsoleStyles) で表示することを想定。
29
- const browserConsoleText = text === noColor
30
- ? noColor
31
- // eslint-disable-next-line no-control-regex
32
- : text.replace(/\x1b\[(\d+)m/g, (_, m1str) => {
33
- const m1 = +m1str;
34
- if (m1 === 0) {
35
- consoleColor = 'inherit';
36
- consoleFontWeight = 'inherit';
37
- }
38
- if (m1 === 1) {
39
- consoleFontWeight = 'bold';
40
- }
41
- if (m1 >= 30 && m1 <= 37) {
42
- consoleColor = colorNames[m1 - 30];
43
- }
44
- browserConsoleStyles.push(`color: ${consoleColor}; font-weight: ${consoleFontWeight};`);
45
- return '%c';
46
- });
47
- // nodeConsoleからhtmlを作る
48
- let htmlColor = 'inherit'; // 文字色
49
- let htmlFontWeight = 'inherit'; // 文字の太さ
50
- // textが色情報を含まないならそれをそのまま使い、含むなら全体を <span>で囲んで、更に、ANSI escape code で囲まれた部分を対応する style を付けた <span> で囲む。
51
- const html = text === noColor ? noColor : ('<span>' + escapeHTML(text)
52
- // eslint-disable-next-line no-control-regex
53
- .replace(/\x1b\[(\d+)m/g, (_, m1str) => {
54
- const m1 = +m1str;
55
- if (m1 === 0) { // リセット
56
- htmlColor = 'inherit';
57
- htmlFontWeight = 'inherit';
58
- }
59
- if (m1 === 1) { // 太字化
60
- htmlFontWeight = 'bold';
61
- }
62
- if (m1 >= 30 && m1 <= 37) { // 文字色の変更
63
- htmlColor = colorNames[m1 - 30];
64
- }
65
- return `</span><span style="color: ${htmlColor}; font-weight: ${htmlFontWeight};">`;
66
- }) + '</span>');
67
- // 各表現を返す。
68
- return {
69
- noColor,
70
- nodeConsole: text === noColor
71
- ? noColor // textが色の情報を含まないならnoColorを返す。
72
- : text + '\x1b[0m', // そうでなければtextの末尾に色をリセットするコードを付けて返す。
73
- html,
74
- browserConsole: [browserConsoleText, ...browserConsoleStyles]
75
- };
76
- };
77
- export const NakoColors = { convertColorTextFormat, colorNames, color };
@@ -1,8 +0,0 @@
1
- // 実際のバージョン定義 (自動生成されるので以下を編集しない)
2
- const coreVersion = {
3
- version: '3.7.21',
4
- major: 3,
5
- minor: 7,
6
- patch: 21
7
- };
8
- export default coreVersion;
@@ -1,193 +0,0 @@
1
- export const options = {
2
- delimiter: ',',
3
- eol: '\r\n',
4
- auto_convert_number: true
5
- };
6
- export function resetEnv() {
7
- options.delimiter = ',';
8
- options.eol = '\r\n';
9
- options.auto_convert_number = true;
10
- }
11
- /// 文字列が数値化どうか判定する関数
12
- function is_numeric(str) {
13
- return /^-?\d+(\.\d+)?([eE][-+]?\d+)?$/.test(str);
14
- }
15
- export function parse(txt, delimiter = undefined) {
16
- // delimiter
17
- if (delimiter === undefined) {
18
- delimiter = options.delimiter;
19
- }
20
- // check txt
21
- txt = '' + txt + '\n';
22
- // convert CRLF to LF, and CR to LF
23
- txt = txt.replace(/(\r\n|\r)/g, '\n');
24
- // trim right
25
- txt = txt.replace(/\s+$/, '') + '\n';
26
- // set pattern
27
- const patToDelim = '^(.*?)([\\' + delimiter + '\\n])';
28
- const reToDelim = new RegExp(patToDelim);
29
- // if value is number then convert to float
30
- const convType = function (v) {
31
- let result = v;
32
- if (typeof (v) === 'string') {
33
- if (options.auto_convert_number && is_numeric(v)) {
34
- result = parseFloat(v); // convert number
35
- }
36
- }
37
- return result;
38
- };
39
- // parse txt
40
- const res = [];
41
- let cells = [];
42
- let c = '';
43
- while (txt !== '') {
44
- // first check delimiter (because /^\s+/ skip delimiter'\t') (#3)
45
- c = txt.charAt(0);
46
- if (c === delimiter) {
47
- txt = txt.substring(1);
48
- cells.push('');
49
- continue;
50
- }
51
- // second check LF (#7)
52
- if (c === '\n') {
53
- cells.push('');
54
- res.push(cells);
55
- cells = [];
56
- txt = txt.substring(1);
57
- continue;
58
- }
59
- // trim white space
60
- txt = txt.replace(/^\s+/, '');
61
- c = txt.charAt(0);
62
- // no data
63
- if (c === delimiter) {
64
- console.log('delimiter');
65
- cells.push('');
66
- txt = txt.substring(delimiter.length);
67
- continue;
68
- }
69
- // written using the dialect of Excel
70
- if (c === '=' && txt.charAt(1) === '"') {
71
- txt = txt.substring(1);
72
- continue;
73
- }
74
- // number or simple string
75
- if (c !== '"') { // number or simple str
76
- const m = reToDelim.exec(txt);
77
- if (!m) {
78
- cells.push(convType(txt));
79
- res.push(cells);
80
- cells = [];
81
- break;
82
- }
83
- if (m[2] === '\n') {
84
- cells.push(convType(m[1]));
85
- res.push(cells);
86
- cells = [];
87
- }
88
- else if (m[2] === delimiter) {
89
- cells.push(convType(m[1]));
90
- }
91
- txt = txt.substring(m[0].length);
92
- continue;
93
- }
94
- // "" ... blank data
95
- if (txt.substring(0, 2) === '""') {
96
- cells.push('');
97
- txt = txt.substring(2);
98
- continue;
99
- }
100
- // "..."
101
- let i = 1;
102
- let s = '';
103
- while (i < txt.length) {
104
- const c1 = txt.charAt(i);
105
- const c2 = txt.charAt(i + 1);
106
- // console.log("@" + c1 + c2);
107
- // 2quote => 1quote char
108
- if (c1 === '"' && c2 === '"') {
109
- i += 2;
110
- s += '"';
111
- continue;
112
- }
113
- if (c1 === '"') {
114
- i++;
115
- if (c2 === delimiter) {
116
- i++;
117
- cells.push(convType(s));
118
- s = '';
119
- break;
120
- }
121
- if (c2 === '\n') {
122
- i++;
123
- cells.push(convType(s));
124
- res.push(cells);
125
- cells = [];
126
- break;
127
- }
128
- // if (c2 === " " || c2 === "\t") {
129
- i++;
130
- continue;
131
- }
132
- s += c1;
133
- i++;
134
- }
135
- txt = txt.substr(i);
136
- }
137
- if (cells.length > 0)
138
- res.push(cells);
139
- return res;
140
- }
141
- // convert 2D array to CSV string
142
- export function stringify(ary, delimiter = undefined, eol = undefined) {
143
- // check arguments
144
- if (delimiter === undefined) {
145
- delimiter = options.delimiter;
146
- }
147
- if (eol === undefined) {
148
- eol = options.eol;
149
- }
150
- const valueConv = genValueConverter(delimiter);
151
- if (ary === undefined)
152
- return '';
153
- let r = '';
154
- for (let i = 0; i < ary.length; i++) {
155
- const cells = ary[i];
156
- if (cells === undefined) {
157
- r += eol;
158
- continue;
159
- }
160
- for (let j = 0; j < cells.length; j++) {
161
- cells[j] = valueConv(cells[j]);
162
- }
163
- r += cells.join(delimiter) + eol;
164
- }
165
- // replace return code
166
- r = r.replace(/(\r\n|\r|\n)/g, eol);
167
- return r;
168
- }
169
- export function replaceEolMark(eol) {
170
- eol = eol.replace(/\n\r/g, '[CRLF]');
171
- eol = eol.replace(/\r/g, '[CR]');
172
- eol = eol.replace(/\n/g, '[LF]');
173
- return eol;
174
- }
175
- function genValueConverter(delimiter) {
176
- return function (s) {
177
- s = '' + s;
178
- let fQuot = false;
179
- if (s.indexOf('\n') >= 0 || s.indexOf('\r') >= 0) {
180
- fQuot = true;
181
- }
182
- if (s.indexOf(delimiter) >= 0) {
183
- fQuot = true;
184
- }
185
- if (s.indexOf('"') >= 0) {
186
- fQuot = true;
187
- s = s.replace(/"/g, '""');
188
- }
189
- if (fQuot)
190
- s = '"' + s + '"';
191
- return s;
192
- };
193
- }
@@ -1,166 +0,0 @@
1
- /**
2
- * なでしこ言語が投げる全てのエラーが継承するクラス
3
- */
4
- export class NakoError extends Error {
5
- constructor(tag, msg, file = undefined, line = undefined) {
6
- // エラー位置を分かりやすく日本語に変換
7
- const positionJa = `${file || ''}${line === undefined ? '' : `(${line + 1}行目): `}`;
8
- // #1223 エラーメッセージに「main__関数名」と表示されるので、main__は省略して表示
9
- msg = msg.replace(/『main__(.+?)』/g, '『$1』');
10
- // 親のErrorを呼ぶ
11
- super(`[${tag}]${positionJa}${msg}`);
12
- // エラーの種類を設定
13
- this.name = 'NakoError';
14
- this.type = 'NakoError';
15
- this.tag = '[' + tag + ']';
16
- this.positionJa = positionJa;
17
- this.msg = msg;
18
- }
19
- }
20
- export class NakoIndentError extends NakoError {
21
- /**
22
- * @param {string} msg
23
- * @param {number} line
24
- * @param {string} file
25
- */
26
- constructor(msg, line, file) {
27
- super('インデントエラー', msg, file, line);
28
- this.type = 'NakoIndentError';
29
- this.line = line;
30
- this.file = file;
31
- }
32
- }
33
- // コンパイラの内部でのみ使うエラー。投げられたらtryでキャッチしてLexerErrorへ変更する。
34
- export class InternalLexerError extends NakoError {
35
- /**
36
- * @param {string} msg
37
- * @param {number} preprocessedCodeStartOffset
38
- * @param {number} preprocessedCodeEndOffset
39
- * @param {number | undefined} [line]
40
- * @param {string | undefined} [file]
41
- */
42
- constructor(msg, preprocessedCodeStartOffset, preprocessedCodeEndOffset, line, file) {
43
- super('字句解析エラー(内部エラー)', msg, file, line);
44
- this.type = 'InternalLexerError';
45
- this.preprocessedCodeStartOffset = preprocessedCodeStartOffset;
46
- this.preprocessedCodeEndOffset = preprocessedCodeEndOffset;
47
- this.line = line;
48
- this.file = file;
49
- }
50
- }
51
- export class NakoLexerError extends NakoError {
52
- /**
53
- * @param {string} msg
54
- * @param {number | null} startOffset
55
- * @param {number | null} endOffset,
56
- * @param {number | undefined} line
57
- * @param {string | undefined} file
58
- */
59
- constructor(msg, startOffset, endOffset, line, file) {
60
- super('字句解析エラー', msg, file, line);
61
- this.type = 'NakoLexerError';
62
- this.startOffset = startOffset;
63
- this.endOffset = endOffset;
64
- this.line = line;
65
- this.file = file;
66
- }
67
- }
68
- export class NakoSyntaxError extends NakoError {
69
- /**
70
- * @param {string} msg
71
- * @param {Ast} first
72
- * @param {Ast} [last]
73
- */
74
- static fromNode(msg, first, last = undefined) {
75
- if (!first) {
76
- return new NakoSyntaxError(msg, undefined, undefined, undefined, undefined);
77
- }
78
- const startOffset = typeof first.startOffset === 'number' ? first.startOffset : undefined;
79
- const endOffset = (last && typeof last.endOffset === 'number')
80
- ? last.endOffset
81
- : (typeof first.endOffset === 'number' ? first.endOffset : undefined);
82
- return new NakoSyntaxError(msg, first.line, startOffset, endOffset, first.file);
83
- }
84
- /**
85
- * @param {string} msg
86
- * @param {number | undefined} line
87
- * @param {number | undefined} startOffset
88
- * @param {number | undefined} endOffset
89
- * @param {string | undefined} file
90
- */
91
- constructor(msg, line, startOffset, endOffset, file) {
92
- super('文法エラー', msg, file, line);
93
- this.type = 'NakoSyntaxError';
94
- this.file = file;
95
- this.line = line;
96
- this.startOffset = startOffset;
97
- this.endOffset = endOffset;
98
- }
99
- }
100
- export class NakoRuntimeError extends NakoError {
101
- /**
102
- * @param error エラー
103
- * @param lineNo 発生行
104
- */
105
- constructor(error, lineNo) {
106
- let msg = 'unknown';
107
- if (typeof error === 'string') {
108
- msg = error;
109
- }
110
- else {
111
- if (error instanceof NakoRuntimeError) {
112
- msg = error.msg;
113
- }
114
- else if (error instanceof NakoError) {
115
- msg = error.msg;
116
- }
117
- else if (error instanceof Error) {
118
- if (error.name === 'Error') {
119
- msg = error.message;
120
- }
121
- else {
122
- msg = `${error.name}: ${error.message}`;
123
- }
124
- }
125
- }
126
- // 行番号を表す文字列をパースする。
127
- let line;
128
- let file;
129
- let matches;
130
- if (lineNo === undefined) {
131
- line = undefined;
132
- file = undefined;
133
- // eslint-disable-next-line no-cond-assign
134
- }
135
- else if (matches = /^l(-?\d+):(.*)$/.exec(lineNo)) {
136
- line = parseInt(matches[1]);
137
- file = matches[2];
138
- // eslint-disable-next-line no-cond-assign
139
- }
140
- else if (matches = /^l(-?\d+)$/.exec(lineNo)) {
141
- line = parseInt(matches[1]);
142
- file = 'main.nako3';
143
- }
144
- else {
145
- line = 0;
146
- file = lineNo;
147
- }
148
- super('実行時エラー', msg, file, line);
149
- this.type = 'NakoRuntimeError';
150
- this.lineNo = lineNo;
151
- this.line = line;
152
- this.file = file;
153
- }
154
- }
155
- export class NakoImportError extends NakoError {
156
- /**
157
- * @param {string} msg
158
- * @param {string} file
159
- * @param {number} line
160
- */
161
- constructor(msg, file, line) {
162
- super('取り込みエラー', msg, file, line);
163
- this.file = file;
164
- this.line = line;
165
- }
166
- }