nadesiko3 3.3.49 → 3.3.52
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/LICENSE +21 -21
- package/README.md +143 -143
- package/batch/.DS_Store +0 -0
- package/batch/browsers.template.md +3 -3
- package/batch/build_browsers.nako3 +72 -72
- package/batch/build_command.nako3 +44 -44
- package/batch/build_nako_version.nako3 +42 -42
- package/batch/calc_hash.nako3 +29 -29
- package/batch/cmd_txt2json.nako3 +74 -74
- package/batch/command.txt +162 -83
- package/batch/command_nakopad.txt +69 -0
- package/batch/download-extlib.nako3 +43 -43
- package/batch/gen_command_nakopad.nako3 +57 -57
- package/batch/jsplugin2text.nako3 +285 -285
- package/batch/pickup_command.nako3 +113 -110
- package/batch/pickup_reserved_words.nako3 +11 -11
- package/batch/publish_version.nako3 +46 -46
- package/batch/show_agents.js +14 -14
- package/batch/turtle2js.nako3 +21 -21
- package/bin/cnako3 +10 -10
- package/core/LICENSE +21 -21
- package/core/README.md +66 -66
- package/core/batch/build_nako_version.nako3 +42 -42
- package/core/command/snako.mjs +105 -105
- package/core/command/snako.mts +116 -116
- package/core/index.mjs +21 -21
- package/core/package.json +47 -47
- package/core/sample/hello.nako3 +7 -7
- package/core/sample/hoge.mjs +4 -4
- package/core/sample/hoge.mts +6 -6
- package/core/src/nako3.mjs +870 -858
- package/core/src/nako3.mts +983 -967
- package/core/src/nako_colors.mjs +78 -78
- package/core/src/nako_colors.mts +86 -86
- package/core/src/nako_core_version.mjs +8 -8
- package/core/src/nako_core_version.mts +19 -19
- package/core/src/nako_csv.mjs +185 -185
- package/core/src/nako_csv.mts +188 -188
- package/core/src/nako_errors.mjs +173 -173
- package/core/src/nako_errors.mts +197 -197
- package/core/src/nako_from_dncl.mjs +255 -255
- package/core/src/nako_from_dncl.mts +250 -250
- package/core/src/nako_gen.mjs +1647 -1648
- package/core/src/nako_gen.mts +1718 -1719
- package/core/src/nako_gen_async.mjs +1659 -1659
- package/core/src/nako_gen_async.mts +1732 -1732
- package/core/src/nako_global.mjs +109 -107
- package/core/src/nako_global.mts +141 -138
- package/core/src/nako_indent.mjs +445 -445
- package/core/src/nako_indent.mts +492 -492
- package/core/src/nako_josi_list.mjs +38 -38
- package/core/src/nako_josi_list.mts +45 -45
- package/core/src/nako_lex_rules.mjs +253 -253
- package/core/src/nako_lex_rules.mts +260 -260
- package/core/src/nako_lexer.mjs +609 -609
- package/core/src/nako_lexer.mts +612 -612
- package/core/src/nako_logger.mjs +199 -199
- package/core/src/nako_logger.mts +232 -232
- package/core/src/nako_parser3.mjs +2441 -2439
- package/core/src/nako_parser3.mts +2197 -2195
- package/core/src/nako_parser_base.mjs +371 -370
- package/core/src/nako_parser_base.mts +372 -370
- package/core/src/nako_parser_const.mjs +37 -37
- package/core/src/nako_parser_const.mts +37 -37
- package/core/src/nako_prepare.mjs +304 -304
- package/core/src/nako_prepare.mts +315 -315
- package/core/src/nako_reserved_words.mjs +38 -38
- package/core/src/nako_reserved_words.mts +38 -38
- package/core/src/nako_source_mapping.mjs +207 -207
- package/core/src/nako_source_mapping.mts +262 -262
- package/core/src/nako_test.mjs +37 -37
- package/core/src/nako_types.mjs +13 -25
- package/core/src/nako_types.mts +144 -151
- package/core/src/plugin_csv.mjs +49 -49
- package/core/src/plugin_csv.mts +50 -50
- package/core/src/plugin_math.mjs +328 -328
- package/core/src/plugin_math.mts +326 -326
- package/core/src/plugin_promise.mjs +91 -91
- package/core/src/plugin_promise.mts +91 -91
- package/core/src/plugin_system.mjs +2832 -2832
- package/core/src/plugin_system.mts +2690 -2690
- package/core/src/plugin_test.mjs +34 -34
- package/core/src/plugin_test.mts +34 -34
- package/demo/.DS_Store +0 -0
- package/demo/ace_editor.html +89 -89
- package/demo/ace_editor_tabs.html +161 -161
- package/demo/basic.html +71 -71
- package/demo/browsers.html +10 -9
- package/demo/css/basic.css +3 -3
- package/demo/css/common.css +157 -157
- package/demo/css/editor.css +8 -8
- package/demo/css/flow.css +3 -3
- package/demo/css/index.css +3 -3
- package/demo/extlib/.DS_Store +0 -0
- package/demo/flow.html +98 -98
- package/demo/graph.html +53 -53
- package/demo/image/nakopad-icon256.png +0 -0
- package/demo/index.html +133 -133
- package/demo/js/common.js +17 -17
- package/demo/js/turtle3d_test.js +44 -44
- package/demo/js/turtle_test.js +45 -45
- package/demo/nako3/calc.nako3 +4 -4
- package/demo/runscript.html +47 -47
- package/demo/runscript2.html +33 -33
- package/demo/runscript3.html +35 -35
- package/demo/runscript4.html +33 -33
- package/demo/turtle.html +58 -58
- package/demo/turtle2.html +141 -141
- package/demo/turtle3.html +279 -279
- package/demo/turtle3d.html +58 -58
- package/demo/turtle3d2.html +107 -107
- package/demo/version.html +24 -24
- package/doc/SETUP.md +157 -157
- package/doc/about.md +17 -17
- package/doc/browsers.md +26 -26
- package/doc/docgen.md +21 -21
- package/doc/editor.md +44 -44
- package/doc/files.md +39 -39
- package/doc/plugins.md +234 -234
- package/doc/release.md +79 -79
- package/doc/textlint.md +43 -43
- package/doc/win32.md +57 -57
- package/package.json +195 -195
- package/release/_hash.txt +28 -28
- 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 +2 -1
- package/release/nako_gen_async.js.LICENSE.txt +35 -0
- package/release/plugin_caniuse.js.LICENSE.txt +11 -0
- package/release/plugin_csv.js +1 -1
- package/release/plugin_csv.js.LICENSE.txt +15 -0
- package/release/plugin_datetime.js.LICENSE.txt +15 -0
- package/release/plugin_kansuji.js.LICENSE.txt +3 -0
- package/release/plugin_markup.js.LICENSE.txt +11 -0
- package/release/plugin_turtle.js.LICENSE.txt +15 -0
- package/release/plugin_webworker.js.LICENSE.txt +3 -0
- package/release/plugin_weykturtle3d.js.LICENSE.txt +3 -0
- package/release/stats.json +1 -1
- package/release/version.js +1 -1
- package/release/wnako3.js +1 -1
- package/release/wnako3.js.LICENSE.txt +203 -1
- package/release/wnako3webworker.js +2 -1
- package/release/wnako3webworker.js.LICENSE.txt +131 -0
- package/src/.DS_Store +0 -0
- package/src/browsers.txt +12 -11
- package/src/browsers_agents.json +2 -2
- package/src/browsers_agents.mjs +1 -1
- package/src/cnako3.mjs +17 -17
- package/src/cnako3.mts +18 -18
- package/src/cnako3mod.mjs +682 -707
- package/src/cnako3mod.mts +688 -712
- package/src/commander_ja.mjs +164 -164
- package/src/commander_ja.mts +161 -161
- package/src/enako3.mjs +68 -68
- package/src/era.mjs +22 -22
- package/src/image_turtle-elephant.mjs +2 -2
- package/src/image_turtle-panda.mjs +2 -2
- package/src/image_turtle64.mjs +2 -2
- package/src/index.mjs +9 -9
- package/src/index.mts +10 -10
- package/src/nako3editorfix.sfd +106 -106
- package/src/nako_version.mjs +8 -8
- package/src/nako_version.mts +2 -2
- package/src/plugin_browser.mjs +213 -213
- package/src/plugin_browser.mts +206 -206
- package/src/plugin_browser_ajax.mjs +399 -399
- package/src/plugin_browser_audio.mjs +109 -109
- package/src/plugin_browser_canvas.mjs +449 -449
- package/src/plugin_browser_chart.mjs +294 -294
- package/src/plugin_browser_color.mjs +49 -49
- package/src/plugin_browser_crypto.mjs +26 -26
- package/src/plugin_browser_dialog.mjs +53 -53
- package/src/plugin_browser_dom_basic.mjs +336 -336
- package/src/plugin_browser_dom_event.mjs +193 -193
- package/src/plugin_browser_dom_parts.mjs +396 -396
- package/src/plugin_browser_geolocation.mjs +51 -51
- package/src/plugin_browser_hotkey.mjs +25 -25
- package/src/plugin_browser_html.mjs +59 -59
- package/src/plugin_browser_in_worker.mjs +45 -45
- package/src/plugin_browser_location.mjs +21 -21
- package/src/plugin_browser_speech.mjs +111 -111
- package/src/plugin_browser_storage.mjs +121 -121
- package/src/plugin_browser_system.mjs +31 -31
- package/src/plugin_browser_websocket.mjs +73 -73
- package/src/plugin_caniuse.mjs +29 -29
- package/src/plugin_datetime.mjs +394 -394
- package/src/plugin_httpserver.mjs +277 -277
- package/src/plugin_httpserver.mts +286 -286
- package/src/plugin_kansuji.mjs +224 -224
- package/src/plugin_keigo.mjs +55 -55
- package/src/plugin_markup.mjs +32 -32
- package/src/plugin_node.mjs +1047 -1047
- package/src/plugin_node.mts +980 -980
- package/src/plugin_turtle.mjs +647 -647
- package/src/plugin_webworker.mjs +334 -334
- package/src/plugin_weykturtle3d.mjs +1214 -1214
- package/src/plugin_worker.mjs +95 -95
- package/src/repl.nako3 +63 -63
- package/src/wnako3.mjs +12 -12
- package/src/wnako3.mts +11 -11
- package/src/wnako3_editor.css +215 -215
- package/src/wnako3_editor.mjs +1542 -1542
- package/src/wnako3_editor.mts +1658 -1657
- package/src/wnako3mod.mjs +213 -213
- package/src/wnako3mod.mts +214 -214
- package/src/wnako3webworker.mjs +69 -69
- package/test/.DS_Store +0 -0
- package/test/ace_editor/karma.config.js +94 -94
- package/test/ace_editor/test/.babelrc.json +3 -3
- package/test/ace_editor/test/ace_editor_test.js +178 -178
- package/test/ace_editor/test/html/custom_context.html +139 -139
- package/test/async/async_basic_test.mjs +122 -122
- package/test/browser/.DS_Store +0 -0
- package/test/browser/karma.config.js +221 -221
- package/test/browser/test/.babelrc.json +3 -3
- package/test/browser/test/compare_util.js +50 -50
- package/test/browser/test/html/div_basic.html +2 -2
- package/test/browser/test/html/event_dom_form.html +4 -4
- package/test/browser/test/html/event_dom_scrolldiv.html +5 -5
- package/test/browser/test/import_plugin_checker.js +24 -24
- package/test/browser/test/plugin_browser_test.js +51 -51
- package/test/browser/test/plugin_browser_test_ajax.js +123 -123
- package/test/browser/test/plugin_browser_test_color.js +18 -18
- package/test/browser/test/plugin_browser_test_dialog.js +72 -72
- package/test/browser/test/plugin_browser_test_dom_event.js +598 -598
- package/test/browser/test/plugin_browser_test_dom_parts.js +125 -125
- package/test/browser/test/plugin_browser_test_system.js +9 -9
- package/test/browser/test/plugin_turtle_test.js +817 -817
- package/test/browser/test/plugin_webworker_test.js +86 -86
- package/test/browser/test/require_test.js +68 -68
- package/test/bundled/.DS_Store +0 -0
- package/test/bundled/karma.config.base.js +117 -117
- package/test/bundled/karma.config.js +86 -86
- package/test/bundled/test/.babelrc.json +3 -3
- package/test/bundled/test/bundled_test.js +69 -69
- package/test/bundled/test/html/custom_context.html +65 -65
- package/test/bundled/test/html/custom_debug.html +66 -66
- package/test/bundled/test4b.cmd +52 -52
- package/test/bundled/test_base/.DS_Store +0 -0
- package/test/bundled/test_base/.babelrc.json +3 -3
- package/test/bundled/test_base/_checktool_test.js +25 -25
- package/test/bundled/test_base/basic_ajax_test.js +56 -56
- package/test/bundled/test_base/basic_async_test.js +18 -18
- package/test/bundled/test_base/basic_test.js +153 -153
- package/test/bundled/test_base/calc_test.js +132 -132
- package/test/bundled/test_base/css/browsers_box.css +114 -114
- package/test/bundled/test_base/html/custom_context.html +69 -69
- package/test/bundled/test_base/html/custom_debug.html +71 -71
- package/test/bundled/test_base/js/browsers_box.js +72 -72
- package/test/bundled/test_base/plugin_csv_test.js +37 -37
- package/test/bundled/test_base/plugin_datetime_test.js +115 -115
- package/test/bundled/test_base/plugin_kansuji_test.js +49 -49
- package/test/bundled/test_base/plugin_system_test.js +410 -410
- package/test/bundled/test_base/plugin_webworker_test.js +53 -53
- package/test/bundled/test_base/test_utils.js +191 -191
- package/test/common/.DS_Store +0 -0
- package/test/common/plugin_browser_test.mjs +22 -22
- package/test/common/plugin_browser_ut_audio_test.mjs +108 -108
- package/test/common/plugin_browser_ut_color_test.mjs +21 -21
- package/test/common/plugin_browser_ut_dialog_test.mjs +100 -100
- package/test/common/plugin_browser_ut_html_test.mjs +13 -13
- package/test/common/plugin_browser_ut_system_test.mjs +10 -10
- package/test/common/plugin_markup_test.mjs +23 -23
- package/test/jsconfig.json +19 -19
- package/test/karma.config.js +91 -91
- package/test/node/.DS_Store +0 -0
- package/test/node/async_test.mjs +96 -96
- package/test/node/commander_ja_test.mjs +89 -89
- package/test/node/error_message_test.mjs +243 -243
- package/test/node/kai_test.nako3 +6 -6
- package/test/node/node_test.mjs +60 -60
- package/test/node/plugin_broken.js.txt +3 -3
- package/test/node/plugin_browser_ut_ajax_test.mjs.todo +357 -357
- package/test/node/plugin_browser_ut_location_test.mjs +42 -42
- package/test/node/plugin_markup_test.mjs +47 -47
- package/test/node/plugin_math_test.mjs +45 -45
- package/test/node/plugin_node_test.mjs +98 -98
- package/test/node/plugin_test.mjs +44 -44
- package/test/node/relative_import_test_1.nako3 +1 -1
- package/test/node/relative_import_test_2.nako3 +2 -2
- package/test/node/require_nako3_test.mjs +67 -67
- package/test/node/requiretest.nako3 +4 -4
- package/test/node/requiretest_indirect.nako3 +1 -1
- package/test/node/requiretest_name.nako3 +5 -5
- package/test/node/runtime_error.nako3 +2 -2
- package/test/node/scope1.nako3 +10 -10
- package/test/node/scope2.nako3 +12 -12
- package/test/node/side_effects_test.mjs +39 -39
- package/test/node/sjis.txt +5 -5
- package/test/node/syntax_error.nako3 +1 -1
- package/test/node/wnako3_editor_test.mjs +384 -384
- package/tools/.DS_Store +0 -0
- package/tools/README.md +12 -12
- package/tools/check_new_version.nako3 +25 -25
- package/tools/nako3edit/.DS_Store +0 -0
- package/tools/nako3edit/a.sqlite3 +0 -0
- package/tools/nako3edit/html/.DS_Store +0 -0
- package/tools/nako3edit/html/daisyui/LICENSE +22 -22
- package/tools/nako3edit/html/daisyui/version_2.14.1 +1 -1
- package/tools/nako3edit/html/edit.html +170 -170
- package/tools/nako3edit/html/edit_plugin.js +6 -6
- package/tools/nako3edit/html/files.html +125 -125
- package/tools/nako3edit/html/nako3edit.css +65 -65
- package/tools/nako3edit/index.mjs +248 -248
- package/tools/nako3server/index.html +10 -10
- package/tools/nako3server/index.mjs +116 -116
- package/tools/nako3server/index.nako3 +34 -34
- package/core/.editorconfig +0 -6
- package/core/.eslintrc.cjs +0 -33
- package/core/.github/dependabot.yml +0 -7
- package/core/.github/workflows/nodejs.yml +0 -37
- package/core/.github/workflows/super-linter.yml +0 -61
- package/core/.github/workflows/textlint.yml +0 -199
- package/core/index.mts +0 -21
- package/core/test/array_test.mjs +0 -34
- package/core/test/basic_test.mjs +0 -344
- package/core/test/calc_test.mjs +0 -140
- package/core/test/core_module_test.mjs +0 -23
- package/core/test/debug_test.mjs +0 -16
- package/core/test/dncl_test.mjs +0 -94
- package/core/test/error_message_test.mjs +0 -210
- package/core/test/error_test.mjs +0 -16
- package/core/test/flow_test.mjs +0 -373
- package/core/test/func_call.mjs +0 -160
- package/core/test/func_test.mjs +0 -149
- package/core/test/indent_test.mjs +0 -364
- package/core/test/lex_test.mjs +0 -168
- package/core/test/literal_test.mjs +0 -73
- package/core/test/nako_lexer_test.mjs +0 -35
- package/core/test/nako_logger_test.mjs +0 -76
- package/core/test/nako_logger_test.mts +0 -78
- package/core/test/plugin_csv_test.mjs +0 -38
- package/core/test/plugin_promise_test.mjs +0 -18
- package/core/test/plugin_system_test.mjs +0 -630
- package/core/test/prepare_test.mjs +0 -96
- package/core/test/re_test.mjs +0 -22
- package/core/test/side_effects_test.mjs +0 -92
- package/core/test/variable_scope_test.mjs +0 -149
- package/core/tsconfig.json +0 -101
|
@@ -1,2195 +1,2197 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* nadesiko v3 parser
|
|
3
|
-
*/
|
|
4
|
-
import { opPriority, keizokuJosi, operatorList } from './nako_parser_const.mjs'
|
|
5
|
-
import { NakoParserBase } from './nako_parser_base.mjs'
|
|
6
|
-
import { NakoSyntaxError } from './nako_errors.mjs'
|
|
7
|
-
import { NakoLexer } from './nako_lexer.mjs'
|
|
8
|
-
import { Token, Ast, FuncListItem, FuncArgs, NewEmptyToken, SourceMap } from './nako_types.mjs'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* 構文解析を行うクラス
|
|
12
|
-
*/
|
|
13
|
-
export class NakoParser extends NakoParserBase {
|
|
14
|
-
/**
|
|
15
|
-
* 構文解析を実行する
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.
|
|
22
|
-
|
|
23
|
-
this.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (this.check('
|
|
104
|
-
if (this.check('
|
|
105
|
-
if (this.
|
|
106
|
-
if (this.
|
|
107
|
-
if (this.
|
|
108
|
-
if (this.accept(['
|
|
109
|
-
if (this.accept(['
|
|
110
|
-
if (this.accept(['
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (this.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (this.accept([this.
|
|
124
|
-
if (this.accept([this.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if (this.accept([this.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
this.
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
if (
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
this.
|
|
274
|
-
this.
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
this.
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
throw NakoSyntaxError.fromNode('
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
//
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
if (this.check('
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
block = this.
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
if (this.check('
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
block = this.
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
this.
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
//
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
const
|
|
673
|
-
const
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
if (
|
|
738
|
-
this.
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
if (this.check('
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
if (
|
|
774
|
-
this.
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
if (
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
if (this.check('
|
|
803
|
-
if (this.check('
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
//
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
if (
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
if (this.check('
|
|
867
|
-
multiline = true
|
|
868
|
-
this.get()
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
const
|
|
899
|
-
if (
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
this.
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
if (this.check('
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
if (
|
|
955
|
-
throw NakoSyntaxError.fromNode('
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
// 違えば
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
if (
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
if (
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
if (
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
this.
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
const
|
|
1066
|
-
const
|
|
1067
|
-
if (
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
const
|
|
1101
|
-
const
|
|
1102
|
-
if (
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
if (
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
if (this.check('
|
|
1165
|
-
//
|
|
1166
|
-
if (this.check('
|
|
1167
|
-
if (this.check('
|
|
1168
|
-
|
|
1169
|
-
if (this.check('
|
|
1170
|
-
if (this.check('
|
|
1171
|
-
if (this.check('
|
|
1172
|
-
if (this.check('
|
|
1173
|
-
|
|
1174
|
-
if (this.
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
const
|
|
1244
|
-
const
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
//
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
//
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
} else
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
const
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
const
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
if (
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
//
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
}
|
|
1416
|
-
|
|
1417
|
-
const
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
}
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
if (
|
|
1444
|
-
|
|
1445
|
-
la
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
if (
|
|
1452
|
-
|
|
1453
|
-
lb
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
this.
|
|
1470
|
-
|
|
1471
|
-
}
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
*
|
|
1614
|
-
* @
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
'
|
|
1624
|
-
'
|
|
1625
|
-
'
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
'
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
*
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
if (!
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
//
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
this.
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
//
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
this.
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
const
|
|
1843
|
-
const
|
|
1844
|
-
const
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
this.
|
|
1859
|
-
const
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
return {
|
|
1881
|
-
type: 'func',
|
|
1882
|
-
name: f.value,
|
|
1883
|
-
args: [],
|
|
1884
|
-
josi: f.josi,
|
|
1885
|
-
...map,
|
|
1886
|
-
end: this.peekSourceMap()
|
|
1887
|
-
}
|
|
1888
|
-
}
|
|
1889
|
-
// C風関数呼び出し FUNC(...)
|
|
1890
|
-
if (this.check2([['func', 'word'], '(']) && this.peekDef().josi === '') {
|
|
1891
|
-
const f = this.peek()
|
|
1892
|
-
if (this.accept([['func', 'word'], '(', this.yGetArgParen, ')'])) {
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
//
|
|
1906
|
-
if (this.
|
|
1907
|
-
//
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
return
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
if (
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
ast.index.push(this.checkArrayIndex(this.y[
|
|
1922
|
-
ast.index
|
|
1923
|
-
ast.
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
ast.index
|
|
1930
|
-
ast.
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
this.checkArrayIndex(this.y[
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
word.value
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
}
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
}
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
}
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
if (
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
if (
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
const
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
}
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* nadesiko v3 parser
|
|
3
|
+
*/
|
|
4
|
+
import { opPriority, keizokuJosi, operatorList } from './nako_parser_const.mjs'
|
|
5
|
+
import { NakoParserBase } from './nako_parser_base.mjs'
|
|
6
|
+
import { NakoSyntaxError } from './nako_errors.mjs'
|
|
7
|
+
import { NakoLexer } from './nako_lexer.mjs'
|
|
8
|
+
import { Token, Ast, FuncListItem, FuncArgs, NewEmptyToken, SourceMap } from './nako_types.mjs'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 構文解析を行うクラス
|
|
12
|
+
*/
|
|
13
|
+
export class NakoParser extends NakoParserBase {
|
|
14
|
+
/**
|
|
15
|
+
* 構文解析を実行する
|
|
16
|
+
*/
|
|
17
|
+
parse (tokens: Token[], filename: string): Ast {
|
|
18
|
+
this.reset()
|
|
19
|
+
this.tokens = tokens
|
|
20
|
+
this.modName = NakoLexer.filenameToModName(filename)
|
|
21
|
+
this.modList.push(this.modName)
|
|
22
|
+
// 解析開始
|
|
23
|
+
return this.startParser()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** パーサーの一番最初に呼び出す構文規則 */
|
|
27
|
+
startParser (): Ast {
|
|
28
|
+
const b: Ast = this.ySentenceList()
|
|
29
|
+
const c: Token|null = this.get()
|
|
30
|
+
if (c && c.type !== 'eof') {
|
|
31
|
+
this.logger.debug(`構文解析でエラー。${this.nodeToStr(c, { depth: 1 }, true)}の使い方が間違っています。`, c)
|
|
32
|
+
throw NakoSyntaxError.fromNode(`構文解析でエラー。${this.nodeToStr(c, { depth: 1 }, false)}の使い方が間違っています。`, c)
|
|
33
|
+
}
|
|
34
|
+
return b
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** 複数文を返す */
|
|
38
|
+
ySentenceList (): Ast {
|
|
39
|
+
const blocks = []
|
|
40
|
+
let line = -1
|
|
41
|
+
const map = this.peekSourceMap()
|
|
42
|
+
while (!this.isEOF()) {
|
|
43
|
+
const n: Ast|null = this.ySentence()
|
|
44
|
+
if (!n) { break }
|
|
45
|
+
blocks.push(n)
|
|
46
|
+
if (line < 0) { line = n.line }
|
|
47
|
+
}
|
|
48
|
+
if (blocks.length === 0) {
|
|
49
|
+
const token = this.peek() || this.tokens[0]
|
|
50
|
+
this.logger.debug('構文解析に失敗:' + this.nodeToStr(this.peek(), { depth: 1 }, true), token)
|
|
51
|
+
throw NakoSyntaxError.fromNode('構文解析に失敗:' + this.nodeToStr(this.peek(), { depth: 1 }, false), token)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return { type: 'block', block: blocks, ...map, end: this.peekSourceMap(), genMode: this.genMode }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
yEOL (): Ast | null {
|
|
58
|
+
// 行末のチェック #1009
|
|
59
|
+
const eol = this.get()
|
|
60
|
+
if (!eol) { return null }
|
|
61
|
+
// 余剰スタックの確認
|
|
62
|
+
if (this.stack.length > 0) {
|
|
63
|
+
/** 余剰スタックのレポートを作る */
|
|
64
|
+
const words: string[] = []
|
|
65
|
+
this.stack.forEach((t) => {
|
|
66
|
+
let w = this.nodeToStr(t, { depth: 1 }, false)
|
|
67
|
+
if (t.josi) { w += t.josi }
|
|
68
|
+
words.push(w)
|
|
69
|
+
})
|
|
70
|
+
const desc = words.join(',')
|
|
71
|
+
// 最近使った関数の使い方レポートを作る #1093
|
|
72
|
+
let descFunc = ''
|
|
73
|
+
const chA = 'A'.charCodeAt(0)
|
|
74
|
+
for (const f of this.recentlyCalledFunc) {
|
|
75
|
+
descFunc += ' - '
|
|
76
|
+
let no = 0
|
|
77
|
+
const josiA: FuncArgs | undefined = (f as FuncListItem).josi
|
|
78
|
+
if (josiA) {
|
|
79
|
+
for (const arg of josiA) {
|
|
80
|
+
const ch = String.fromCharCode(chA + no)
|
|
81
|
+
descFunc += ch
|
|
82
|
+
if (arg.length === 1) { descFunc += arg[0] } else { descFunc += `(${arg.join('|')})` }
|
|
83
|
+
no++
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
descFunc += f.name + '\n'
|
|
87
|
+
}
|
|
88
|
+
throw NakoSyntaxError.fromNode(
|
|
89
|
+
`未解決の単語があります: [${desc}]\n次の命令の可能性があります:\n${descFunc}`, eol)
|
|
90
|
+
}
|
|
91
|
+
this.recentlyCalledFunc = []
|
|
92
|
+
return eol as Ast
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** @returns {Ast | null} */
|
|
96
|
+
ySentence (): Ast | null {
|
|
97
|
+
const map: SourceMap = this.peekSourceMap()
|
|
98
|
+
|
|
99
|
+
// 最初の語句が決まっている構文
|
|
100
|
+
if (this.check('eol')) { return this.yEOL() }
|
|
101
|
+
if (this.check('もし')) { return this.yIF() }
|
|
102
|
+
if (this.check('後判定')) { return this.yAtohantei() }
|
|
103
|
+
if (this.check('エラー監視')) { return this.yTryExcept() }
|
|
104
|
+
if (this.check('逐次実行')) { return this.yTikuji() }
|
|
105
|
+
if (this.accept(['抜ける'])) { return { type: 'break', josi: '', ...map, end: this.peekSourceMap() } }
|
|
106
|
+
if (this.accept(['続ける'])) { return { type: 'continue', josi: '', ...map, end: this.peekSourceMap() } }
|
|
107
|
+
if (this.accept(['require', 'string', '取込'])) { return this.yRequire() }
|
|
108
|
+
if (this.accept(['not', '非同期モード'])) { return this.yASyncMode() }
|
|
109
|
+
if (this.accept(['not', 'DNCLモード'])) { return this.yDNCLMode() }
|
|
110
|
+
if (this.accept(['not', 'string', 'モード設定'])) { return this.ySetGenMode(this.y[1].value) }
|
|
111
|
+
|
|
112
|
+
// 関数呼び出し演算子
|
|
113
|
+
if (this.check2(['func', '←'])) { return this.yCallOp() }
|
|
114
|
+
if (this.check2(['func', 'eq'])) {
|
|
115
|
+
const word: Token = this.get() || NewEmptyToken('?', '?', map.line, map.file || '')
|
|
116
|
+
throw NakoSyntaxError.fromNode(`関数『${word.value}』に代入できません。『←』を使ってください。`, word)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// 先読みして初めて確定する構文
|
|
120
|
+
if (this.accept([this.ySpeedMode])) { return this.y[0] }
|
|
121
|
+
if (this.accept([this.yPerformanceMonitor])) { return this.y[0] }
|
|
122
|
+
if (this.accept([this.yLet])) { return this.y[0] }
|
|
123
|
+
if (this.accept([this.yDefTest])) { return this.y[0] }
|
|
124
|
+
if (this.accept([this.yDefFunc])) { return this.y[0] }
|
|
125
|
+
|
|
126
|
+
// 関数呼び出しの他、各種構文の実装
|
|
127
|
+
if (this.accept([this.yCall])) {
|
|
128
|
+
const c1 = this.y[0]
|
|
129
|
+
if (c1.josi === 'して') { // 連文をblockとして接続する(もし構文、逐次実行構文などのため)
|
|
130
|
+
const c2 = this.ySentence()
|
|
131
|
+
if (c2 !== null) {
|
|
132
|
+
return {
|
|
133
|
+
type: 'block',
|
|
134
|
+
block: [c1, c2],
|
|
135
|
+
josi: c2.josi,
|
|
136
|
+
...map,
|
|
137
|
+
end: this.peekSourceMap()
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return c1
|
|
142
|
+
}
|
|
143
|
+
return null
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** @returns {Ast} */
|
|
147
|
+
yASyncMode (): Ast {
|
|
148
|
+
const map = this.peekSourceMap()
|
|
149
|
+
this.genMode = '非同期モード'
|
|
150
|
+
return { type: 'eol', ...map, end: this.peekSourceMap() }
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** @returns {Ast} */
|
|
154
|
+
yDNCLMode (): Ast {
|
|
155
|
+
const map = this.peekSourceMap()
|
|
156
|
+
// 配列インデックスは1から
|
|
157
|
+
this.arrayIndexFrom = 1
|
|
158
|
+
// 配列アクセスをJSと逆順で指定する
|
|
159
|
+
this.flagReverseArrayIndex = true
|
|
160
|
+
// 配列代入時自動で初期化チェックする
|
|
161
|
+
this.flagCheckArrayInit = true
|
|
162
|
+
return { type: 'eol', ...map, end: this.peekSourceMap() }
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** @returns {Ast} */
|
|
166
|
+
ySetGenMode (mode: string): Ast {
|
|
167
|
+
const map = this.peekSourceMap()
|
|
168
|
+
this.genMode = mode
|
|
169
|
+
return { type: 'eol', ...map, end: this.peekSourceMap() }
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** @returns {Ast} */
|
|
173
|
+
yRequire (): Ast {
|
|
174
|
+
const nameToken = this.y[1]
|
|
175
|
+
const filename = nameToken.value
|
|
176
|
+
const modName = NakoLexer.filenameToModName(filename)
|
|
177
|
+
if (this.modList.indexOf(modName) < 0) {
|
|
178
|
+
// 優先度が最も高いのは modList[0]
|
|
179
|
+
// [memo] モジュールの検索優先度は、下に書くほど高くなる
|
|
180
|
+
const modSelf: string|undefined = this.modList.shift()
|
|
181
|
+
if (modSelf) {
|
|
182
|
+
this.modList.unshift(modName)
|
|
183
|
+
this.modList.unshift(modSelf)
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
type: 'require',
|
|
188
|
+
value: filename,
|
|
189
|
+
josi: '',
|
|
190
|
+
...this.peekSourceMap(),
|
|
191
|
+
end: this.peekSourceMap()
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** @returns {Ast} */
|
|
196
|
+
yBlock (): Ast {
|
|
197
|
+
const map = this.peekSourceMap()
|
|
198
|
+
const blocks = []
|
|
199
|
+
if (this.check('ここから')) { this.get() }
|
|
200
|
+
while (!this.isEOF()) {
|
|
201
|
+
if (this.checkTypes(['違えば', 'ここまで', 'エラー'])) { break }
|
|
202
|
+
if (!this.accept([this.ySentence])) { break }
|
|
203
|
+
blocks.push(this.y[0])
|
|
204
|
+
}
|
|
205
|
+
return { type: 'block', block: blocks, ...map, end: this.peekSourceMap() }
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
yDefFuncReadArgs (): Ast[]|null {
|
|
209
|
+
if (!this.check('(')) { return null }
|
|
210
|
+
const a: Ast[] = []
|
|
211
|
+
this.get() // skip '('
|
|
212
|
+
while (!this.isEOF()) {
|
|
213
|
+
if (this.check(')')) {
|
|
214
|
+
this.get() // skip ''
|
|
215
|
+
break
|
|
216
|
+
}
|
|
217
|
+
const t = this.get()
|
|
218
|
+
if (t) { a.push(t as Ast) }
|
|
219
|
+
if (this.check('comma')) { this.get() }
|
|
220
|
+
}
|
|
221
|
+
return a
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** @returns {Ast | null} */
|
|
225
|
+
yDefTest (): Ast|null {
|
|
226
|
+
return this.yDef('def_test')
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** @returns {Ast | null} */
|
|
230
|
+
yDefFunc (): Ast|null {
|
|
231
|
+
return this.yDef('def_func')
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* @param {string} type
|
|
236
|
+
* @returns {Ast | null}
|
|
237
|
+
*/
|
|
238
|
+
yDef (type: string): Ast|null {
|
|
239
|
+
if (!this.check(type)) {
|
|
240
|
+
return null
|
|
241
|
+
}
|
|
242
|
+
const map = this.peekSourceMap()
|
|
243
|
+
const def = this.get() // ●
|
|
244
|
+
if (!def) { return null }
|
|
245
|
+
let defArgs: Ast[] = []
|
|
246
|
+
if (this.check('(')) { defArgs = this.yDefFuncReadArgs() || [] } // // lexerでも解析しているが再度詳しく
|
|
247
|
+
|
|
248
|
+
const funcName: Token|null = this.get()
|
|
249
|
+
if (!funcName || funcName.type !== 'func') {
|
|
250
|
+
this.logger.debug(this.nodeToStr(funcName, { depth: 0, typeName: '関数' }, true) + 'の宣言でエラー。', funcName)
|
|
251
|
+
throw NakoSyntaxError.fromNode(this.nodeToStr(funcName, { depth: 0, typeName: '関数' }, false) + 'の宣言でエラー。', def)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (this.check('(')) {
|
|
255
|
+
// 関数引数の二重定義
|
|
256
|
+
if (defArgs.length > 0) {
|
|
257
|
+
this.logger.debug(this.nodeToStr(funcName, { depth: 0, typeName: '関数' }, true) + 'の宣言で、引数定義は名前の前か後に一度だけ可能です。', funcName)
|
|
258
|
+
throw NakoSyntaxError.fromNode(this.nodeToStr(funcName, { depth: 0, typeName: '関数' }, false) + 'の宣言で、引数定義は名前の前か後に一度だけ可能です。', funcName)
|
|
259
|
+
}
|
|
260
|
+
defArgs = this.yDefFuncReadArgs() || []
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (this.check('とは')) { this.get() }
|
|
264
|
+
let block: Ast|null = null
|
|
265
|
+
let multiline = false
|
|
266
|
+
let asyncFn = false
|
|
267
|
+
if (this.check('ここから')) { multiline = true }
|
|
268
|
+
if (this.check('eol')) { multiline = true }
|
|
269
|
+
try {
|
|
270
|
+
this.funcLevel++
|
|
271
|
+
this.usedAsyncFn = false
|
|
272
|
+
// ローカル変数を生成
|
|
273
|
+
const backupLocalvars = this.localvars
|
|
274
|
+
this.localvars = { 'それ': { type: 'var', value: '' } }
|
|
275
|
+
|
|
276
|
+
if (multiline) {
|
|
277
|
+
this.saveStack()
|
|
278
|
+
// 関数の引数をローカル変数として登録する
|
|
279
|
+
for (const arg of defArgs) {
|
|
280
|
+
const fnName: string = (arg.value) ? arg.value + '' : ''
|
|
281
|
+
this.localvars[fnName] = { 'type': 'var', 'value': '' }
|
|
282
|
+
}
|
|
283
|
+
block = this.yBlock()
|
|
284
|
+
if (this.check('ここまで')) { this.get() } else { throw NakoSyntaxError.fromNode('『ここまで』がありません。関数定義の末尾に必要です。', def) }
|
|
285
|
+
this.loadStack()
|
|
286
|
+
} else {
|
|
287
|
+
this.saveStack()
|
|
288
|
+
block = this.ySentence()
|
|
289
|
+
this.loadStack()
|
|
290
|
+
}
|
|
291
|
+
this.funcLevel--
|
|
292
|
+
asyncFn = this.usedAsyncFn
|
|
293
|
+
this.localvars = backupLocalvars
|
|
294
|
+
} catch (err: any) {
|
|
295
|
+
this.logger.debug(this.nodeToStr(funcName, { depth: 0, typeName: '関数' }, true) +
|
|
296
|
+
'の定義で以下のエラーがありました。\n' + err.message, def)
|
|
297
|
+
throw NakoSyntaxError.fromNode(this.nodeToStr(funcName, { depth: 0, typeName: '関数' }, false) +
|
|
298
|
+
'の定義で以下のエラーがありました。\n' + err.message, def)
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
return {
|
|
302
|
+
type,
|
|
303
|
+
name: funcName,
|
|
304
|
+
args: defArgs,
|
|
305
|
+
block: block || [],
|
|
306
|
+
asyncFn,
|
|
307
|
+
josi: '',
|
|
308
|
+
...map,
|
|
309
|
+
end: this.peekSourceMap()
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/** @returns {Ast | null} */
|
|
314
|
+
yIFCond (): Ast | null { // もしの条件の取得
|
|
315
|
+
const map = this.peekSourceMap()
|
|
316
|
+
let a: Ast | null = this.yGetArg()
|
|
317
|
+
if (!a) { return null }
|
|
318
|
+
// console.log('yIFCond=', a, this.peek())
|
|
319
|
+
|
|
320
|
+
// チェック : AがBならば
|
|
321
|
+
if (a.josi === 'が') {
|
|
322
|
+
const tmpI = this.index
|
|
323
|
+
const b = this.yGetArg()
|
|
324
|
+
const naraba = this.get()
|
|
325
|
+
if ((b && b.type !== 'func') && (naraba && naraba.type === 'ならば')) {
|
|
326
|
+
return {
|
|
327
|
+
type: 'op',
|
|
328
|
+
operator: (naraba.value === 'でなければ') ? 'noteq' : 'eq',
|
|
329
|
+
left: a,
|
|
330
|
+
right: b,
|
|
331
|
+
josi: '',
|
|
332
|
+
...map,
|
|
333
|
+
end: this.peekSourceMap()
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
this.index = tmpI
|
|
338
|
+
}
|
|
339
|
+
if (a.josi !== '') {
|
|
340
|
+
// もし文で関数呼び出しがある場合
|
|
341
|
+
this.stack.push(a)
|
|
342
|
+
a = this.yCall()
|
|
343
|
+
}
|
|
344
|
+
// (ならば|でなければ)を確認
|
|
345
|
+
if (!this.check('ならば')) {
|
|
346
|
+
const smap: Ast = a || { type: '?', ...map }
|
|
347
|
+
this.logger.debug(
|
|
348
|
+
'もし文で『ならば』がないか、条件が複雑過ぎます。' + this.nodeToStr(this.peek(), { depth: 1 }, false) + 'の直前に『ならば』を書いてください。', smap)
|
|
349
|
+
throw NakoSyntaxError.fromNode(
|
|
350
|
+
'もし文で『ならば』がないか、条件が複雑過ぎます。' + this.nodeToStr(this.peek(), { depth: 1 }, false) + 'の直前に『ならば』を書いてください。', smap)
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
const naraba = this.get()
|
|
354
|
+
if (naraba && naraba.value === 'でなければ') {
|
|
355
|
+
a = {
|
|
356
|
+
type: 'not',
|
|
357
|
+
value: a,
|
|
358
|
+
josi: '',
|
|
359
|
+
...map,
|
|
360
|
+
end: this.peekSourceMap()
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return a
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/** @returns {Ast | null} */
|
|
368
|
+
yIF (): Ast | null {
|
|
369
|
+
const map = this.peekSourceMap()
|
|
370
|
+
if (!this.check('もし')) { return null }
|
|
371
|
+
const mosi:Token|null = this.get() // skip もし
|
|
372
|
+
if (mosi == null) { return null }
|
|
373
|
+
while (this.check('comma')) { this.get() } // skip comma
|
|
374
|
+
let cond: Ast|null = null
|
|
375
|
+
try {
|
|
376
|
+
cond = this.yIFCond()
|
|
377
|
+
} catch (err: any) {
|
|
378
|
+
throw NakoSyntaxError.fromNode('『もし』文の条件で次のエラーがあります。\n' + err.message, mosi)
|
|
379
|
+
}
|
|
380
|
+
if (cond === null) {
|
|
381
|
+
throw NakoSyntaxError.fromNode('『もし』文で条件の指定が空です。', mosi)
|
|
382
|
+
}
|
|
383
|
+
let trueBlock: Ast|null = null
|
|
384
|
+
let falseBlock: Ast|null = null
|
|
385
|
+
let tanbun = false
|
|
386
|
+
|
|
387
|
+
// True Block
|
|
388
|
+
if (this.check('eol')) {
|
|
389
|
+
trueBlock = this.yBlock()
|
|
390
|
+
} else {
|
|
391
|
+
trueBlock = this.ySentence()
|
|
392
|
+
tanbun = true
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// skip EOL
|
|
396
|
+
while (this.check('eol')) { this.get() }
|
|
397
|
+
|
|
398
|
+
// Flase Block
|
|
399
|
+
if (this.check('違えば')) {
|
|
400
|
+
this.get() // skip 違えば
|
|
401
|
+
while (this.check('comma')) { this.get() }
|
|
402
|
+
if (this.check('eol')) {
|
|
403
|
+
falseBlock = this.yBlock()
|
|
404
|
+
} else {
|
|
405
|
+
falseBlock = this.ySentence()
|
|
406
|
+
tanbun = true
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
if (tanbun === false) {
|
|
411
|
+
if (this.check('ここまで')) {
|
|
412
|
+
this.get()
|
|
413
|
+
} else {
|
|
414
|
+
throw NakoSyntaxError.fromNode('『もし』文で『ここまで』がありません。', mosi)
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
return {
|
|
418
|
+
type: 'if',
|
|
419
|
+
expr: cond || [],
|
|
420
|
+
block: trueBlock || [],
|
|
421
|
+
false_block: falseBlock || [],
|
|
422
|
+
josi: '',
|
|
423
|
+
...map,
|
|
424
|
+
end: this.peekSourceMap()
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
ySpeedMode (): Ast | null {
|
|
429
|
+
const map: SourceMap = this.peekSourceMap()
|
|
430
|
+
if (!this.check2(['string', '実行速度優先'])) {
|
|
431
|
+
return null
|
|
432
|
+
}
|
|
433
|
+
const optionNode: Token|null = this.get()
|
|
434
|
+
this.get()
|
|
435
|
+
let val = ''
|
|
436
|
+
if (optionNode && optionNode.value) { val = optionNode.value } else { return null }
|
|
437
|
+
|
|
438
|
+
const options: {[key: string]: boolean} = { 行番号無し: false, 暗黙の型変換無し: false, 強制ピュア: false, それ無効: false }
|
|
439
|
+
for (const name of val.split('/')) {
|
|
440
|
+
// 全て有効化
|
|
441
|
+
if (name === '全て') {
|
|
442
|
+
for (const k of Object.keys(options)) {
|
|
443
|
+
options[k] = true
|
|
444
|
+
}
|
|
445
|
+
break
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// 個別に有効化
|
|
449
|
+
if (Object.keys(options).includes(name)) {
|
|
450
|
+
options[name] = true
|
|
451
|
+
} else {
|
|
452
|
+
// 互換性を考えて、警告に留める。
|
|
453
|
+
this.logger.warn(`実行速度優先文のオプション『${name}』は存在しません。`, optionNode)
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
let multiline = false
|
|
458
|
+
if (this.check('ここから')) {
|
|
459
|
+
this.get()
|
|
460
|
+
multiline = true
|
|
461
|
+
} else if (this.check('eol')) {
|
|
462
|
+
multiline = true
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
let block = null
|
|
466
|
+
if (multiline) {
|
|
467
|
+
block = this.yBlock()
|
|
468
|
+
if (this.check('ここまで')) { this.get() }
|
|
469
|
+
} else {
|
|
470
|
+
block = this.ySentence()
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
return {
|
|
474
|
+
type: 'speed_mode',
|
|
475
|
+
options,
|
|
476
|
+
block: block || [],
|
|
477
|
+
josi: '',
|
|
478
|
+
...map
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
yPerformanceMonitor (): Ast|null {
|
|
483
|
+
const map = this.peekSourceMap()
|
|
484
|
+
if (!this.check2(['string', 'パフォーマンスモニタ適用'])) {
|
|
485
|
+
return null
|
|
486
|
+
}
|
|
487
|
+
const optionNode = this.get()
|
|
488
|
+
if (!optionNode) { return null }
|
|
489
|
+
this.get()
|
|
490
|
+
|
|
491
|
+
const options: {[key: string]: boolean} = { ユーザ関数: false, システム関数本体: false, システム関数: false }
|
|
492
|
+
for (const name of optionNode.value.split('/')) {
|
|
493
|
+
// 全て有効化
|
|
494
|
+
if (name === '全て') {
|
|
495
|
+
for (const k of Object.keys(options)) {
|
|
496
|
+
options[k] = true
|
|
497
|
+
}
|
|
498
|
+
break
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
// 個別に有効化
|
|
502
|
+
if (Object.keys(options).includes(name)) {
|
|
503
|
+
options[name] = true
|
|
504
|
+
} else {
|
|
505
|
+
// 互換性を考えて、警告に留める。
|
|
506
|
+
this.logger.warn(`パフォーマンスモニタ適用文のオプション『${name}』は存在しません。`, optionNode)
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
let multiline = false
|
|
511
|
+
if (this.check('ここから')) {
|
|
512
|
+
this.get()
|
|
513
|
+
multiline = true
|
|
514
|
+
} else if (this.check('eol')) {
|
|
515
|
+
multiline = true
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
let block = null
|
|
519
|
+
if (multiline) {
|
|
520
|
+
block = this.yBlock()
|
|
521
|
+
if (this.check('ここまで')) { this.get() }
|
|
522
|
+
} else {
|
|
523
|
+
block = this.ySentence()
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
return {
|
|
527
|
+
type: 'performance_monitor',
|
|
528
|
+
options,
|
|
529
|
+
block: block || [],
|
|
530
|
+
josi: '',
|
|
531
|
+
...map
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/** (非推奨) 「逐次実行」構文 @returns {Ast | null} */
|
|
536
|
+
yTikuji (): Ast|null {
|
|
537
|
+
const map = this.peekSourceMap()
|
|
538
|
+
if (!this.check('逐次実行')) { return null }
|
|
539
|
+
const tikuji = this.getCur() // skip 逐次実行
|
|
540
|
+
this.logger.warn('『逐次実行』構文の使用は非推奨になりました(https://nadesi.com/v3/doc/go.php?944)。', tikuji)
|
|
541
|
+
const blocks: Ast[] = []
|
|
542
|
+
let errorBlock = null
|
|
543
|
+
if (!tikuji || !this.check('eol')) {
|
|
544
|
+
throw NakoSyntaxError.fromNode('『逐次実行』の直後は改行が必要です。', tikuji)
|
|
545
|
+
}
|
|
546
|
+
// ブロックを読む
|
|
547
|
+
for (;;) {
|
|
548
|
+
if (this.check('ここまで')) { break }
|
|
549
|
+
if (this.check('eol')) {
|
|
550
|
+
this.get() // skip EOL
|
|
551
|
+
continue
|
|
552
|
+
}
|
|
553
|
+
if (this.check2(['エラー', 'ならば'])) {
|
|
554
|
+
this.get() // skip エラー
|
|
555
|
+
this.get() // skip ならば
|
|
556
|
+
errorBlock = this.yBlock()
|
|
557
|
+
break
|
|
558
|
+
}
|
|
559
|
+
let block = null
|
|
560
|
+
// 「先に」「次に」句はブロック宣言 #717 (ただしブロック以外も可能)
|
|
561
|
+
if (this.check('先に') || this.check('次に')) {
|
|
562
|
+
const tugini = this.get() // skip 先に | 次に
|
|
563
|
+
if (this.check('comma')) { this.get() }
|
|
564
|
+
if (this.check('eol')) { // block
|
|
565
|
+
block = this.yBlock()
|
|
566
|
+
if (!this.check('ここまで')) {
|
|
567
|
+
let tuginiType = '次に'
|
|
568
|
+
if (tugini != null) { tuginiType = tugini.type }
|
|
569
|
+
throw NakoSyntaxError.fromNode(`『${tuginiType}』...『ここまで』を対応させてください。`, map)
|
|
570
|
+
}
|
|
571
|
+
this.get() // skip 'ここまで'
|
|
572
|
+
} else { // line
|
|
573
|
+
block = this.ySentence()
|
|
574
|
+
}
|
|
575
|
+
} else {
|
|
576
|
+
block = this.ySentence()
|
|
577
|
+
}
|
|
578
|
+
// add block
|
|
579
|
+
if (block != null) { blocks.push(block) }
|
|
580
|
+
}
|
|
581
|
+
if (!this.check('ここまで')) {
|
|
582
|
+
console.log(blocks, this.peek())
|
|
583
|
+
throw NakoSyntaxError.fromNode('『逐次実行』...『ここまで』を対応させてください。', tikuji)
|
|
584
|
+
}
|
|
585
|
+
this.get() // skip 'ここまで'
|
|
586
|
+
return {
|
|
587
|
+
type: 'tikuji',
|
|
588
|
+
blocks: blocks || [],
|
|
589
|
+
errorBlock: errorBlock || [],
|
|
590
|
+
josi: '',
|
|
591
|
+
...map,
|
|
592
|
+
end: this.peekSourceMap()
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* 1つ目の値を与え、その後に続く計算式を取得し、優先規則に沿って並び替えして戻す
|
|
598
|
+
* @param {Ast} firstValue
|
|
599
|
+
*/
|
|
600
|
+
yGetArgOperator (firstValue: Ast): Ast|null {
|
|
601
|
+
const args:Ast[] = [firstValue]
|
|
602
|
+
while (!this.isEOF()) {
|
|
603
|
+
// 演算子がある?
|
|
604
|
+
let op = this.peek()
|
|
605
|
+
if (op && opPriority[op.type]) {
|
|
606
|
+
op = this.getCur()
|
|
607
|
+
args.push(op as Ast)
|
|
608
|
+
// 演算子後の値を取得
|
|
609
|
+
const v = this.yValue()
|
|
610
|
+
if (v === null) {
|
|
611
|
+
throw NakoSyntaxError.fromNode(
|
|
612
|
+
`計算式で演算子『${op.value}』後に値がありません`,
|
|
613
|
+
firstValue)
|
|
614
|
+
}
|
|
615
|
+
args.push(v)
|
|
616
|
+
continue
|
|
617
|
+
}
|
|
618
|
+
break
|
|
619
|
+
}
|
|
620
|
+
if (args.length === 0) { return null }
|
|
621
|
+
if (args.length === 1) { return args[0] }
|
|
622
|
+
return this.infixToAST(args)
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
yGetArg (): Ast|null {
|
|
626
|
+
// 値を一つ読む
|
|
627
|
+
const value1 = this.yValue()
|
|
628
|
+
if (value1 === null) { return null }
|
|
629
|
+
// 計算式がある場合を考慮
|
|
630
|
+
return this.yGetArgOperator(value1)
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
infixToPolish (list: Ast[]): Ast[] {
|
|
634
|
+
// 中間記法から逆ポーランドに変換
|
|
635
|
+
const priority = (t: Ast) => {
|
|
636
|
+
if (opPriority[t.type]) { return opPriority[t.type] }
|
|
637
|
+
return 10
|
|
638
|
+
}
|
|
639
|
+
const stack: Ast[] = []
|
|
640
|
+
const polish: Ast[] = []
|
|
641
|
+
while (list.length > 0) {
|
|
642
|
+
const t = list.shift()
|
|
643
|
+
if (!t) { break }
|
|
644
|
+
while (stack.length > 0) { // 優先順位を見て移動する
|
|
645
|
+
const sTop = stack[stack.length - 1]
|
|
646
|
+
if (priority(t) > priority(sTop)) { break }
|
|
647
|
+
const tpop = stack.pop()
|
|
648
|
+
if (!tpop) {
|
|
649
|
+
this.logger.error('計算式に間違いがあります。', t)
|
|
650
|
+
break
|
|
651
|
+
}
|
|
652
|
+
polish.push(tpop)
|
|
653
|
+
}
|
|
654
|
+
stack.push(t)
|
|
655
|
+
}
|
|
656
|
+
// 残った要素を積み替える
|
|
657
|
+
while (stack.length > 0) {
|
|
658
|
+
const t = stack.pop()
|
|
659
|
+
if (t) { polish.push(t) }
|
|
660
|
+
}
|
|
661
|
+
return polish
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/** @returns {Ast | null} */
|
|
665
|
+
infixToAST (list: Ast[]): Ast | null {
|
|
666
|
+
if (list.length === 0) { return null }
|
|
667
|
+
// 逆ポーランドを構文木に
|
|
668
|
+
const josi = list[list.length - 1].josi
|
|
669
|
+
const node = list[list.length - 1]
|
|
670
|
+
const polish = this.infixToPolish(list)
|
|
671
|
+
/** @type {Ast[]} */
|
|
672
|
+
const stack = []
|
|
673
|
+
for (const t of polish) {
|
|
674
|
+
if (!opPriority[t.type]) { // 演算子ではない
|
|
675
|
+
stack.push(t)
|
|
676
|
+
continue
|
|
677
|
+
}
|
|
678
|
+
const b:Ast|undefined = stack.pop()
|
|
679
|
+
const a:Ast|undefined = stack.pop()
|
|
680
|
+
if (a === undefined || b === undefined) {
|
|
681
|
+
this.logger.debug('--- 計算式(逆ポーランド) ---\n' + JSON.stringify(polish))
|
|
682
|
+
throw NakoSyntaxError.fromNode('計算式でエラー', node)
|
|
683
|
+
}
|
|
684
|
+
/** @type {Ast} */
|
|
685
|
+
const op:Ast = {
|
|
686
|
+
type: 'op',
|
|
687
|
+
operator: t.type,
|
|
688
|
+
left: a,
|
|
689
|
+
right: b,
|
|
690
|
+
josi,
|
|
691
|
+
startOffset: a.startOffset,
|
|
692
|
+
endOffset: a.endOffset,
|
|
693
|
+
line: a.line,
|
|
694
|
+
column: a.column,
|
|
695
|
+
file: a.file
|
|
696
|
+
}
|
|
697
|
+
stack.push(op)
|
|
698
|
+
}
|
|
699
|
+
const ans = stack.pop()
|
|
700
|
+
if (!ans) { return null }
|
|
701
|
+
return ans
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
yGetArgParen (y: Ast[]): Ast[] { // C言語風呼び出しでカッコの中を取得
|
|
705
|
+
let isClose = false
|
|
706
|
+
const si = this.stack.length
|
|
707
|
+
while (!this.isEOF()) {
|
|
708
|
+
if (this.check(')')) {
|
|
709
|
+
isClose = true
|
|
710
|
+
break
|
|
711
|
+
}
|
|
712
|
+
const v = this.yGetArg()
|
|
713
|
+
if (v) {
|
|
714
|
+
this.pushStack(v)
|
|
715
|
+
if (this.check('comma')) { this.get() }
|
|
716
|
+
continue
|
|
717
|
+
}
|
|
718
|
+
break
|
|
719
|
+
}
|
|
720
|
+
if (!isClose) {
|
|
721
|
+
throw NakoSyntaxError.fromNode(`C風関数『${y[0].value}』でカッコが閉じていません`, y[0])
|
|
722
|
+
}
|
|
723
|
+
const a: Ast[] = []
|
|
724
|
+
while (si < this.stack.length) {
|
|
725
|
+
const v = this.popStack()
|
|
726
|
+
if (v) { a.unshift(v) }
|
|
727
|
+
}
|
|
728
|
+
return a
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
/** @returns {Ast | null} */
|
|
732
|
+
yRepeatTime (): Ast|null {
|
|
733
|
+
const map = this.peekSourceMap()
|
|
734
|
+
if (!this.check('回')) { return null }
|
|
735
|
+
this.get() // skip '回'
|
|
736
|
+
if (this.check('comma')) { this.get() } // skip comma
|
|
737
|
+
if (this.check('繰返')) { this.get() } // skip 'N回、繰り返す' (#924)
|
|
738
|
+
let num = this.popStack([])
|
|
739
|
+
let multiline = false
|
|
740
|
+
let block = null
|
|
741
|
+
if (num === null) { num = { type: 'word', value: 'それ', josi: '', ...map, end: this.peekSourceMap() } }
|
|
742
|
+
if (this.check('comma')) { this.get() }
|
|
743
|
+
if (this.check('ここから')) {
|
|
744
|
+
this.get()
|
|
745
|
+
multiline = true
|
|
746
|
+
} else if (this.check('eol')) {
|
|
747
|
+
multiline = true
|
|
748
|
+
}
|
|
749
|
+
if (multiline) { // multiline
|
|
750
|
+
block = this.yBlock()
|
|
751
|
+
if (this.check('ここまで')) { this.get() } else { throw NakoSyntaxError.fromNode('『ここまで』がありません。『回』...『ここまで』を対応させてください。', map) }
|
|
752
|
+
} else {
|
|
753
|
+
// singleline
|
|
754
|
+
block = this.ySentence()
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
return {
|
|
758
|
+
type: 'repeat_times',
|
|
759
|
+
value: num,
|
|
760
|
+
block: block || [],
|
|
761
|
+
josi: '',
|
|
762
|
+
...map,
|
|
763
|
+
end: this.peekSourceMap()
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
/** @returns {Ast | null} */
|
|
768
|
+
yWhile (): Ast | null {
|
|
769
|
+
const map = this.peekSourceMap()
|
|
770
|
+
if (!this.check('間')) { return null }
|
|
771
|
+
this.get() // skip '間'
|
|
772
|
+
while (this.check('comma')) { this.get() } // skip ','
|
|
773
|
+
if (this.check('繰返')) { this.get() } // skip '繰り返す' #927
|
|
774
|
+
const cond = this.popStack()
|
|
775
|
+
if (cond === null) {
|
|
776
|
+
throw NakoSyntaxError.fromNode('『間』で条件がありません。', map)
|
|
777
|
+
}
|
|
778
|
+
if (this.check('comma')) { this.get() }
|
|
779
|
+
if (!this.checkTypes(['ここから', 'eol'])) {
|
|
780
|
+
throw NakoSyntaxError.fromNode('『間』の直後は改行が必要です', map)
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
const block = this.yBlock()
|
|
784
|
+
if (this.check('ここまで')) { this.get() }
|
|
785
|
+
return {
|
|
786
|
+
type: 'while',
|
|
787
|
+
cond,
|
|
788
|
+
block,
|
|
789
|
+
josi: '',
|
|
790
|
+
...map,
|
|
791
|
+
end: this.peekSourceMap()
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
/** @returns {Ast | null} */
|
|
796
|
+
yAtohantei (): Ast|null {
|
|
797
|
+
const map = this.peekSourceMap()
|
|
798
|
+
if (this.check('後判定')) { this.get() } // skip 後判定
|
|
799
|
+
if (this.check('繰返')) { this.get() } // skip 繰り返す
|
|
800
|
+
if (this.check('ここから')) { this.get() }
|
|
801
|
+
const block = this.yBlock()
|
|
802
|
+
if (this.check('ここまで')) { this.get() }
|
|
803
|
+
if (this.check('comma')) { this.get() }
|
|
804
|
+
let cond = this.yGetArg() // 条件
|
|
805
|
+
let bUntil = false
|
|
806
|
+
const t = this.peek()
|
|
807
|
+
if (t && t.value === 'なる' && (t.josi === 'まで' || t.josi === 'までの')) {
|
|
808
|
+
this.get() // skip なるまで
|
|
809
|
+
bUntil = true
|
|
810
|
+
}
|
|
811
|
+
if (this.check('間')) { this.get() } // skip 間
|
|
812
|
+
if (bUntil) { // 条件を反転する
|
|
813
|
+
cond = {
|
|
814
|
+
type: 'not',
|
|
815
|
+
value: cond,
|
|
816
|
+
josi: '',
|
|
817
|
+
...map,
|
|
818
|
+
end: this.peekSourceMap()
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
return {
|
|
822
|
+
type: 'atohantei',
|
|
823
|
+
cond: cond || [],
|
|
824
|
+
block,
|
|
825
|
+
josi: '',
|
|
826
|
+
...map,
|
|
827
|
+
end: this.peekSourceMap()
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
/** @returns {Ast | null} */
|
|
832
|
+
yFor (): Ast|null {
|
|
833
|
+
const map = this.peekSourceMap()
|
|
834
|
+
if (this.check('繰返') || this.check('増繰返') || this.check('減繰返')) {
|
|
835
|
+
// pass
|
|
836
|
+
} else {
|
|
837
|
+
return null
|
|
838
|
+
}
|
|
839
|
+
const kurikaesu: Token = this.getCur() // skip 繰り返す
|
|
840
|
+
// スタックに(増や|減ら)してがある?
|
|
841
|
+
const incdec = this.stack.pop()
|
|
842
|
+
if (incdec) {
|
|
843
|
+
if (incdec.type === 'word' && (incdec.value === '増' || incdec.value === '減')) {
|
|
844
|
+
kurikaesu.type = incdec.value + kurikaesu.type
|
|
845
|
+
// ↑ typeを増繰返 | 減繰返 に変換
|
|
846
|
+
} else {
|
|
847
|
+
// 普通の繰り返しの場合
|
|
848
|
+
this.stack.push(incdec) // 違ったので改めて追加
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
let vInc = null
|
|
852
|
+
if (kurikaesu.type === '増繰返' || kurikaesu.type === '減繰返') {
|
|
853
|
+
vInc = this.popStack(['ずつ'])
|
|
854
|
+
}
|
|
855
|
+
const vTo = this.popStack(['まで'])
|
|
856
|
+
const vFrom = this.popStack(['から'])
|
|
857
|
+
const word = this.popStack(['を', 'で'])
|
|
858
|
+
if (vFrom === null || vTo === null) {
|
|
859
|
+
throw NakoSyntaxError.fromNode('『繰り返す』文でAからBまでの指定がありません。', kurikaesu)
|
|
860
|
+
}
|
|
861
|
+
if (this.check('comma')) { this.get() } // skip comma
|
|
862
|
+
let multiline = false
|
|
863
|
+
if (this.check('ここから')) {
|
|
864
|
+
multiline = true
|
|
865
|
+
this.get()
|
|
866
|
+
} else if (this.check('eol')) {
|
|
867
|
+
multiline = true
|
|
868
|
+
this.get()
|
|
869
|
+
}
|
|
870
|
+
let block = null
|
|
871
|
+
if (multiline) {
|
|
872
|
+
block = this.yBlock()
|
|
873
|
+
if (this.check('ここまで')) {
|
|
874
|
+
this.get()
|
|
875
|
+
} else {
|
|
876
|
+
throw NakoSyntaxError.fromNode('『ここまで』がありません。『繰り返す』...『ここまで』を対応させてください。', map)
|
|
877
|
+
}
|
|
878
|
+
} else { block = this.ySentence() }
|
|
879
|
+
|
|
880
|
+
return {
|
|
881
|
+
type: 'for',
|
|
882
|
+
from: vFrom,
|
|
883
|
+
to: vTo,
|
|
884
|
+
inc: vInc,
|
|
885
|
+
word,
|
|
886
|
+
block: block || [],
|
|
887
|
+
josi: '',
|
|
888
|
+
...map,
|
|
889
|
+
end: this.peekSourceMap()
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
/** @returns {Ast | null} */
|
|
894
|
+
yReturn (): Ast|null {
|
|
895
|
+
const map = this.peekSourceMap()
|
|
896
|
+
if (!this.check('戻る')) { return null }
|
|
897
|
+
this.get() // skip '戻る'
|
|
898
|
+
const v = this.popStack(['で', 'を'])
|
|
899
|
+
if (this.stack.length > 0) {
|
|
900
|
+
throw NakoSyntaxError.fromNode('『戻』文の直前に未解決の引数があります。『(式)を戻す』のように式をカッコで括ってください。', map)
|
|
901
|
+
}
|
|
902
|
+
return {
|
|
903
|
+
type: 'return',
|
|
904
|
+
value: v,
|
|
905
|
+
josi: '',
|
|
906
|
+
...map,
|
|
907
|
+
end: this.peekSourceMap()
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
/** @returns {Ast | null} */
|
|
912
|
+
yForEach (): Ast|null {
|
|
913
|
+
const map = this.peekSourceMap()
|
|
914
|
+
if (!this.check('反復')) { return null }
|
|
915
|
+
this.get() // skip '反復'
|
|
916
|
+
while (this.check('comma')) { this.get() } // skip ','
|
|
917
|
+
const target = this.popStack(['を'])
|
|
918
|
+
const name = this.popStack(['で'])
|
|
919
|
+
let block = null
|
|
920
|
+
let multiline = false
|
|
921
|
+
if (this.check('ここから')) {
|
|
922
|
+
multiline = true
|
|
923
|
+
this.get()
|
|
924
|
+
} else if (this.check('eol')) { multiline = true }
|
|
925
|
+
|
|
926
|
+
if (multiline) {
|
|
927
|
+
block = this.yBlock()
|
|
928
|
+
if (this.check('ここまで')) { this.get() }
|
|
929
|
+
} else { block = this.ySentence() }
|
|
930
|
+
|
|
931
|
+
return {
|
|
932
|
+
type: 'foreach',
|
|
933
|
+
name,
|
|
934
|
+
target,
|
|
935
|
+
block: block || [],
|
|
936
|
+
josi: '',
|
|
937
|
+
...map,
|
|
938
|
+
end: this.peekSourceMap()
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
/** 条件分岐構文 */
|
|
943
|
+
ySwitch (): Ast | null {
|
|
944
|
+
const map = this.peekSourceMap()
|
|
945
|
+
if (!this.check('条件分岐')) { return null }
|
|
946
|
+
const joukenbunki = this.get() // skip '条件分岐'
|
|
947
|
+
if (!joukenbunki) { return null }
|
|
948
|
+
const eol = this.get() // skip 'eol'
|
|
949
|
+
if (!eol) { return null }
|
|
950
|
+
const value = this.popStack(['で'])
|
|
951
|
+
if (!value) {
|
|
952
|
+
throw NakoSyntaxError.fromNode('『(値)で条件分岐』のように記述してください。', joukenbunki)
|
|
953
|
+
}
|
|
954
|
+
if (eol.type !== 'eol') {
|
|
955
|
+
throw NakoSyntaxError.fromNode('『条件分岐』の直後は改行してください。', joukenbunki)
|
|
956
|
+
}
|
|
957
|
+
let isDefaultClause = false // 「違えば」内かどうか
|
|
958
|
+
let skippedKokomade = false
|
|
959
|
+
const cases: any[] = []
|
|
960
|
+
while (!this.isEOF()) {
|
|
961
|
+
if (this.check('ここまで')) {
|
|
962
|
+
if (skippedKokomade) {
|
|
963
|
+
throw NakoSyntaxError.fromNode('『条件分岐』は『(条件)ならば〜ここまで』と記述してください。', joukenbunki)
|
|
964
|
+
}
|
|
965
|
+
this.get() // skip ここまで
|
|
966
|
+
break
|
|
967
|
+
}
|
|
968
|
+
if (this.check('eol')) {
|
|
969
|
+
this.get()
|
|
970
|
+
continue
|
|
971
|
+
}
|
|
972
|
+
if (isDefaultClause) {
|
|
973
|
+
throw NakoSyntaxError.fromNode('『条件分岐』で『違えば〜ここまで』の後に処理を続けることは出来ません。', joukenbunki)
|
|
974
|
+
}
|
|
975
|
+
// 違えば?
|
|
976
|
+
let cond: Ast|null = null
|
|
977
|
+
const condToken: Token|null = this.peek()
|
|
978
|
+
if (condToken && condToken.type === '違えば') {
|
|
979
|
+
// 違えば
|
|
980
|
+
skippedKokomade = false
|
|
981
|
+
isDefaultClause = true
|
|
982
|
+
cond = this.get() as Ast // skip 違えば
|
|
983
|
+
if (this.check('comma')) { this.get() } // skip ','
|
|
984
|
+
} else {
|
|
985
|
+
// ***ならば
|
|
986
|
+
if (skippedKokomade) {
|
|
987
|
+
throw NakoSyntaxError.fromNode('『条件分岐』は『(条件)ならば〜ここまで』と記述してください。', joukenbunki)
|
|
988
|
+
}
|
|
989
|
+
// 「**ならば」を得る
|
|
990
|
+
cond = this.yValue()
|
|
991
|
+
if (!cond) {
|
|
992
|
+
throw NakoSyntaxError.fromNode('『条件分岐』は『(条件)ならば〜ここまで』と記述してください。', joukenbunki)
|
|
993
|
+
}
|
|
994
|
+
const naraba = this.get() // skip ならば
|
|
995
|
+
if (!naraba || naraba.type !== 'ならば') {
|
|
996
|
+
throw NakoSyntaxError.fromNode('『条件分岐』で条件は**ならばと記述してください。', joukenbunki)
|
|
997
|
+
}
|
|
998
|
+
if (this.check('comma')) { this.get() } // skip ','
|
|
999
|
+
}
|
|
1000
|
+
// 条件にあったときに実行すること
|
|
1001
|
+
const condBlock = this.yBlock()
|
|
1002
|
+
const kokomade = this.peek()
|
|
1003
|
+
if (kokomade && kokomade.type === 'ここまで') {
|
|
1004
|
+
this.get() // skip ここまで
|
|
1005
|
+
} else {
|
|
1006
|
+
if (isDefaultClause) {
|
|
1007
|
+
throw NakoSyntaxError.fromNode('『条件分岐』は『違えば〜ここまで』と記述してください。', joukenbunki)
|
|
1008
|
+
}
|
|
1009
|
+
// 次が「違えば」の場合に限り、「もし〜ここまで」の「ここまで」を省略できる
|
|
1010
|
+
skippedKokomade = true
|
|
1011
|
+
}
|
|
1012
|
+
cases.push([cond, condBlock])
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
return {
|
|
1016
|
+
type: 'switch',
|
|
1017
|
+
value,
|
|
1018
|
+
cases: cases || [],
|
|
1019
|
+
josi: '',
|
|
1020
|
+
...map,
|
|
1021
|
+
end: this.peekSourceMap()
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
/** 無名関数 */
|
|
1026
|
+
yMumeiFunc (): Ast | null { // 無名関数の定義
|
|
1027
|
+
const map = this.peekSourceMap()
|
|
1028
|
+
if (!this.check('def_func')) { return null }
|
|
1029
|
+
const def = this.get()
|
|
1030
|
+
if (!def) { return null }
|
|
1031
|
+
let args: Ast[] = []
|
|
1032
|
+
// 「,」を飛ばす
|
|
1033
|
+
if (this.check('comma')) { this.get() }
|
|
1034
|
+
// 関数の引数定義は省略できる
|
|
1035
|
+
if (this.check('(')) { args = this.yDefFuncReadArgs() || [] }
|
|
1036
|
+
// 「,」を飛ばす
|
|
1037
|
+
if (this.check('comma')) { this.get() }
|
|
1038
|
+
// ブロックを読む
|
|
1039
|
+
this.funcLevel++
|
|
1040
|
+
this.saveStack()
|
|
1041
|
+
const block = this.yBlock()
|
|
1042
|
+
// 末尾の「ここまで」をチェック - もしなければエラーにする #1045
|
|
1043
|
+
if (!this.check('ここまで')) {
|
|
1044
|
+
throw NakoSyntaxError.fromNode('『ここまで』がありません。『には』構文か無名関数の末尾に『ここまで』が必要です。', map)
|
|
1045
|
+
}
|
|
1046
|
+
this.get() // skip ここまで
|
|
1047
|
+
this.loadStack()
|
|
1048
|
+
this.funcLevel--
|
|
1049
|
+
return {
|
|
1050
|
+
type: 'func_obj',
|
|
1051
|
+
args,
|
|
1052
|
+
block,
|
|
1053
|
+
meta: def.meta,
|
|
1054
|
+
josi: '',
|
|
1055
|
+
...map,
|
|
1056
|
+
end: this.peekSourceMap()
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
/** 代入構文 */
|
|
1061
|
+
yDainyu (): Ast | null {
|
|
1062
|
+
const map = this.peekSourceMap()
|
|
1063
|
+
const dainyu = this.get() // 代入
|
|
1064
|
+
if (dainyu === null) { return null }
|
|
1065
|
+
const value = this.popStack(['を'])
|
|
1066
|
+
const word: Ast|null = this.popStack(['へ', 'に'])
|
|
1067
|
+
if (!word || (word.type !== 'word' && word.type !== 'func' && word.type !== '配列参照')) {
|
|
1068
|
+
throw NakoSyntaxError.fromNode('代入文で代入先の変数が見当たりません。『(変数名)に(値)を代入』のように使います。', dainyu)
|
|
1069
|
+
}
|
|
1070
|
+
// 配列への代入
|
|
1071
|
+
if (word.type === '配列参照') {
|
|
1072
|
+
return {
|
|
1073
|
+
type: 'let_array',
|
|
1074
|
+
name: word.name,
|
|
1075
|
+
index: word.index,
|
|
1076
|
+
value,
|
|
1077
|
+
josi: '',
|
|
1078
|
+
checkInit: this.flagCheckArrayInit,
|
|
1079
|
+
...map,
|
|
1080
|
+
end: this.peekSourceMap()
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
// 一般的な変数への代入
|
|
1084
|
+
const word2 = this.getVarName(word)
|
|
1085
|
+
return {
|
|
1086
|
+
type: 'let',
|
|
1087
|
+
name: word2,
|
|
1088
|
+
value,
|
|
1089
|
+
josi: '',
|
|
1090
|
+
...map,
|
|
1091
|
+
end: this.peekSourceMap()
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
/** 定める構文 */
|
|
1096
|
+
ySadameru (): Ast | null {
|
|
1097
|
+
const map = this.peekSourceMap()
|
|
1098
|
+
const sadameru = this.get() // 定める
|
|
1099
|
+
if (sadameru === null) { return null }
|
|
1100
|
+
const word = this.popStack(['を'])
|
|
1101
|
+
const value = this.popStack(['へ', 'に'])
|
|
1102
|
+
if (!word || (word.type !== 'word' && word.type !== 'func' && word.type !== '配列参照')) {
|
|
1103
|
+
throw NakoSyntaxError.fromNode('『定める』文で定数が見当たりません。『(定数名)を(値)に定める』のように使います。', sadameru)
|
|
1104
|
+
}
|
|
1105
|
+
// 変数を生成する
|
|
1106
|
+
const nameToken = this.getVarName(word)
|
|
1107
|
+
return {
|
|
1108
|
+
type: 'def_local_var',
|
|
1109
|
+
name: nameToken,
|
|
1110
|
+
vartype: '定数',
|
|
1111
|
+
value,
|
|
1112
|
+
josi: '',
|
|
1113
|
+
...map,
|
|
1114
|
+
end: this.peekSourceMap()
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
yIncDec (): Ast | null {
|
|
1119
|
+
const map = this.peekSourceMap()
|
|
1120
|
+
const action = this.get() // (増やす|減らす)
|
|
1121
|
+
if (action === null) { return null }
|
|
1122
|
+
|
|
1123
|
+
// 『Nずつ増やして繰り返す』文か?
|
|
1124
|
+
if (this.check('繰返')) {
|
|
1125
|
+
this.pushStack({ type: 'word', value: action.value, josi: action.josi, ...map, end: this.peekSourceMap() })
|
|
1126
|
+
return this.yFor()
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
// スタックから引数をポップ
|
|
1130
|
+
let value = this.popStack(['だけ', ''])
|
|
1131
|
+
if (!value) {
|
|
1132
|
+
value = { type: 'number', value: 1, josi: 'だけ', ...map, end: this.peekSourceMap() }
|
|
1133
|
+
}
|
|
1134
|
+
const word = this.popStack(['を'])
|
|
1135
|
+
if (!word || (word.type !== 'word' && word.type !== '配列参照')) {
|
|
1136
|
+
throw NakoSyntaxError.fromNode(
|
|
1137
|
+
`『${action.type}』文で定数が見当たりません。『(変数名)を(値)だけ${action.type}』のように使います。`,
|
|
1138
|
+
action)
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
// 減らすなら-1かける
|
|
1142
|
+
if (action.value === '減') {
|
|
1143
|
+
value = { type: 'op', operator: '*', left: value, right: { type: 'number', value: -1, line: action.line }, josi: '', ...map }
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
return {
|
|
1147
|
+
type: 'inc',
|
|
1148
|
+
name: word,
|
|
1149
|
+
value,
|
|
1150
|
+
josi: action.josi,
|
|
1151
|
+
...map,
|
|
1152
|
+
end: this.peekSourceMap()
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
yCall (): Ast | null {
|
|
1157
|
+
if (this.isEOF()) { return null }
|
|
1158
|
+
|
|
1159
|
+
// スタックに積んでいく
|
|
1160
|
+
while (!this.isEOF()) {
|
|
1161
|
+
if (this.check('ここから')) { this.get() }
|
|
1162
|
+
// 代入
|
|
1163
|
+
if (this.check('代入')) { return this.yDainyu() }
|
|
1164
|
+
if (this.check('定める')) { return this.ySadameru() }
|
|
1165
|
+
// 制御構文
|
|
1166
|
+
if (this.check('回')) { return this.yRepeatTime() }
|
|
1167
|
+
if (this.check('間')) { return this.yWhile() }
|
|
1168
|
+
if (this.check('繰返') || this.check('増繰返') || this.check('減繰返')) { return this.yFor() }
|
|
1169
|
+
if (this.check('反復')) { return this.yForEach() }
|
|
1170
|
+
if (this.check('条件分岐')) { return this.ySwitch() }
|
|
1171
|
+
if (this.check('戻る')) { return this.yReturn() }
|
|
1172
|
+
if (this.check('増') || this.check('減')) { return this.yIncDec() }
|
|
1173
|
+
// C言語風関数
|
|
1174
|
+
if (this.check2([['func', 'word'], '('])) { // C言語風
|
|
1175
|
+
const cur = this.peek()
|
|
1176
|
+
if (cur && cur.josi === '') {
|
|
1177
|
+
const t: Ast|null = this.yValue()
|
|
1178
|
+
if (t) {
|
|
1179
|
+
const josi = t.josi || ''
|
|
1180
|
+
if (t.type === 'func' && (t.josi === '' || keizokuJosi.indexOf(josi) >= 0)) {
|
|
1181
|
+
t.josi = ''
|
|
1182
|
+
return t // 関数なら値とする
|
|
1183
|
+
}
|
|
1184
|
+
this.pushStack(t)
|
|
1185
|
+
}
|
|
1186
|
+
if (this.check('comma')) { this.get() }
|
|
1187
|
+
continue
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
// なでしこ式関数
|
|
1191
|
+
if (this.check('func')) {
|
|
1192
|
+
const r = this.yCallFunc()
|
|
1193
|
+
if (r === null) { continue }
|
|
1194
|
+
// 「〜する間」の形ならスタックに積む。
|
|
1195
|
+
if (this.check('間')) {
|
|
1196
|
+
this.pushStack(r)
|
|
1197
|
+
continue
|
|
1198
|
+
}
|
|
1199
|
+
// 関数呼び出しの直後に、四則演算があるか?
|
|
1200
|
+
if (!this.checkTypes(operatorList)) { return r } // なければ関数呼び出しを戻す
|
|
1201
|
+
// 四則演算があった場合、計算してスタックに載せる
|
|
1202
|
+
this.pushStack(this.yGetArgOperator(r))
|
|
1203
|
+
continue
|
|
1204
|
+
}
|
|
1205
|
+
// 値のとき → スタックに載せる
|
|
1206
|
+
const t = this.yGetArg()
|
|
1207
|
+
if (t) {
|
|
1208
|
+
this.pushStack(t)
|
|
1209
|
+
continue
|
|
1210
|
+
}
|
|
1211
|
+
break
|
|
1212
|
+
} // end of while
|
|
1213
|
+
|
|
1214
|
+
// 助詞が余ってしまった場合
|
|
1215
|
+
if (this.stack.length > 0) {
|
|
1216
|
+
this.logger.debug('--- stack dump ---\n' + JSON.stringify(this.stack, null, 2) + '\npeek: ' + JSON.stringify(this.peek(), null, 2))
|
|
1217
|
+
let msgDebug = `不完全な文です。${this.stack.map((n) => this.nodeToStr(n, { depth: 0 }, true)).join('、')}が解決していません。`
|
|
1218
|
+
let msg = `不完全な文です。${this.stack.map((n) => this.nodeToStr(n, { depth: 0 }, false)).join('、')}が解決していません。`
|
|
1219
|
+
|
|
1220
|
+
// 各ノードについて、更に詳細な情報があるなら表示
|
|
1221
|
+
for (const n of this.stack) {
|
|
1222
|
+
const d0 = this.nodeToStr(n, { depth: 0 }, false)
|
|
1223
|
+
const d1 = this.nodeToStr(n, { depth: 1 }, false)
|
|
1224
|
+
if (d0 !== d1) {
|
|
1225
|
+
msgDebug += `${this.nodeToStr(n, { depth: 0 }, true)}は${this.nodeToStr(n, { depth: 1 }, true)}として使われています。`
|
|
1226
|
+
msg += `${d0}は${d1}として使われています。`
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
const first = this.stack[0]
|
|
1231
|
+
const last = this.stack[this.stack.length - 1]
|
|
1232
|
+
this.logger.debug(msgDebug, first)
|
|
1233
|
+
throw NakoSyntaxError.fromNode(msg, first, last)
|
|
1234
|
+
}
|
|
1235
|
+
return this.popStack([])
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
/** @returns {Ast | null} */
|
|
1239
|
+
yCallFunc (): Ast | null {
|
|
1240
|
+
const map = this.peekSourceMap()
|
|
1241
|
+
const t = this.get()
|
|
1242
|
+
if (!t) { return null }
|
|
1243
|
+
const f = t.meta
|
|
1244
|
+
const funcName: string = t.value
|
|
1245
|
+
// (関数)には ... 構文 ... https://github.com/kujirahand/nadesiko3/issues/66
|
|
1246
|
+
let funcObj = null
|
|
1247
|
+
if (t.josi === 'には') {
|
|
1248
|
+
try {
|
|
1249
|
+
funcObj = this.yMumeiFunc()
|
|
1250
|
+
} catch (err: any) {
|
|
1251
|
+
throw NakoSyntaxError.fromNode(`『${t.value}には...』で無名関数の定義で以下の間違いがあります。\n${err.message}`, t)
|
|
1252
|
+
}
|
|
1253
|
+
if (funcObj === null) { throw NakoSyntaxError.fromNode('『Fには』構文がありましたが、関数定義が見当たりません。', t) }
|
|
1254
|
+
}
|
|
1255
|
+
if (!f || typeof f.josi === 'undefined') { throw NakoSyntaxError.fromNode('関数の定義でエラー。', t) }
|
|
1256
|
+
|
|
1257
|
+
// 最近使った関数を記録
|
|
1258
|
+
this.recentlyCalledFunc.push({ name: funcName, ...f })
|
|
1259
|
+
|
|
1260
|
+
// 呼び出す関数が非同期呼び出しが必要(asyncFn)ならマーク
|
|
1261
|
+
if (f && f.asyncFn) { this.usedAsyncFn = true }
|
|
1262
|
+
|
|
1263
|
+
// 関数の引数を取り出す処理
|
|
1264
|
+
const args: any[] = []
|
|
1265
|
+
let nullCount = 0
|
|
1266
|
+
let valueCount = 0
|
|
1267
|
+
for (let i = 0; i < f.josi.length; i++) {
|
|
1268
|
+
while (true) {
|
|
1269
|
+
// スタックから任意の助詞を持つ値を一つ取り出す、助詞がなければ末尾から得る
|
|
1270
|
+
let popArg = this.popStack(f.josi[i])
|
|
1271
|
+
if (popArg !== null) {
|
|
1272
|
+
valueCount++
|
|
1273
|
+
} else if (i < f.josi.length - 1 || !f.isVariableJosi) {
|
|
1274
|
+
nullCount++
|
|
1275
|
+
popArg = funcObj
|
|
1276
|
+
} else {
|
|
1277
|
+
break
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
if (popArg !== null && f.funcPointers !== undefined && f.funcPointers[i] !== null) {
|
|
1281
|
+
if (popArg.type === 'func') { // 引数が関数の参照渡しに該当する場合、typeを『func_pointer』に変更
|
|
1282
|
+
popArg.type = 'func_pointer'
|
|
1283
|
+
} else {
|
|
1284
|
+
const varname = (f.varnames) ? f.varnames[i] : `${i + 1}番目の引数`
|
|
1285
|
+
throw NakoSyntaxError.fromNode(
|
|
1286
|
+
`関数『${t.value}』の引数『${varname}』には関数オブジェクトが必要です。`, t)
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
args.push(popArg)
|
|
1290
|
+
if (i < f.josi.length - 1 || !f.isVariableJosi) { break }
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
// 1つだけなら、変数「それ」で補完される
|
|
1294
|
+
if (nullCount >= 2 && (valueCount > 0 || t.josi === '' || keizokuJosi.indexOf(t.josi) >= 0)) {
|
|
1295
|
+
throw NakoSyntaxError.fromNode(`関数『${t.value}』の引数が不足しています。`, t)
|
|
1296
|
+
}
|
|
1297
|
+
this.usedFuncs.add(t.value)
|
|
1298
|
+
// 関数呼び出しのAstを構築
|
|
1299
|
+
const funcNode: Ast = {
|
|
1300
|
+
type: 'func',
|
|
1301
|
+
name: t.value,
|
|
1302
|
+
args,
|
|
1303
|
+
josi: t.josi,
|
|
1304
|
+
...map,
|
|
1305
|
+
end: this.peekSourceMap()
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
// 「プラグイン名設定」ならば、そこでスコープを変更することを意味する
|
|
1309
|
+
if (funcNode.name === 'プラグイン名設定') {
|
|
1310
|
+
if (args.length > 0 && args[0]) {
|
|
1311
|
+
let fname: string = '' + args[0].value
|
|
1312
|
+
if (fname === 'メイン') { fname = '' + args[0].file }
|
|
1313
|
+
this.modName = NakoLexer.filenameToModName(fname)
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
// 言い切りならそこで一度切る
|
|
1318
|
+
if (t.josi === '') { return funcNode }
|
|
1319
|
+
|
|
1320
|
+
// 「**して、**」の場合も一度切る
|
|
1321
|
+
if (keizokuJosi.indexOf(t.josi) >= 0) {
|
|
1322
|
+
funcNode.josi = 'して'
|
|
1323
|
+
return funcNode
|
|
1324
|
+
}
|
|
1325
|
+
// 続き
|
|
1326
|
+
funcNode.meta = f
|
|
1327
|
+
this.pushStack(funcNode)
|
|
1328
|
+
return null
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
/** 関数呼び出し演算子 #891
|
|
1332
|
+
* @returns {Ast | null} */
|
|
1333
|
+
yCallOp (): Ast | null {
|
|
1334
|
+
if (!this.check2(['func', '←'])) { return null }
|
|
1335
|
+
const map = this.peekSourceMap()
|
|
1336
|
+
// 関数名を得る
|
|
1337
|
+
const word = this.get()
|
|
1338
|
+
if (word == null) { throw new Error('関数が取得できません。') }
|
|
1339
|
+
try {
|
|
1340
|
+
const op = this.get()
|
|
1341
|
+
if (op == null) { throw new Error('関数呼び出し演算子が取得できません。') }
|
|
1342
|
+
const funcName = word.value
|
|
1343
|
+
// 関数の引数なしをチェック
|
|
1344
|
+
if (!word.meta) { throw new Error('関数本体を取得できません。') }
|
|
1345
|
+
if (!word.meta.josi) { throw new Error('関数の引数情報を取得できません。') }
|
|
1346
|
+
const argCount = word.meta.josi.length
|
|
1347
|
+
if (argCount === 0) {
|
|
1348
|
+
throw NakoSyntaxError.fromNode(`引数がない関数『${funcName}』を関数呼び出し演算子で呼び出すことはできません。`, word)
|
|
1349
|
+
}
|
|
1350
|
+
// 引数を順に取得
|
|
1351
|
+
const curStackPos = this.stack.length
|
|
1352
|
+
while (!this.isEOF()) {
|
|
1353
|
+
const t = this.yGetArg()
|
|
1354
|
+
if (t) {
|
|
1355
|
+
this.pushStack(t)
|
|
1356
|
+
if ((this.stack.length - curStackPos) === argCount) { break }
|
|
1357
|
+
continue
|
|
1358
|
+
}
|
|
1359
|
+
break
|
|
1360
|
+
}
|
|
1361
|
+
// この場合第一引数の省略は認めない
|
|
1362
|
+
const realArgCount = this.stack.length - curStackPos
|
|
1363
|
+
if (realArgCount !== argCount) {
|
|
1364
|
+
throw NakoSyntaxError.fromNode(`関数『${funcName}』呼び出しで引数の数(${realArgCount})が定義(${argCount})と違います。`, word)
|
|
1365
|
+
}
|
|
1366
|
+
// 引数を取り出す
|
|
1367
|
+
const tmpList = this.stack.splice(curStackPos, argCount)
|
|
1368
|
+
// 引数が1つなら助詞は省略が可能。ただし、引数が2つ以上の時、正しく助詞の順序を入れ替える
|
|
1369
|
+
let argList = tmpList
|
|
1370
|
+
if (argCount >= 2) {
|
|
1371
|
+
argList = []
|
|
1372
|
+
const defList = word.meta.josi
|
|
1373
|
+
defList.forEach((josiList, i) => {
|
|
1374
|
+
for (let j = 0; j < tmpList.length; j++) {
|
|
1375
|
+
const t = tmpList[j]
|
|
1376
|
+
if (josiList.indexOf(t.josi) >= 0) {
|
|
1377
|
+
argList[i] = t
|
|
1378
|
+
return
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
const josiStr = josiList.join(',')
|
|
1382
|
+
throw new Error(`助詞『${josiStr}』が見当たりません。`)
|
|
1383
|
+
})
|
|
1384
|
+
}
|
|
1385
|
+
this.usedFuncs.add(funcName)
|
|
1386
|
+
// funcノードを返す
|
|
1387
|
+
return {
|
|
1388
|
+
type: 'func',
|
|
1389
|
+
name: funcName,
|
|
1390
|
+
args: argList,
|
|
1391
|
+
setter: true, // 重要
|
|
1392
|
+
josi: '',
|
|
1393
|
+
...map,
|
|
1394
|
+
end: this.peekSourceMap()
|
|
1395
|
+
}
|
|
1396
|
+
} catch (err: any) {
|
|
1397
|
+
this.logger.debug(`${this.nodeToStr(word, { depth: 0 }, true)}の関数呼び出しで引数(『←』以降)が読み取れません。`, word)
|
|
1398
|
+
throw NakoSyntaxError.fromNode(
|
|
1399
|
+
`${this.nodeToStr(word, { depth: 0 }, false)}の関数呼び出しでエラーがあります。\n${err.message}`, word)
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
/** @returns {Ast | null} */
|
|
1404
|
+
yLet (): Ast | null {
|
|
1405
|
+
const map = this.peekSourceMap()
|
|
1406
|
+
// 通常の変数
|
|
1407
|
+
if (this.check2(['word', 'eq'])) {
|
|
1408
|
+
const word = this.peek()
|
|
1409
|
+
let threw = false
|
|
1410
|
+
try {
|
|
1411
|
+
if (this.accept(['word', 'eq', this.yCalc]) || this.accept(['word', 'eq', this.ySentence])) {
|
|
1412
|
+
if (this.y[2].type === 'eol') {
|
|
1413
|
+
throw new Error('値が空です。')
|
|
1414
|
+
}
|
|
1415
|
+
if (this.check('comma')) { this.get() } // skip comma (ex) name1=val1, name2=val2
|
|
1416
|
+
const nameToken = this.getVarName(this.y[0])
|
|
1417
|
+
const valueToken = this.y[2]
|
|
1418
|
+
return {
|
|
1419
|
+
type: 'let',
|
|
1420
|
+
name: nameToken,
|
|
1421
|
+
value: valueToken,
|
|
1422
|
+
...map,
|
|
1423
|
+
end: this.peekSourceMap()
|
|
1424
|
+
}
|
|
1425
|
+
} else {
|
|
1426
|
+
threw = true
|
|
1427
|
+
this.logger.debug(`${this.nodeToStr(word, { depth: 1 }, true)}への代入文で計算式に書き間違いがあります。`, word)
|
|
1428
|
+
throw NakoSyntaxError.fromNode(`${this.nodeToStr(word, { depth: 1 }, false)}への代入文で計算式に書き間違いがあります。`, map)
|
|
1429
|
+
}
|
|
1430
|
+
} catch (err: any) {
|
|
1431
|
+
if (threw) {
|
|
1432
|
+
throw err
|
|
1433
|
+
}
|
|
1434
|
+
this.logger.debug(`${this.nodeToStr(word, { depth: 1 }, true)}への代入文で計算式に以下の書き間違いがあります。\n${err.message}`, word)
|
|
1435
|
+
throw NakoSyntaxError.fromNode(`${this.nodeToStr(word, { depth: 1 }, false)}への代入文で計算式に以下の書き間違いがあります。\n${err.message}`, map)
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
// let_array ?
|
|
1440
|
+
if (this.check2(['word', '@'])) {
|
|
1441
|
+
const la = this.yLetArrayAt(map)
|
|
1442
|
+
if (this.check('comma')) { this.get() } // skip comma (ex) name1=val1, name2=val2
|
|
1443
|
+
if (la) {
|
|
1444
|
+
la.checkInit = this.flagCheckArrayInit
|
|
1445
|
+
return la
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
if (this.check2(['word', '['])) {
|
|
1449
|
+
const lb = this.yLetArrayBracket(map)
|
|
1450
|
+
if (this.check('comma')) { this.get() } // skip comma (ex) name1=val1, name2=val2
|
|
1451
|
+
if (lb) {
|
|
1452
|
+
lb.checkInit = this.flagCheckArrayInit
|
|
1453
|
+
return lb
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
// ローカル変数定義
|
|
1458
|
+
if (this.accept(['word', 'とは'])) {
|
|
1459
|
+
const word = this.getVarName(this.y[0])
|
|
1460
|
+
if (!this.checkTypes(['変数', '定数'])) {
|
|
1461
|
+
throw NakoSyntaxError.fromNode('ローカル変数『' + word.value + '』の定義エラー', word)
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
const vtype = this.getCur() // 変数
|
|
1465
|
+
// 初期値がある?
|
|
1466
|
+
let value = null
|
|
1467
|
+
if (this.check('eq')) {
|
|
1468
|
+
this.get()
|
|
1469
|
+
value = this.yCalc()
|
|
1470
|
+
}
|
|
1471
|
+
if (this.check('comma')) { this.get() } // skip comma (ex) name1=val1, name2=val2
|
|
1472
|
+
return {
|
|
1473
|
+
type: 'def_local_var',
|
|
1474
|
+
name: word,
|
|
1475
|
+
vartype: vtype.type,
|
|
1476
|
+
value,
|
|
1477
|
+
...map,
|
|
1478
|
+
end: this.peekSourceMap()
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
// ローカル変数定義(その2)
|
|
1482
|
+
if (this.accept(['変数', 'word', 'eq', this.yCalc])) {
|
|
1483
|
+
const word = this.getVarName(this.y[1])
|
|
1484
|
+
return {
|
|
1485
|
+
type: 'def_local_var',
|
|
1486
|
+
name: word,
|
|
1487
|
+
vartype: '変数',
|
|
1488
|
+
value: this.y[3],
|
|
1489
|
+
...map,
|
|
1490
|
+
end: this.peekSourceMap()
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
if (this.accept(['定数', 'word', 'eq', this.yCalc])) {
|
|
1495
|
+
const word = this.getVarName(this.y[1])
|
|
1496
|
+
return {
|
|
1497
|
+
type: 'def_local_var',
|
|
1498
|
+
name: word,
|
|
1499
|
+
vartype: '定数',
|
|
1500
|
+
value: this.y[3],
|
|
1501
|
+
...map,
|
|
1502
|
+
end: this.peekSourceMap()
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
// 複数定数への代入 #563
|
|
1507
|
+
if (this.accept(['定数', this.yJSONArray, 'eq', this.yCalc])) {
|
|
1508
|
+
const names = this.y[1]
|
|
1509
|
+
// check array
|
|
1510
|
+
if (names && names.value instanceof Array) {
|
|
1511
|
+
for (const i in names.value) {
|
|
1512
|
+
if (names.value[i].type !== 'word') {
|
|
1513
|
+
throw NakoSyntaxError.fromNode(`複数定数の代入文${i + 1}番目でエラー。『定数[A,B,C]=[1,2,3]』の書式で記述してください。`, this.y[0])
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
} else {
|
|
1517
|
+
throw NakoSyntaxError.fromNode('複数定数の代入文でエラー。『定数[A,B,C]=[1,2,3]』の書式で記述してください。', this.y[0])
|
|
1518
|
+
}
|
|
1519
|
+
names.value = this.getVarNameList(names.value)
|
|
1520
|
+
return {
|
|
1521
|
+
type: 'def_local_varlist',
|
|
1522
|
+
names: names.value,
|
|
1523
|
+
vartype: '定数',
|
|
1524
|
+
value: this.y[3],
|
|
1525
|
+
...map,
|
|
1526
|
+
end: this.peekSourceMap()
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
// 複数変数への代入 #563
|
|
1530
|
+
if (this.accept(['変数', this.yJSONArray, 'eq', this.yCalc])) {
|
|
1531
|
+
const names = this.y[1]
|
|
1532
|
+
// check array
|
|
1533
|
+
if (names && names.value instanceof Array) {
|
|
1534
|
+
for (const i in names.value) {
|
|
1535
|
+
if (names.value[i].type !== 'word') {
|
|
1536
|
+
throw NakoSyntaxError.fromNode(`複数変数の代入文${i + 1}番目でエラー。『変数[A,B,C]=[1,2,3]』の書式で記述してください。`, this.y[0])
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
} else {
|
|
1540
|
+
throw NakoSyntaxError.fromNode('複数変数の代入文でエラー。『変数[A,B,C]=[1,2,3]』の書式で記述してください。', this.y[0])
|
|
1541
|
+
}
|
|
1542
|
+
names.value = this.getVarNameList(names.value)
|
|
1543
|
+
return {
|
|
1544
|
+
type: 'def_local_varlist',
|
|
1545
|
+
names: names.value,
|
|
1546
|
+
vartype: '変数',
|
|
1547
|
+
value: this.y[3],
|
|
1548
|
+
...map,
|
|
1549
|
+
end: this.peekSourceMap()
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
// 複数変数への代入 #563
|
|
1554
|
+
if (this.check2(['word', 'comma', 'word'])) {
|
|
1555
|
+
// 2 word
|
|
1556
|
+
if (this.accept(['word', 'comma', 'word', 'eq', this.yCalc])) {
|
|
1557
|
+
let names = [this.y[0], this.y[2]]
|
|
1558
|
+
names = this.getVarNameList(names)
|
|
1559
|
+
return {
|
|
1560
|
+
type: 'def_local_varlist',
|
|
1561
|
+
names,
|
|
1562
|
+
vartype: '変数',
|
|
1563
|
+
value: this.y[4],
|
|
1564
|
+
...map,
|
|
1565
|
+
end: this.peekSourceMap()
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
// 3 word
|
|
1569
|
+
if (this.accept(['word', 'comma', 'word', 'comma', 'word', 'eq', this.yCalc])) {
|
|
1570
|
+
let names = [this.y[0], this.y[2], this.y[4]]
|
|
1571
|
+
names = this.getVarNameList(names)
|
|
1572
|
+
return {
|
|
1573
|
+
type: 'def_local_varlist',
|
|
1574
|
+
names,
|
|
1575
|
+
vartype: '変数',
|
|
1576
|
+
value: this.y[6],
|
|
1577
|
+
...map,
|
|
1578
|
+
end: this.peekSourceMap()
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
// 4 word
|
|
1582
|
+
if (this.accept(['word', 'comma', 'word', 'comma', 'word', 'comma', 'word', 'eq', this.yCalc])) {
|
|
1583
|
+
let names = [this.y[0], this.y[2], this.y[4], this.y[6]]
|
|
1584
|
+
names = this.getVarNameList(names)
|
|
1585
|
+
return {
|
|
1586
|
+
type: 'def_local_varlist',
|
|
1587
|
+
names,
|
|
1588
|
+
vartype: '変数',
|
|
1589
|
+
value: this.y[8],
|
|
1590
|
+
...map,
|
|
1591
|
+
end: this.peekSourceMap()
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
// 5 word
|
|
1595
|
+
if (this.accept(['word', 'comma', 'word', 'comma', 'word', 'comma', 'word', 'comma', 'word', 'eq', this.yCalc])) {
|
|
1596
|
+
let names = [this.y[0], this.y[2], this.y[4], this.y[6], this.y[8]]
|
|
1597
|
+
names = this.getVarNameList(names)
|
|
1598
|
+
return {
|
|
1599
|
+
type: 'def_local_varlist',
|
|
1600
|
+
names,
|
|
1601
|
+
vartype: '変数',
|
|
1602
|
+
value: this.y[10],
|
|
1603
|
+
...map,
|
|
1604
|
+
end: this.peekSourceMap()
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
return null
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
/**
|
|
1612
|
+
* 配列のインデックスが1から始まる場合を考慮するか
|
|
1613
|
+
* @param {Ast} node
|
|
1614
|
+
* @returns
|
|
1615
|
+
*/
|
|
1616
|
+
checkArrayIndex (node: Ast): Ast {
|
|
1617
|
+
// 配列が0から始まるのであればそのまま返す
|
|
1618
|
+
if (this.arrayIndexFrom === 0) { return node }
|
|
1619
|
+
// 配列が1から始まるのであれば演算を加えて返す
|
|
1620
|
+
return {
|
|
1621
|
+
...node,
|
|
1622
|
+
'type': 'op',
|
|
1623
|
+
'operator': '-',
|
|
1624
|
+
'left': node,
|
|
1625
|
+
'right': {
|
|
1626
|
+
...node,
|
|
1627
|
+
'type': 'number',
|
|
1628
|
+
'value': this.arrayIndexFrom
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
/**
|
|
1634
|
+
* 配列のインデックスを逆順にするのを考慮するか
|
|
1635
|
+
* @param {Ast[]| null} ary
|
|
1636
|
+
*/
|
|
1637
|
+
checkArrayReverse (ary: Ast[] | null): Ast[] {
|
|
1638
|
+
if (!ary) { return [] }
|
|
1639
|
+
if (!this.flagReverseArrayIndex) { return ary }
|
|
1640
|
+
// 二次元以上の配列変数のアクセスを[y][x]ではなく[x][y]と順序を変更する
|
|
1641
|
+
if (ary.length <= 1) { return ary }
|
|
1642
|
+
return ary.reverse()
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
/** @returns {Ast | null} */
|
|
1646
|
+
yLetArrayAt (map: SourceMap): Ast|null {
|
|
1647
|
+
// 一次元配列
|
|
1648
|
+
if (this.accept(['word', '@', this.yValue, 'eq', this.yCalc])) {
|
|
1649
|
+
return {
|
|
1650
|
+
type: 'let_array',
|
|
1651
|
+
name: this.getVarName(this.y[0]),
|
|
1652
|
+
index: [this.checkArrayIndex(this.y[2])],
|
|
1653
|
+
value: this.y[4],
|
|
1654
|
+
...map,
|
|
1655
|
+
end: this.peekSourceMap()
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
// 二次元配列
|
|
1660
|
+
if (this.accept(['word', '@', this.yValue, '@', this.yValue, 'eq', this.yCalc])) {
|
|
1661
|
+
return {
|
|
1662
|
+
type: 'let_array',
|
|
1663
|
+
name: this.getVarName(this.y[0]),
|
|
1664
|
+
index: this.checkArrayReverse([this.checkArrayIndex(this.y[2]), this.checkArrayIndex(this.y[4])]),
|
|
1665
|
+
value: this.y[6],
|
|
1666
|
+
...map,
|
|
1667
|
+
end: this.peekSourceMap()
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
// 三次元配列
|
|
1672
|
+
if (this.accept(['word', '@', this.yValue, '@', this.yValue, '@', this.yValue, 'eq', this.yCalc])) {
|
|
1673
|
+
return {
|
|
1674
|
+
type: 'let_array',
|
|
1675
|
+
name: this.getVarName(this.y[0]),
|
|
1676
|
+
index: this.checkArrayReverse([this.checkArrayIndex(this.y[2]), this.checkArrayIndex(this.y[4]), this.checkArrayIndex(this.y[6])]),
|
|
1677
|
+
value: this.y[8],
|
|
1678
|
+
...map,
|
|
1679
|
+
end: this.peekSourceMap()
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
// 二次元配列(カンマ指定)
|
|
1684
|
+
if (this.accept(['word', '@', this.yValue, 'comma', this.yValue, 'eq', this.yCalc])) {
|
|
1685
|
+
return {
|
|
1686
|
+
type: 'let_array',
|
|
1687
|
+
name: this.getVarName(this.y[0]),
|
|
1688
|
+
index: this.checkArrayReverse([this.checkArrayIndex(this.y[2]), this.checkArrayIndex(this.y[4])]),
|
|
1689
|
+
value: this.y[6],
|
|
1690
|
+
...map,
|
|
1691
|
+
end: this.peekSourceMap()
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
// 三次元配列(カンマ指定)
|
|
1696
|
+
if (this.accept(['word', '@', this.yValue, 'comma', this.yValue, 'comma', this.yValue, 'eq', this.yCalc])) {
|
|
1697
|
+
return {
|
|
1698
|
+
type: 'let_array',
|
|
1699
|
+
name: this.getVarName(this.y[0]),
|
|
1700
|
+
index: this.checkArrayReverse([this.checkArrayIndex(this.y[2]), this.checkArrayIndex(this.y[4]), this.checkArrayIndex(this.y[6])]),
|
|
1701
|
+
value: this.y[8],
|
|
1702
|
+
...map,
|
|
1703
|
+
end: this.peekSourceMap()
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
return null
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
/** @returns {Ast | null} */
|
|
1710
|
+
yLetArrayBracket (map: SourceMap): Ast|null {
|
|
1711
|
+
// 一次元配列
|
|
1712
|
+
if (this.accept(['word', '[', this.yCalc, ']', 'eq', this.yCalc])) {
|
|
1713
|
+
return {
|
|
1714
|
+
type: 'let_array',
|
|
1715
|
+
name: this.getVarName(this.y[0]),
|
|
1716
|
+
index: [this.checkArrayIndex(this.y[2])],
|
|
1717
|
+
value: this.y[5],
|
|
1718
|
+
...map,
|
|
1719
|
+
end: this.peekSourceMap()
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
// 二次元配列
|
|
1724
|
+
if (this.accept(['word', '[', this.yCalc, ']', '[', this.yCalc, ']', 'eq', this.yCalc])) {
|
|
1725
|
+
return {
|
|
1726
|
+
type: 'let_array',
|
|
1727
|
+
name: this.getVarName(this.y[0]),
|
|
1728
|
+
index: this.checkArrayReverse([this.checkArrayIndex(this.y[2]), this.checkArrayIndex(this.y[5])]),
|
|
1729
|
+
value: this.y[8],
|
|
1730
|
+
tag: '2',
|
|
1731
|
+
...map,
|
|
1732
|
+
end: this.peekSourceMap()
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
if (this.accept(['word', '[', this.yCalc, 'comma', this.yCalc, ']', 'eq', this.yCalc])) {
|
|
1736
|
+
return {
|
|
1737
|
+
type: 'let_array',
|
|
1738
|
+
name: this.getVarName(this.y[0]),
|
|
1739
|
+
index: this.checkArrayReverse([this.checkArrayIndex(this.y[2]), this.checkArrayIndex(this.y[4])]),
|
|
1740
|
+
value: this.y[7],
|
|
1741
|
+
tag: '2',
|
|
1742
|
+
...map,
|
|
1743
|
+
end: this.peekSourceMap()
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
// 三次元配列
|
|
1748
|
+
if (this.accept(['word', '[', this.yCalc, ']', '[', this.yCalc, ']', '[', this.yCalc, ']', 'eq', this.yCalc])) {
|
|
1749
|
+
return {
|
|
1750
|
+
type: 'let_array',
|
|
1751
|
+
name: this.getVarName(this.y[0]),
|
|
1752
|
+
index: this.checkArrayReverse([this.checkArrayIndex(this.y[2]), this.checkArrayIndex(this.y[5]), this.checkArrayIndex(this.y[8])]),
|
|
1753
|
+
value: this.y[11],
|
|
1754
|
+
...map,
|
|
1755
|
+
end: this.peekSourceMap()
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
if (this.accept(['word', '[', this.yCalc, 'comma', this.yCalc, 'comma', this.yCalc, ']', 'eq', this.yCalc])) {
|
|
1759
|
+
return {
|
|
1760
|
+
type: 'let_array',
|
|
1761
|
+
name: this.getVarName(this.y[0]),
|
|
1762
|
+
index: this.checkArrayReverse([this.checkArrayIndex(this.y[2]), this.checkArrayIndex(this.y[4]), this.checkArrayIndex(this.y[6])]),
|
|
1763
|
+
value: this.y[9],
|
|
1764
|
+
...map,
|
|
1765
|
+
end: this.peekSourceMap()
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
return null
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
/** @returns {Ast | null} */
|
|
1772
|
+
yCalc (): Ast|null {
|
|
1773
|
+
const map = this.peekSourceMap()
|
|
1774
|
+
if (this.check('eol')) { return null }
|
|
1775
|
+
// 値を一つ読む
|
|
1776
|
+
const t = this.yGetArg()
|
|
1777
|
+
if (!t) { return null }
|
|
1778
|
+
// 助詞がある? つまり、関数呼び出しがある?
|
|
1779
|
+
if (t.josi === '') { return t } // 値だけの場合
|
|
1780
|
+
// 関数の呼び出しがあるなら、スタックに載せて関数読み出しを呼ぶ
|
|
1781
|
+
this.pushStack(t)
|
|
1782
|
+
const t1 = this.yCall()
|
|
1783
|
+
if (!t1) {
|
|
1784
|
+
return this.popStack()
|
|
1785
|
+
}
|
|
1786
|
+
// それが連文か確認
|
|
1787
|
+
if (t1.josi !== 'して') { return t1 } // 連文ではない
|
|
1788
|
+
// 連文なら右側を読んで左側とくっつける
|
|
1789
|
+
const t2 = this.yCalc()
|
|
1790
|
+
if (!t2) { return t1 }
|
|
1791
|
+
return {
|
|
1792
|
+
type: 'renbun',
|
|
1793
|
+
left: t1,
|
|
1794
|
+
right: t2,
|
|
1795
|
+
josi: t2.josi,
|
|
1796
|
+
...map,
|
|
1797
|
+
end: this.peekSourceMap()
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1801
|
+
/** @returns {Ast | null} */
|
|
1802
|
+
yValueKakko (): Ast | null {
|
|
1803
|
+
if (!this.check('(')) { return null }
|
|
1804
|
+
const t = this.get() // skip '('
|
|
1805
|
+
if (!t) { throw new Error('[System Error] check したのに get できない') }
|
|
1806
|
+
this.saveStack()
|
|
1807
|
+
const v = this.yCalc() || this.ySentence()
|
|
1808
|
+
if (v === null) {
|
|
1809
|
+
const v2 = this.get()
|
|
1810
|
+
this.logger.debug('(...)の解析エラー。' + this.nodeToStr(v2, { depth: 1 }, true) + 'の近く', t)
|
|
1811
|
+
throw NakoSyntaxError.fromNode('(...)の解析エラー。' + this.nodeToStr(v2, { depth: 1 }, false) + 'の近く', t)
|
|
1812
|
+
}
|
|
1813
|
+
if (!this.check(')')) {
|
|
1814
|
+
this.logger.debug('(...)の解析エラー。' + this.nodeToStr(v, { depth: 1 }, true) + 'の近く', t)
|
|
1815
|
+
throw NakoSyntaxError.fromNode('(...)の解析エラー。' + this.nodeToStr(v, { depth: 1 }, false) + 'の近く', t)
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
const closeParent = this.get() // skip ')'
|
|
1819
|
+
this.loadStack()
|
|
1820
|
+
if (closeParent) {
|
|
1821
|
+
v.josi = closeParent.josi
|
|
1822
|
+
}
|
|
1823
|
+
return v
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
/** @returns {Ast | null} */
|
|
1827
|
+
yValue (): Ast | null {
|
|
1828
|
+
const map = this.peekSourceMap()
|
|
1829
|
+
|
|
1830
|
+
// カンマなら飛ばす #877
|
|
1831
|
+
if (this.check('comma')) { this.get() }
|
|
1832
|
+
|
|
1833
|
+
// プリミティブな値
|
|
1834
|
+
if (this.checkTypes(['number', 'string'])) { return this.getCur() as Ast }
|
|
1835
|
+
|
|
1836
|
+
// 丸括弧
|
|
1837
|
+
if (this.check('(')) { return this.yValueKakko() }
|
|
1838
|
+
|
|
1839
|
+
// マイナス記号
|
|
1840
|
+
if (this.check2(['-', 'number']) || this.check2(['-', 'word']) || this.check2(['-', 'func'])) {
|
|
1841
|
+
const m = this.get() // skip '-'
|
|
1842
|
+
const v = this.yValue()
|
|
1843
|
+
const josi = (v && v.josi) ? v.josi : ''
|
|
1844
|
+
const line = (m && m.line) ? m.line : 0
|
|
1845
|
+
return {
|
|
1846
|
+
type: 'op',
|
|
1847
|
+
operator: '*',
|
|
1848
|
+
left: { type: 'number', value: -1, line },
|
|
1849
|
+
right: v || [],
|
|
1850
|
+
josi,
|
|
1851
|
+
...map,
|
|
1852
|
+
end: this.peekSourceMap()
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
// NOT
|
|
1856
|
+
if (this.check('not')) {
|
|
1857
|
+
this.get() // skip '!'
|
|
1858
|
+
const v = this.yValue()
|
|
1859
|
+
const josi = (v && v.josi) ? v.josi : ''
|
|
1860
|
+
return {
|
|
1861
|
+
type: 'not',
|
|
1862
|
+
value: v,
|
|
1863
|
+
josi,
|
|
1864
|
+
...map,
|
|
1865
|
+
end: this.peekSourceMap()
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
// JSON object
|
|
1869
|
+
const a = this.yJSONArray()
|
|
1870
|
+
if (a) { return a }
|
|
1871
|
+
const o = this.yJSONObject()
|
|
1872
|
+
if (o) { return o }
|
|
1873
|
+
// 一語関数
|
|
1874
|
+
const splitType = operatorList.concat(['eol', ')', ']', 'ならば', '回', '間', '反復', '条件分岐'])
|
|
1875
|
+
if (this.check2(['func', splitType])) {
|
|
1876
|
+
const tt = this.get()
|
|
1877
|
+
if (!tt) { throw new Error('[System Error] 正しく値が取れませんでした。') }
|
|
1878
|
+
const f = this.getVarNameRef(tt)
|
|
1879
|
+
this.usedFuncs.add(f.value)
|
|
1880
|
+
return {
|
|
1881
|
+
type: 'func',
|
|
1882
|
+
name: f.value,
|
|
1883
|
+
args: [],
|
|
1884
|
+
josi: f.josi,
|
|
1885
|
+
...map,
|
|
1886
|
+
end: this.peekSourceMap()
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
// C風関数呼び出し FUNC(...)
|
|
1890
|
+
if (this.check2([['func', 'word'], '(']) && this.peekDef().josi === '') {
|
|
1891
|
+
const f = this.peek()
|
|
1892
|
+
if (this.accept([['func', 'word'], '(', this.yGetArgParen, ')'])) {
|
|
1893
|
+
const funcName: string = this.getVarNameRef(this.y[0]).value
|
|
1894
|
+
this.usedFuncs.add(funcName)
|
|
1895
|
+
return {
|
|
1896
|
+
type: 'func',
|
|
1897
|
+
name: funcName,
|
|
1898
|
+
args: this.y[2],
|
|
1899
|
+
josi: this.y[3].josi,
|
|
1900
|
+
...map,
|
|
1901
|
+
end: this.peekSourceMap()
|
|
1902
|
+
}
|
|
1903
|
+
} else { throw NakoSyntaxError.fromNode('C風関数呼び出しのエラー', f || NewEmptyToken()) }
|
|
1904
|
+
}
|
|
1905
|
+
// 関数呼び出し演算子
|
|
1906
|
+
if (this.check2(['func', '←'])) { return this.yCallOp() }
|
|
1907
|
+
// 無名関数(関数オブジェクト)
|
|
1908
|
+
if (this.check('def_func')) { return this.yMumeiFunc() }
|
|
1909
|
+
// 変数
|
|
1910
|
+
const word = this.yValueWord()
|
|
1911
|
+
if (word) { return word }
|
|
1912
|
+
// その他
|
|
1913
|
+
return null
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1916
|
+
yValueWordGetIndex (ast: Ast): boolean {
|
|
1917
|
+
if (!ast.index) { ast.index = [] }
|
|
1918
|
+
// word @ a, b, c
|
|
1919
|
+
if (this.check('@')) {
|
|
1920
|
+
if (this.accept(['@', this.yValue, 'comma', this.yValue, 'comma', this.yValue])) {
|
|
1921
|
+
ast.index.push(this.checkArrayIndex(this.y[1]))
|
|
1922
|
+
ast.index.push(this.checkArrayIndex(this.y[3]))
|
|
1923
|
+
ast.index.push(this.checkArrayIndex(this.y[5]))
|
|
1924
|
+
ast.index = this.checkArrayReverse(ast.index)
|
|
1925
|
+
ast.josi = this.y[5].josi
|
|
1926
|
+
return true
|
|
1927
|
+
}
|
|
1928
|
+
if (this.accept(['@', this.yValue, 'comma', this.yValue])) {
|
|
1929
|
+
ast.index.push(this.checkArrayIndex(this.y[1]))
|
|
1930
|
+
ast.index.push(this.checkArrayIndex(this.y[3]))
|
|
1931
|
+
ast.index = this.checkArrayReverse(ast.index)
|
|
1932
|
+
ast.josi = this.y[3].josi
|
|
1933
|
+
return true
|
|
1934
|
+
}
|
|
1935
|
+
if (this.accept(['@', this.yValue])) {
|
|
1936
|
+
ast.index.push(this.checkArrayIndex(this.y[1]))
|
|
1937
|
+
ast.josi = this.y[1].josi
|
|
1938
|
+
return true
|
|
1939
|
+
}
|
|
1940
|
+
throw NakoSyntaxError.fromNode('変数の後ろの『@要素』の指定が不正です。', ast)
|
|
1941
|
+
}
|
|
1942
|
+
if (this.check('[')) {
|
|
1943
|
+
if (this.accept(['[', this.yCalc, ']'])) {
|
|
1944
|
+
ast.index.push(this.checkArrayIndex(this.y[1]))
|
|
1945
|
+
ast.josi = this.y[2].josi
|
|
1946
|
+
return true
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
if (this.check('[')) {
|
|
1950
|
+
if (this.accept(['[', this.yCalc, 'comma', this.yCalc, ']'])) {
|
|
1951
|
+
const index = [
|
|
1952
|
+
this.checkArrayIndex(this.y[1]),
|
|
1953
|
+
this.checkArrayIndex(this.y[3])
|
|
1954
|
+
]
|
|
1955
|
+
ast.index = this.checkArrayReverse(index)
|
|
1956
|
+
ast.josi = this.y[4].josi
|
|
1957
|
+
return true
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
if (this.check('[')) {
|
|
1961
|
+
if (this.accept(['[', this.yCalc, 'comma', this.yCalc, 'comma', this.yCalc, ']'])) {
|
|
1962
|
+
const index = [
|
|
1963
|
+
this.checkArrayIndex(this.y[1]),
|
|
1964
|
+
this.checkArrayIndex(this.y[3]),
|
|
1965
|
+
this.checkArrayIndex(this.y[5])
|
|
1966
|
+
]
|
|
1967
|
+
ast.index = this.checkArrayReverse(index)
|
|
1968
|
+
ast.josi = this.y[6].josi
|
|
1969
|
+
return true
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
return false
|
|
1973
|
+
}
|
|
1974
|
+
|
|
1975
|
+
/** @returns {Ast | null} */
|
|
1976
|
+
yValueWord (): Ast|null {
|
|
1977
|
+
const map = this.peekSourceMap()
|
|
1978
|
+
if (this.check('word')) {
|
|
1979
|
+
const t = this.getCur()
|
|
1980
|
+
const word = this.getVarNameRef(t)
|
|
1981
|
+
|
|
1982
|
+
// word[n] || word@n
|
|
1983
|
+
if (word.josi === '' && this.checkTypes(['[', '@'])) {
|
|
1984
|
+
const ast:Ast = {
|
|
1985
|
+
type: '配列参照',
|
|
1986
|
+
name: word,
|
|
1987
|
+
index: [],
|
|
1988
|
+
josi: '',
|
|
1989
|
+
...map,
|
|
1990
|
+
end: this.peekSourceMap()
|
|
1991
|
+
}
|
|
1992
|
+
while (!this.isEOF()) {
|
|
1993
|
+
if (!this.yValueWordGetIndex(ast)) { break }
|
|
1994
|
+
}
|
|
1995
|
+
if (ast.index && ast.index.length === 0) { throw NakoSyntaxError.fromNode(`配列『${word.value}』アクセスで指定ミス`, word) }
|
|
1996
|
+
return ast
|
|
1997
|
+
}
|
|
1998
|
+
return word as Ast
|
|
1999
|
+
}
|
|
2000
|
+
return null
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2003
|
+
/** 変数名を検索して解決する
|
|
2004
|
+
* @param {Ast|Token} word
|
|
2005
|
+
* @return {Ast|Token}
|
|
2006
|
+
*/
|
|
2007
|
+
getVarName (word: Token|Ast): Token|Ast {
|
|
2008
|
+
// check word name
|
|
2009
|
+
const f = this.findVar(word.value)
|
|
2010
|
+
if (!f) { // 変数が見つからない
|
|
2011
|
+
if (this.funcLevel === 0) { // global
|
|
2012
|
+
let gname = word.value
|
|
2013
|
+
if (gname.indexOf('__') < 0) { gname = this.modName + '__' + word.value }
|
|
2014
|
+
this.funclist[gname] = { type: 'var', value: '' }
|
|
2015
|
+
word.value = gname
|
|
2016
|
+
} else { // local
|
|
2017
|
+
this.localvars[word.value] = { type: 'var', value: '' }
|
|
2018
|
+
}
|
|
2019
|
+
} else if (f && f.scope === 'global') {
|
|
2020
|
+
word.value = f.name
|
|
2021
|
+
}
|
|
2022
|
+
return word
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
/** 変数名を検索して解決する */
|
|
2026
|
+
getVarNameRef (word: Token): Token {
|
|
2027
|
+
// check word name
|
|
2028
|
+
const f = this.findVar(word.value)
|
|
2029
|
+
if (!f) { // 変数が見つからない
|
|
2030
|
+
if (this.funcLevel === 0 && word.value.indexOf('__') < 0) {
|
|
2031
|
+
word.value = this.modName + '__' + word.value
|
|
2032
|
+
}
|
|
2033
|
+
} else if (f && f.scope === 'global') {
|
|
2034
|
+
word.value = f.name
|
|
2035
|
+
}
|
|
2036
|
+
return word
|
|
2037
|
+
}
|
|
2038
|
+
|
|
2039
|
+
/** 複数の変数名を検索して解決する */
|
|
2040
|
+
getVarNameList (words: Token[]): Token[] {
|
|
2041
|
+
for (let i = 0; i < words.length; i++) {
|
|
2042
|
+
words[i] = this.getVarName(words[i]) as Token
|
|
2043
|
+
}
|
|
2044
|
+
return words
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
yJSONObjectValue (): {key: Ast, value: Ast}[] |null {
|
|
2048
|
+
const a: {key: Ast, value: Ast}[] = []
|
|
2049
|
+
const firstToken = this.peek()
|
|
2050
|
+
if (!firstToken) { return null }
|
|
2051
|
+
while (!this.isEOF()) {
|
|
2052
|
+
while (this.check('eol')) { this.get() }
|
|
2053
|
+
if (this.check('}')) { break }
|
|
2054
|
+
if (this.accept(['word', ':', this.yCalc])) {
|
|
2055
|
+
this.y[0].type = 'string' // キー名の文字列記号省略の場合
|
|
2056
|
+
a.push({
|
|
2057
|
+
key: this.y[0],
|
|
2058
|
+
value: this.y[2]
|
|
2059
|
+
})
|
|
2060
|
+
} else if (this.accept(['string', ':', this.yCalc])) {
|
|
2061
|
+
a.push({
|
|
2062
|
+
key: this.y[0],
|
|
2063
|
+
value: this.y[2]
|
|
2064
|
+
})
|
|
2065
|
+
} else if (this.check('word')) {
|
|
2066
|
+
const w = this.getCur()
|
|
2067
|
+
w.type = 'string'
|
|
2068
|
+
a.push({
|
|
2069
|
+
key: w as Ast,
|
|
2070
|
+
value: w as Ast
|
|
2071
|
+
})
|
|
2072
|
+
} else if (this.checkTypes(['string', 'number'])) {
|
|
2073
|
+
const w = this.getCur()
|
|
2074
|
+
a.push({
|
|
2075
|
+
key: w as Ast,
|
|
2076
|
+
value: w as Ast
|
|
2077
|
+
})
|
|
2078
|
+
} else { throw NakoSyntaxError.fromNode('辞書オブジェクトの宣言で末尾の『}』がありません。', firstToken) }
|
|
2079
|
+
|
|
2080
|
+
if (this.check('comma')) { this.get() }
|
|
2081
|
+
}
|
|
2082
|
+
return a
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2085
|
+
/** @returns {Ast | null} */
|
|
2086
|
+
yJSONObject (): Ast | null {
|
|
2087
|
+
const map = this.peekSourceMap()
|
|
2088
|
+
if (this.accept(['{', '}'])) {
|
|
2089
|
+
return {
|
|
2090
|
+
type: 'json_obj',
|
|
2091
|
+
value: [],
|
|
2092
|
+
josi: this.y[1].josi,
|
|
2093
|
+
...map,
|
|
2094
|
+
end: this.peekSourceMap()
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
|
|
2098
|
+
if (this.accept(['{', this.yJSONObjectValue, '}'])) {
|
|
2099
|
+
return {
|
|
2100
|
+
type: 'json_obj',
|
|
2101
|
+
value: this.y[1],
|
|
2102
|
+
josi: this.y[2].josi,
|
|
2103
|
+
...map,
|
|
2104
|
+
end: this.peekSourceMap()
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2107
|
+
|
|
2108
|
+
// 辞書初期化に終わりがなかった場合 (エラーチェックのため) #958
|
|
2109
|
+
if (this.accept(['{', this.yJSONObjectValue])) {
|
|
2110
|
+
throw NakoSyntaxError.fromNode(
|
|
2111
|
+
'辞書型変数の初期化が『}』で閉じられていません。',
|
|
2112
|
+
this.y[1])
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
return null
|
|
2116
|
+
}
|
|
2117
|
+
|
|
2118
|
+
yJSONArrayValue (): Ast[] | null {
|
|
2119
|
+
if (this.check('eol')) { this.get() }
|
|
2120
|
+
const v1 = this.yCalc()
|
|
2121
|
+
if (v1 === null) { return null }
|
|
2122
|
+
if (this.check('comma')) { this.get() }
|
|
2123
|
+
const a: Ast[] = [v1]
|
|
2124
|
+
while (!this.isEOF()) {
|
|
2125
|
+
if (this.check('eol')) { this.get() }
|
|
2126
|
+
if (this.check(']')) { break }
|
|
2127
|
+
const v2 = this.yCalc()
|
|
2128
|
+
if (v2 === null) { break }
|
|
2129
|
+
if (this.check('comma')) { this.get() }
|
|
2130
|
+
a.push(v2)
|
|
2131
|
+
}
|
|
2132
|
+
return a
|
|
2133
|
+
}
|
|
2134
|
+
|
|
2135
|
+
/** @returns {Ast | null} */
|
|
2136
|
+
yJSONArray (): Ast | null {
|
|
2137
|
+
const map = this.peekSourceMap()
|
|
2138
|
+
if (this.accept(['[', ']'])) {
|
|
2139
|
+
return {
|
|
2140
|
+
type: 'json_array',
|
|
2141
|
+
value: [],
|
|
2142
|
+
josi: this.y[1].josi,
|
|
2143
|
+
...map,
|
|
2144
|
+
end: this.peekSourceMap()
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2148
|
+
if (this.accept(['[', this.yJSONArrayValue, ']'])) {
|
|
2149
|
+
return {
|
|
2150
|
+
type: 'json_array',
|
|
2151
|
+
value: this.y[1],
|
|
2152
|
+
josi: this.y[2].josi,
|
|
2153
|
+
...map,
|
|
2154
|
+
end: this.peekSourceMap()
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2157
|
+
// 配列に終わりがなかった場合 (エラーチェックのため) #958
|
|
2158
|
+
if (this.accept(['[', this.yJSONArrayValue])) {
|
|
2159
|
+
throw NakoSyntaxError.fromNode(
|
|
2160
|
+
'配列変数の初期化が『]』で閉じられていません。',
|
|
2161
|
+
this.y[1])
|
|
2162
|
+
}
|
|
2163
|
+
|
|
2164
|
+
return null
|
|
2165
|
+
}
|
|
2166
|
+
|
|
2167
|
+
/** エラー監視構文 */
|
|
2168
|
+
yTryExcept (): Ast | null {
|
|
2169
|
+
const map = this.peekSourceMap()
|
|
2170
|
+
if (!this.check('エラー監視')) { return null }
|
|
2171
|
+
const kansi = this.getCur() // skip エラー監視
|
|
2172
|
+
const block = this.yBlock()
|
|
2173
|
+
if (!this.check2(['エラー', 'ならば'])) {
|
|
2174
|
+
throw NakoSyntaxError.fromNode(
|
|
2175
|
+
'エラー構文で『エラーならば』がありません。' +
|
|
2176
|
+
'『エラー監視..エラーならば..ここまで』を対で記述します。',
|
|
2177
|
+
kansi)
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
this.get() // skip エラー
|
|
2181
|
+
this.get() // skip ならば
|
|
2182
|
+
const errBlock = this.yBlock()
|
|
2183
|
+
if (this.check('ここまで')) {
|
|
2184
|
+
this.get()
|
|
2185
|
+
} else {
|
|
2186
|
+
throw NakoSyntaxError.fromNode('『ここまで』がありません。『エラー監視』...『エラーならば』...『ここまで』を対応させてください。', map)
|
|
2187
|
+
}
|
|
2188
|
+
return {
|
|
2189
|
+
type: 'try_except',
|
|
2190
|
+
block,
|
|
2191
|
+
errBlock: errBlock || [],
|
|
2192
|
+
josi: '',
|
|
2193
|
+
...map,
|
|
2194
|
+
end: this.peekSourceMap()
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
}
|