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