nadesiko3 3.2.27
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 -0
- package/README.md +107 -0
- package/bin/cnako3 +10 -0
- package/bin/cnako3.bat +11 -0
- package/bin/nako3server.bat +6 -0
- package/demo/ace_editor.html +90 -0
- package/demo/ace_editor_tabs.html +162 -0
- package/demo/basic.html +71 -0
- package/demo/browsers.html +128 -0
- package/demo/css/basic.css +3 -0
- package/demo/css/common.css +157 -0
- package/demo/css/editor.css +8 -0
- package/demo/css/flow.css +3 -0
- package/demo/css/index.css +3 -0
- package/demo/extlib/ace@1.4.12/ace.js +17 -0
- package/demo/extlib/ace@1.4.12/ext-code_lens.min.js +1 -0
- package/demo/extlib/ace@1.4.12/ext-language_tools.min.js +1 -0
- package/demo/extlib/ace@1.4.12/ext-options.min.js +1 -0
- package/demo/extlib/ace@1.4.12/ext-settings_menu.js +8 -0
- package/demo/extlib/ace@1.4.12/keybinding-vscode.js +8 -0
- package/demo/extlib/ace@1.4.12/theme-monokai.js +8 -0
- package/demo/extlib/ace@1.4.12/theme-xcode.js +8 -0
- package/demo/extlib/chart.js@3.2.1/chart.min.js +13 -0
- package/demo/extlib/pure-min.css +11 -0
- package/demo/flow.html +97 -0
- package/demo/graph.html +53 -0
- package/demo/image/nako.png +0 -0
- package/demo/image/nakopad-icon256.png +0 -0
- package/demo/image/turtle.fla +0 -0
- package/demo/image/turtle.png +0 -0
- package/demo/index.html +134 -0
- package/demo/js/common.js +17 -0
- package/demo/js/turtle3d_test.js +44 -0
- package/demo/js/turtle_test.js +44 -0
- package/demo/runscript.html +47 -0
- package/demo/runscript2.html +33 -0
- package/demo/turtle.html +58 -0
- package/demo/turtle2.html +141 -0
- package/demo/turtle3.html +278 -0
- package/demo/turtle3d.html +58 -0
- package/demo/turtle3d2.html +107 -0
- package/demo/version.html +24 -0
- package/doc/SETUP.md +172 -0
- package/doc/about.md +34 -0
- package/doc/browsers.md +60 -0
- package/doc/docgen.md +21 -0
- package/doc/editor.md +44 -0
- package/doc/files.md +37 -0
- package/doc/plugins.md +195 -0
- package/doc/release.md +78 -0
- package/doc/win32.md +57 -0
- package/package.json +196 -0
- package/release/_hash.txt +65 -0
- package/release/_script-tags.txt +13 -0
- package/release/command.json +1 -0
- package/release/command.json.js +1 -0
- package/release/command_cnako3.json +1 -0
- package/release/command_list.json +1 -0
- package/release/editor.js +2 -0
- package/release/editor.js.LICENSE.txt +32 -0
- package/release/josi.json +48 -0
- package/release/nako_gen_async.js +1 -0
- package/release/nako_gen_async.js.LICENSE.txt +595 -0
- package/release/plugin_caniuse.js +1 -0
- package/release/plugin_caniuse.js.LICENSE.txt +411 -0
- package/release/plugin_csv.js +1 -0
- package/release/plugin_csv.js.LICENSE.txt +367 -0
- package/release/plugin_datetime.js +1 -0
- package/release/plugin_datetime.js.LICENSE.txt +471 -0
- package/release/plugin_kansuji.js +1 -0
- package/release/plugin_kansuji.js.LICENSE.txt +491 -0
- package/release/plugin_markup.js +1 -0
- package/release/plugin_markup.js.LICENSE.txt +363 -0
- package/release/plugin_turtle.js +1 -0
- package/release/plugin_turtle.js.LICENSE.txt +435 -0
- package/release/plugin_webworker.js +1 -0
- package/release/plugin_webworker.js.LICENSE.txt +491 -0
- package/release/version.js +2 -0
- package/release/version.js.LICENSE.txt +32 -0
- package/release/wnako3.js +2 -0
- package/release/wnako3.js.LICENSE.txt +1 -0
- package/release/wnako3webworker.js +1 -0
- package/release/wnako3webworker.js.LICENSE.txt +847 -0
- package/release/yoyakugo.json +30 -0
- package/src/browsers.md +60 -0
- package/src/cnako3.js +466 -0
- package/src/commander_ja.js +154 -0
- package/src/enako3.js +69 -0
- package/src/era.json +22 -0
- package/src/index.js +5 -0
- package/src/nako3.js +836 -0
- package/src/nako3_assert.js +37 -0
- package/src/nako3editorfix.sfd +106 -0
- package/src/nako3editorfix.woff +0 -0
- package/src/nako3server.js +51 -0
- package/src/nako_colors.js +86 -0
- package/src/nako_errors.js +176 -0
- package/src/nako_gen.js +1459 -0
- package/src/nako_gen_async.js +1622 -0
- package/src/nako_global.js +113 -0
- package/src/nako_indent.js +480 -0
- package/src/nako_josi_list.js +46 -0
- package/src/nako_lex_rules.js +259 -0
- package/src/nako_lexer.js +576 -0
- package/src/nako_logger.js +138 -0
- package/src/nako_parser3.js +1768 -0
- package/src/nako_parser_base.js +265 -0
- package/src/nako_parser_const.js +37 -0
- package/src/nako_prepare.js +293 -0
- package/src/nako_reserved_words.js +35 -0
- package/src/nako_source_mapping.js +251 -0
- package/src/nako_test.js +37 -0
- package/src/nako_version.js +8 -0
- package/src/plugin_browser.js +191 -0
- package/src/plugin_browser_ajax.js +352 -0
- package/src/plugin_browser_audio.js +109 -0
- package/src/plugin_browser_canvas.js +462 -0
- package/src/plugin_browser_chart.js +296 -0
- package/src/plugin_browser_color.js +49 -0
- package/src/plugin_browser_crypto.js +26 -0
- package/src/plugin_browser_dialog.js +53 -0
- package/src/plugin_browser_dom_basic.js +322 -0
- package/src/plugin_browser_dom_event.js +193 -0
- package/src/plugin_browser_dom_parts.js +163 -0
- package/src/plugin_browser_geolocation.js +51 -0
- package/src/plugin_browser_hotkey.js +25 -0
- package/src/plugin_browser_html.js +59 -0
- package/src/plugin_browser_in_worker.js +44 -0
- package/src/plugin_browser_location.js +21 -0
- package/src/plugin_browser_speech.js +111 -0
- package/src/plugin_browser_storage.js +121 -0
- package/src/plugin_browser_system.js +12 -0
- package/src/plugin_browser_websocket.js +73 -0
- package/src/plugin_caniuse.js +24 -0
- package/src/plugin_csv.js +57 -0
- package/src/plugin_datetime.js +414 -0
- package/src/plugin_express.js +212 -0
- package/src/plugin_kansuji.js +224 -0
- package/src/plugin_keigo.js +55 -0
- package/src/plugin_markup.js +32 -0
- package/src/plugin_math.js +319 -0
- package/src/plugin_node.js +1018 -0
- package/src/plugin_promise.js +94 -0
- package/src/plugin_system.js +2109 -0
- package/src/plugin_test.js +38 -0
- package/src/plugin_turtle.js +646 -0
- package/src/plugin_webworker.js +334 -0
- package/src/plugin_weykturtle3d.js +1216 -0
- package/src/plugin_worker.js +92 -0
- package/src/repl.nako3 +63 -0
- package/src/turtle-elephant.png +0 -0
- package/src/turtle-panda.png +0 -0
- package/src/turtle64.png +0 -0
- package/src/wnako3.js +162 -0
- package/src/wnako3_editor.css +215 -0
- package/src/wnako3_editor.js +1645 -0
- package/src/wnako3_editor_marker_red.png +0 -0
- package/src/wnako3_editor_marker_red.xcf +0 -0
- package/src/wnako3_editor_marker_yellow.png +0 -0
- package/src/wnako3_editor_marker_yellow.xcf +0 -0
- package/src/wnako3webworker.js +70 -0
- package/test/ace_editor/karma.config.js +94 -0
- package/test/ace_editor/test/.babelrc.json +3 -0
- package/test/ace_editor/test/ace_editor_test.js +178 -0
- package/test/ace_editor/test/html/custom_context.html +140 -0
- package/test/async/async_basic_test.js +124 -0
- package/test/browser/karma.config.js +212 -0
- package/test/browser/test/.babelrc.json +3 -0
- package/test/browser/test/compare_util.js +50 -0
- package/test/browser/test/html/canvas_basic.html +1 -0
- package/test/browser/test/html/div_basic.html +2 -0
- package/test/browser/test/html/event_dom_form.html +4 -0
- package/test/browser/test/html/event_dom_scrolldiv.html +5 -0
- package/test/browser/test/image/canvas_test1.png +0 -0
- package/test/browser/test/image/canvas_test2.png +0 -0
- package/test/browser/test/image/canvas_test3.png +0 -0
- package/test/browser/test/image/canvas_test4.png +0 -0
- package/test/browser/test/image/canvas_test7.png +0 -0
- package/test/browser/test/image/canvas_test8.png +0 -0
- package/test/browser/test/image/canvas_test_blank.png +0 -0
- package/test/browser/test/image/elephant_kana.png +0 -0
- package/test/browser/test/image/panda_kana.png +0 -0
- package/test/browser/test/image/turtle_kana.png +0 -0
- package/test/browser/test/import_plugin_checker.js +24 -0
- package/test/browser/test/plugin_browser_test.js +52 -0
- package/test/browser/test/plugin_browser_test_ajax.js +123 -0
- package/test/browser/test/plugin_browser_test_color.js +18 -0
- package/test/browser/test/plugin_browser_test_dialog.js +72 -0
- package/test/browser/test/plugin_browser_test_dom_event.js +598 -0
- package/test/browser/test/plugin_browser_test_dom_parts.js +125 -0
- package/test/browser/test/plugin_browser_test_system.js +9 -0
- package/test/browser/test/plugin_turtle_test.js +817 -0
- package/test/browser/test/plugin_webworker_test.js +87 -0
- package/test/browser/test/require_test.js +71 -0
- package/test/bundled/karma.config.base.js +117 -0
- package/test/bundled/karma.config.js +86 -0
- package/test/bundled/test/.babelrc.json +3 -0
- package/test/bundled/test/bundled_test.js +69 -0
- package/test/bundled/test/html/custom_context.html +65 -0
- package/test/bundled/test/html/custom_debug.html +66 -0
- package/test/bundled/test4b.cmd +52 -0
- package/test/bundled/test_base/.babelrc.json +3 -0
- package/test/bundled/test_base/_checktool_test.js +25 -0
- package/test/bundled/test_base/basic_ajax_test.js +56 -0
- package/test/bundled/test_base/basic_async_test.js +18 -0
- package/test/bundled/test_base/basic_test.js +153 -0
- package/test/bundled/test_base/calc_test.js +132 -0
- package/test/bundled/test_base/css/browsers_box.css +114 -0
- package/test/bundled/test_base/html/custom_context.html +69 -0
- package/test/bundled/test_base/html/custom_debug.html +71 -0
- package/test/bundled/test_base/js/browsers_box.js +72 -0
- package/test/bundled/test_base/plugin_csv_test.js +37 -0
- package/test/bundled/test_base/plugin_datetime_test.js +115 -0
- package/test/bundled/test_base/plugin_kansuji_test.js +49 -0
- package/test/bundled/test_base/plugin_system_test.js +410 -0
- package/test/bundled/test_base/plugin_webworker_test.js +53 -0
- package/test/bundled/test_base/resources/ok.txt +1 -0
- package/test/bundled/test_base/test_utils.js +191 -0
- package/test/common/array_test.js +40 -0
- package/test/common/basic_test.js +317 -0
- package/test/common/calc_test.js +139 -0
- package/test/common/debug_test.js +16 -0
- package/test/common/error_test.js +16 -0
- package/test/common/flow_test.js +360 -0
- package/test/common/func_call.js +136 -0
- package/test/common/func_test.js +149 -0
- package/test/common/indent_test.js +362 -0
- package/test/common/lex_test.js +146 -0
- package/test/common/literal_test.js +72 -0
- package/test/common/nako_logger_test.js +26 -0
- package/test/common/plugin_browser_test.js +24 -0
- package/test/common/plugin_browser_ut_audio_test.js +88 -0
- package/test/common/plugin_browser_ut_color_test.js +21 -0
- package/test/common/plugin_browser_ut_dialog_test.js +100 -0
- package/test/common/plugin_browser_ut_html_test.js +13 -0
- package/test/common/plugin_browser_ut_system_test.js +10 -0
- package/test/common/plugin_csv_test.js +39 -0
- package/test/common/plugin_datetime_test.js +120 -0
- package/test/common/plugin_kansuji_test.js +59 -0
- package/test/common/plugin_promise_test.js +18 -0
- package/test/common/plugin_system_test.js +451 -0
- package/test/common/prepare_test.js +93 -0
- package/test/common/re_test.js +20 -0
- package/test/common/variable_scope_test.js +105 -0
- package/test/jsconfig.json +19 -0
- package/test/karma.config.js +91 -0
- package/test/node/add_test.nako3 +1 -0
- package/test/node/async_test.js +80 -0
- package/test/node/commander_ja_test.js +82 -0
- package/test/node/error_message_test.js +244 -0
- package/test/node/kai_test.nako3 +6 -0
- package/test/node/node_test.js +43 -0
- package/test/node/plugin_broken.js.txt +3 -0
- package/test/node/plugin_browser_ut_ajax_test.js +355 -0
- package/test/node/plugin_browser_ut_location_test.js +32 -0
- package/test/node/plugin_markup_test.js +44 -0
- package/test/node/plugin_math_test.js +42 -0
- package/test/node/plugin_node_test.js +93 -0
- package/test/node/plugin_test.js +16 -0
- package/test/node/relative_import_test_1.nako3 +1 -0
- package/test/node/relative_import_test_2.nako3 +2 -0
- package/test/node/require_nako3_test.js +59 -0
- package/test/node/requiretest.nako3 +4 -0
- package/test/node/requiretest_indirect.nako3 +1 -0
- package/test/node/requiretest_name.nako3 +5 -0
- package/test/node/runtime_error.nako3 +2 -0
- package/test/node/side_effects_test.js +106 -0
- package/test/node/sjis.txt +5 -0
- package/test/node/syntax_error.nako3 +2 -0
- package/test/node/wnako3_editor_test.js +360 -0
- package/tools/README.md +7 -0
- package/tools/nako3edit/html/edit.html +83 -0
- package/tools/nako3edit/html/edit_plugin.js +6 -0
- package/tools/nako3edit/html/files.html +49 -0
- package/tools/nako3edit/html/nako3edit.css +66 -0
- package/tools/nako3edit/index.nako3 +145 -0
- package/tools/nako3edit/run.js +12 -0
- package/tools/nako3server/html/edit.html +104 -0
- package/tools/nako3server/html/edit_plugin.js +6 -0
- package/tools/nako3server/html/files.html +53 -0
- package/tools/nako3server/html/nako3edit.css +66 -0
- package/tools/nako3server/index.nako3 +129 -0
- package/tools/nako3server/run.js +12 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* eslint-disable quote-props */
|
|
2
|
+
/**
|
|
3
|
+
* Assert対応のなでしこ
|
|
4
|
+
*/
|
|
5
|
+
const assert = require('assert')
|
|
6
|
+
const path = require('path')
|
|
7
|
+
const NakoCompiler = require(path.join(__dirname, 'nako3'))
|
|
8
|
+
|
|
9
|
+
const PluginAssert = {
|
|
10
|
+
'初期化': {
|
|
11
|
+
type: 'func',
|
|
12
|
+
josi: [],
|
|
13
|
+
fn: function (sys) {
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
// @Assert
|
|
17
|
+
'NAKO3ASSERTバージョン': { type: 'const', value: 0.01 },
|
|
18
|
+
'テスト': { // AとBが等しいかテスト // @てすと
|
|
19
|
+
type: 'func',
|
|
20
|
+
josi: [['と'], ['で']],
|
|
21
|
+
fn: function (a, b, sys) {
|
|
22
|
+
assert.strictEqual(a, b)
|
|
23
|
+
},
|
|
24
|
+
return_none: true
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
class Nako3Assert extends NakoCompiler {
|
|
29
|
+
constructor () {
|
|
30
|
+
super()
|
|
31
|
+
this.silent = true
|
|
32
|
+
this.addPluginFile('PluginAssert', path.join(__dirname, 'nako3_assert.js'), PluginAssert)
|
|
33
|
+
this.__varslist[0]['ナデシコ種類'] = 'nako3_assert'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = Nako3Assert
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
SplineFontDB: 3.2
|
|
2
|
+
FontName: nako3editorfix
|
|
3
|
+
FullName: nako3editorfix
|
|
4
|
+
FamilyName: nako3editorfix
|
|
5
|
+
Weight: Regular
|
|
6
|
+
Copyright: MIT License\nCopyright (c) 2021, yy0931\n
|
|
7
|
+
UComments: "2021-3-4: Created with FontForge (http://fontforge.org)"
|
|
8
|
+
Version: 001.000
|
|
9
|
+
ItalicAngle: 0
|
|
10
|
+
UnderlinePosition: -100
|
|
11
|
+
UnderlineWidth: 50
|
|
12
|
+
Ascent: 800
|
|
13
|
+
Descent: 200
|
|
14
|
+
InvalidEm: 0
|
|
15
|
+
LayerCount: 2
|
|
16
|
+
Layer: 0 0 "Back" 1
|
|
17
|
+
Layer: 1 0 "Fore" 0
|
|
18
|
+
XUID: [1021 548 -260896367 14412733]
|
|
19
|
+
FSType: 0
|
|
20
|
+
OS2Version: 0
|
|
21
|
+
OS2_WeightWidthSlopeOnly: 0
|
|
22
|
+
OS2_UseTypoMetrics: 1
|
|
23
|
+
CreationTime: 1614788066
|
|
24
|
+
ModificationTime: 1614792123
|
|
25
|
+
PfmFamily: 17
|
|
26
|
+
TTFWeight: 400
|
|
27
|
+
TTFWidth: 5
|
|
28
|
+
LineGap: 90
|
|
29
|
+
VLineGap: 0
|
|
30
|
+
OS2TypoAscent: 0
|
|
31
|
+
OS2TypoAOffset: 1
|
|
32
|
+
OS2TypoDescent: 0
|
|
33
|
+
OS2TypoDOffset: 1
|
|
34
|
+
OS2TypoLinegap: 90
|
|
35
|
+
OS2WinAscent: 0
|
|
36
|
+
OS2WinAOffset: 1
|
|
37
|
+
OS2WinDescent: 0
|
|
38
|
+
OS2WinDOffset: 1
|
|
39
|
+
HheadAscent: 0
|
|
40
|
+
HheadAOffset: 1
|
|
41
|
+
HheadDescent: 0
|
|
42
|
+
HheadDOffset: 1
|
|
43
|
+
OS2Vendor: 'PfEd'
|
|
44
|
+
MarkAttachClasses: 1
|
|
45
|
+
DEI: 91125
|
|
46
|
+
LangName: 1033
|
|
47
|
+
Encoding: Custom
|
|
48
|
+
UnicodeInterp: none
|
|
49
|
+
NameList: AGL For New Fonts
|
|
50
|
+
DisplaySize: -48
|
|
51
|
+
AntiAlias: 1
|
|
52
|
+
FitToEm: 0
|
|
53
|
+
WinInfo: 0 35 14
|
|
54
|
+
BeginPrivate: 0
|
|
55
|
+
EndPrivate
|
|
56
|
+
TeXData: 1 0 0 346030 173015 115343 0 1048576 115343 783286 444596 497025 792723 393216 433062 380633 303038 157286 324010 404750 52429 2506097 1059062 262144
|
|
57
|
+
BeginChars: 256 1
|
|
58
|
+
|
|
59
|
+
StartChar: referencemark
|
|
60
|
+
Encoding: 0 8251 0
|
|
61
|
+
Width: 502
|
|
62
|
+
VWidth: 0
|
|
63
|
+
Flags: W
|
|
64
|
+
HStem: -0.288086 103.478<220.624 286.161> 303.245 103.478<46.0534 111.589 406.038 469.011> 583.324 103.478<220.624 286.161>
|
|
65
|
+
VStem: 38.8916 80.8984<308.115 400.698> 213.462 80.8994<4.58193 97.1645 588.194 680.777> 397.613 80.8984<305.356 397.939>
|
|
66
|
+
LayerCount: 2
|
|
67
|
+
Fore
|
|
68
|
+
SplineSet
|
|
69
|
+
253.912109375 103.189453125 m 0
|
|
70
|
+
277.330078125 103.189453125 294.361328125 78.3544921875 294.361328125 49.3798828125 c 0
|
|
71
|
+
294.361328125 21.7861328125 279.458984375 -0.2880859375 253.912109375 -0.2880859375 c 0
|
|
72
|
+
230.493164062 -0.2880859375 213.461914062 16.267578125 213.461914062 49.3798828125 c 0
|
|
73
|
+
213.461914062 78.3544921875 227.30078125 103.189453125 253.912109375 103.189453125 c 0
|
|
74
|
+
79.3408203125 406.72265625 m 0
|
|
75
|
+
102.758789062 406.72265625 119.790039062 381.887695312 119.790039062 352.915039062 c 0
|
|
76
|
+
119.790039062 325.3203125 104.887695312 303.245117188 79.3408203125 303.245117188 c 0
|
|
77
|
+
55.9228515625 303.245117188 38.8916015625 319.801757812 38.8916015625 352.915039062 c 0
|
|
78
|
+
38.8916015625 381.887695312 52.7294921875 406.72265625 79.3408203125 406.72265625 c 0
|
|
79
|
+
438.0625 403.963867188 m 0
|
|
80
|
+
461.48046875 403.963867188 478.51171875 379.12890625 478.51171875 350.154296875 c 0
|
|
81
|
+
478.51171875 322.560546875 463.610351562 300.486328125 438.0625 300.486328125 c 0
|
|
82
|
+
414.645507812 300.486328125 397.61328125 317.041992188 397.61328125 350.154296875 c 0
|
|
83
|
+
397.61328125 379.12890625 411.451171875 403.963867188 438.0625 403.963867188 c 0
|
|
84
|
+
253.912109375 686.801757812 m 0
|
|
85
|
+
277.330078125 686.801757812 294.361328125 661.966796875 294.361328125 632.993164062 c 0
|
|
86
|
+
294.361328125 605.399414062 279.458984375 583.32421875 253.912109375 583.32421875 c 0
|
|
87
|
+
230.493164062 583.32421875 213.461914062 599.879882812 213.461914062 632.993164062 c 0
|
|
88
|
+
213.461914062 661.966796875 227.30078125 686.801757812 253.912109375 686.801757812 c 0
|
|
89
|
+
251.783203125 401.203125 m 1
|
|
90
|
+
414.645507812 639.891601562 l 1
|
|
91
|
+
450.8359375 590.22265625 l 1
|
|
92
|
+
286.91015625 347.395507812 l 1
|
|
93
|
+
444.44921875 93.53125 l 1
|
|
94
|
+
404 48 l 1
|
|
95
|
+
252.84765625 297.7265625 l 1
|
|
96
|
+
98.5009765625 48 l 1
|
|
97
|
+
59.1171875 100.428710938 l 1
|
|
98
|
+
214.52734375 351.534179688 l 1
|
|
99
|
+
70.8251953125 592.981445312 l 1
|
|
100
|
+
110.209960938 641.271484375 l 1
|
|
101
|
+
251.783203125 401.203125 l 1
|
|
102
|
+
EndSplineSet
|
|
103
|
+
Validated: 524289
|
|
104
|
+
EndChar
|
|
105
|
+
EndChars
|
|
106
|
+
EndSplineFont
|
|
Binary file
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** なでしこ3簡易EXPRESSサーバー */
|
|
3
|
+
|
|
4
|
+
const express = require('express')
|
|
5
|
+
const app = express()
|
|
6
|
+
|
|
7
|
+
// set static
|
|
8
|
+
const path = require('path')
|
|
9
|
+
const rootDir = path.resolve(path.join(__dirname, '../'))
|
|
10
|
+
app.use(express.static(rootDir))
|
|
11
|
+
console.log('documentRoot:', rootDir)
|
|
12
|
+
|
|
13
|
+
// ライブラリがあるかチェック
|
|
14
|
+
const fs = require('fs')
|
|
15
|
+
if (!fs.existsSync(path.resolve(rootDir, 'extlib/pure.min.css'))) {
|
|
16
|
+
const execSync = require('child_process').execSync;
|
|
17
|
+
execSync('npm run extlib:install')
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// root => redirect
|
|
21
|
+
app.get('/', function (req, res) {
|
|
22
|
+
res.redirect(302, 'demo/')
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
// start server
|
|
26
|
+
let port = 3000
|
|
27
|
+
let server = null
|
|
28
|
+
const callbackStart = () => {
|
|
29
|
+
const opener = require('opener')
|
|
30
|
+
const port = server.address().port
|
|
31
|
+
console.log('+ サーバーを開始しました')
|
|
32
|
+
console.log('+ [URL] http://localhost:%s', port)
|
|
33
|
+
opener('http://localhost:' + port)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
server = app
|
|
37
|
+
.listen(port, callbackStart)
|
|
38
|
+
.on('error', () => {
|
|
39
|
+
port += 1
|
|
40
|
+
server = app
|
|
41
|
+
.listen(port, callbackStart)
|
|
42
|
+
.on('error', () => {
|
|
43
|
+
port += 1
|
|
44
|
+
server = app
|
|
45
|
+
.listen(port, callbackStart)
|
|
46
|
+
.on('error', (e) => {
|
|
47
|
+
console.log('サーバーを起動できませんでした。')
|
|
48
|
+
console.log(e.toString())
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
})
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ブラウザとNode.jsでテキストへの色付けを共通化するためのコード
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* ANSI escape code の一部
|
|
7
|
+
*/
|
|
8
|
+
const color = { reset: '\x1b[0m', bold: '\x1b[1m', black: '\x1b[30m', red: '\x1b[31m', green: '\x1b[32m', yellow: '\x1b[33m', blue: '\x1b[34m', magenta: '\x1b[35m', cyan: '\x1b[36m', white: '\x1b[37m' }
|
|
9
|
+
|
|
10
|
+
// 30 ~ 37
|
|
11
|
+
const colorNames = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white']
|
|
12
|
+
|
|
13
|
+
/** @param {string} t */
|
|
14
|
+
const escapeHTML = (t) => t.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''')
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* ANSI escape code で色付けしたテキストを、HTMLやブラウザのconsole.log用のフォーマットに変換する。
|
|
18
|
+
* たとえば `convertColorTextFormat(`foo${color.red}bar`).html` で `"foobar"` の `"bar"` の部分が赤く表示されるHTMLを取得できる。
|
|
19
|
+
* @param {string} text
|
|
20
|
+
* @returns {{ nodeConsole: string, noColor: string, html: string, browserConsole: string[] }}
|
|
21
|
+
*/
|
|
22
|
+
const convertColorTextFormat = (text) => {
|
|
23
|
+
// textから [ANSI escape code](https://en.wikipedia.org/wiki/ANSI_escape_code) を削除して、色の無いテキストを作る。
|
|
24
|
+
// eslint-disable-next-line no-control-regex
|
|
25
|
+
const noColor = text.replace(/\x1b\[\d+m/g, '')
|
|
26
|
+
|
|
27
|
+
// nodeConsoleからbrowserConsoleを作る
|
|
28
|
+
/** @type {string[]} */
|
|
29
|
+
const browserConsoleStyles = []
|
|
30
|
+
let consoleColor = 'inherit' // 文字色
|
|
31
|
+
let consoleFontWeight = 'inherit' // 文字の太さ
|
|
32
|
+
// /\x1b\[(\d+)m/ で正規表現マッチし、それぞれを %c で置換すると同時に browserConsoleStyles にCSSでの表現をpushする。
|
|
33
|
+
// console.log(browserConsoleText, ...browserConsoleStyles) で表示することを想定。
|
|
34
|
+
const browserConsoleText = text === noColor
|
|
35
|
+
? noColor
|
|
36
|
+
// eslint-disable-next-line no-control-regex
|
|
37
|
+
: text.replace(/\x1b\[(\d+)m/g, (_, m1str) => {
|
|
38
|
+
const m1 = +m1str
|
|
39
|
+
if (m1 === 0) {
|
|
40
|
+
consoleColor = 'inherit'
|
|
41
|
+
consoleFontWeight = 'inherit'
|
|
42
|
+
}
|
|
43
|
+
if (m1 === 1) {
|
|
44
|
+
consoleFontWeight = 'bold'
|
|
45
|
+
}
|
|
46
|
+
if (m1 >= 30 && m1 <= 37) {
|
|
47
|
+
consoleColor = colorNames[m1 - 30]
|
|
48
|
+
}
|
|
49
|
+
browserConsoleStyles.push(`color: ${consoleColor}; font-weight: ${consoleFontWeight};`)
|
|
50
|
+
return '%c'
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
// nodeConsoleからhtmlを作る
|
|
54
|
+
let htmlColor = 'inherit' // 文字色
|
|
55
|
+
let htmlFontWeight = 'inherit' // 文字の太さ
|
|
56
|
+
// textが色情報を含まないならそれをそのまま使い、含むなら全体を <span>で囲んで、更に、ANSI escape code で囲まれた部分を対応する style を付けた <span> で囲む。
|
|
57
|
+
// eslint-disable-next-line multiline-ternary
|
|
58
|
+
const html = text === noColor ? noColor : ('<span>' + escapeHTML(text)
|
|
59
|
+
// eslint-disable-next-line no-control-regex
|
|
60
|
+
.replace(/\x1b\[(\d+)m/g, (_, m1str) => { // ANSI escape code(の一部)にマッチして置換
|
|
61
|
+
const m1 = +m1str
|
|
62
|
+
if (m1 === 0) { // リセット
|
|
63
|
+
htmlColor = 'inherit'
|
|
64
|
+
htmlFontWeight = 'inherit'
|
|
65
|
+
}
|
|
66
|
+
if (m1 === 1) { // 太字化
|
|
67
|
+
htmlFontWeight = 'bold'
|
|
68
|
+
}
|
|
69
|
+
if (m1 >= 30 && m1 <= 37) { // 文字色の変更
|
|
70
|
+
htmlColor = colorNames[m1 - 30]
|
|
71
|
+
}
|
|
72
|
+
return `</span><span style="color: ${htmlColor}; font-weight: ${htmlFontWeight};">`
|
|
73
|
+
}) + '</span>')
|
|
74
|
+
|
|
75
|
+
// 各表現を返す。
|
|
76
|
+
return {
|
|
77
|
+
noColor,
|
|
78
|
+
nodeConsole: text === noColor
|
|
79
|
+
? noColor // textが色の情報を含まないならnoColorを返す。
|
|
80
|
+
: text + '\x1b[0m', // そうでなければtextの末尾に色をリセットするコードを付けて返す。
|
|
81
|
+
html,
|
|
82
|
+
browserConsole: [browserConsoleText, ...browserConsoleStyles]
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
module.exports = { convertColorTextFormat, colorNames, color }
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
const nakoVersion = require('./nako_version')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* なでしこ言語が投げる全てのエラーが継承するクラス
|
|
5
|
+
*/
|
|
6
|
+
class NakoError extends Error {
|
|
7
|
+
/**
|
|
8
|
+
* @param {string} tag
|
|
9
|
+
* @param {string} msg
|
|
10
|
+
* @param {string | undefined} file
|
|
11
|
+
* @param {number | undefined} line
|
|
12
|
+
*/
|
|
13
|
+
constructor (tag, msg, file, line) {
|
|
14
|
+
const positionJa = `${file || ''}${line === undefined ? '' : `(${line + 1}行目): `}`
|
|
15
|
+
super(`[${tag}]${positionJa}${msg}\n[バージョン] ${nakoVersion.version}`)
|
|
16
|
+
this.tag = '[' + tag + ']'
|
|
17
|
+
this.positionJa = positionJa
|
|
18
|
+
this.msg = msg
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
class NakoIndentError extends NakoError {
|
|
23
|
+
/**
|
|
24
|
+
* @param {string} msg
|
|
25
|
+
* @param {number} line
|
|
26
|
+
* @param {string} file
|
|
27
|
+
*/
|
|
28
|
+
constructor (msg, line, file) {
|
|
29
|
+
super('インデントエラー', msg, file, line)
|
|
30
|
+
this.line = line
|
|
31
|
+
this.file = file
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// コンパイラの内部でのみ使うエラー。投げられたらtryでキャッチしてLexerErrorへ変更する。
|
|
36
|
+
class InternalLexerError extends NakoError {
|
|
37
|
+
/**
|
|
38
|
+
* @param {string} msg
|
|
39
|
+
* @param {number} preprocessedCodeStartOffset
|
|
40
|
+
* @param {number} preprocessedCodeEndOffset
|
|
41
|
+
* @param {number | undefined} [line]
|
|
42
|
+
* @param {string | undefined} [file]
|
|
43
|
+
*/
|
|
44
|
+
constructor (msg, preprocessedCodeStartOffset, preprocessedCodeEndOffset, line, file) {
|
|
45
|
+
super('字句解析エラー(内部エラー)', msg, file, line)
|
|
46
|
+
this.preprocessedCodeStartOffset = preprocessedCodeStartOffset
|
|
47
|
+
this.preprocessedCodeEndOffset = preprocessedCodeEndOffset
|
|
48
|
+
this.line = line
|
|
49
|
+
this.file = file
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
class NakoLexerError extends NakoError {
|
|
54
|
+
/**
|
|
55
|
+
* @param {string} msg
|
|
56
|
+
* @param {number | null} startOffset
|
|
57
|
+
* @param {number | null} endOffset,
|
|
58
|
+
* @param {number | undefined} line
|
|
59
|
+
* @param {string | undefined} file
|
|
60
|
+
*/
|
|
61
|
+
constructor (
|
|
62
|
+
msg,
|
|
63
|
+
startOffset,
|
|
64
|
+
endOffset,
|
|
65
|
+
line,
|
|
66
|
+
file
|
|
67
|
+
) {
|
|
68
|
+
super('字句解析エラー', msg, file, line)
|
|
69
|
+
this.startOffset = startOffset
|
|
70
|
+
this.endOffset = endOffset
|
|
71
|
+
this.line = line
|
|
72
|
+
this.file = file
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
class NakoSyntaxError extends NakoError {
|
|
77
|
+
/**
|
|
78
|
+
* @param {string} msg
|
|
79
|
+
* @param {import("./nako3").Ast | null | undefined} first
|
|
80
|
+
* @param {import("./nako3").Ast | null | undefined} [last]
|
|
81
|
+
*/
|
|
82
|
+
static fromNode (msg, first, last) {
|
|
83
|
+
if (!first) {
|
|
84
|
+
return new NakoSyntaxError(msg, undefined, null, null, undefined)
|
|
85
|
+
}
|
|
86
|
+
const startOffset = typeof first.startOffset === 'number' ? first.startOffset : null
|
|
87
|
+
const endOffset =
|
|
88
|
+
(last && typeof last.endOffset === 'number')
|
|
89
|
+
? last.endOffset
|
|
90
|
+
: (typeof first.endOffset === 'number' ? first.endOffset : null)
|
|
91
|
+
return new NakoSyntaxError(msg, first.line, startOffset, endOffset, first.file)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @param {string} msg
|
|
96
|
+
* @param {number | undefined} line
|
|
97
|
+
* @param {number | null} startOffset
|
|
98
|
+
* @param {number | null} endOffset
|
|
99
|
+
* @param {string | undefined} file
|
|
100
|
+
*/
|
|
101
|
+
constructor (msg, line, startOffset, endOffset, file) {
|
|
102
|
+
super('文法エラー', msg, file, line)
|
|
103
|
+
this.file = file
|
|
104
|
+
this.line = line
|
|
105
|
+
this.startOffset = startOffset
|
|
106
|
+
this.endOffset = endOffset
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
class NakoRuntimeError extends NakoError {
|
|
111
|
+
/**
|
|
112
|
+
* @param {Error | string} error エラー
|
|
113
|
+
* @param {string | undefined} lineNo 発生行
|
|
114
|
+
*/
|
|
115
|
+
constructor (error, lineNo) {
|
|
116
|
+
const className =
|
|
117
|
+
(error instanceof Error &&
|
|
118
|
+
error.constructor !== Error &&
|
|
119
|
+
error.constructor !== NakoRuntimeError)
|
|
120
|
+
? error.constructor.name + ': '
|
|
121
|
+
: ''
|
|
122
|
+
const msg = error instanceof Error ? error.message : error + ''
|
|
123
|
+
|
|
124
|
+
// 行番号を表す文字列をパースする。
|
|
125
|
+
/** @type {number | undefined} */
|
|
126
|
+
let line
|
|
127
|
+
/** @type {string | undefined} */
|
|
128
|
+
let file
|
|
129
|
+
/** @type {RegExpExecArray | null} */
|
|
130
|
+
let matches
|
|
131
|
+
if (lineNo === undefined) {
|
|
132
|
+
line = undefined
|
|
133
|
+
file = undefined
|
|
134
|
+
// eslint-disable-next-line no-cond-assign
|
|
135
|
+
} else if (matches = /^l(-?\d+):(.*)$/.exec(lineNo)) {
|
|
136
|
+
line = +matches[1]
|
|
137
|
+
file = matches[2]
|
|
138
|
+
// eslint-disable-next-line no-cond-assign
|
|
139
|
+
} else if (matches = /^l(-?\d+)$/.exec(lineNo)) {
|
|
140
|
+
line = +matches[1]
|
|
141
|
+
file = undefined
|
|
142
|
+
} else {
|
|
143
|
+
line = undefined
|
|
144
|
+
file = lineNo
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
super('実行時エラー', `エラー『${className}${msg}』が発生しました。`, file, line)
|
|
148
|
+
this.error = error
|
|
149
|
+
this.lineNo = lineNo
|
|
150
|
+
this.line = line
|
|
151
|
+
this.file = file
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
class NakoImportError extends NakoError {
|
|
156
|
+
/**
|
|
157
|
+
* @param {string} msg
|
|
158
|
+
* @param {number} line
|
|
159
|
+
* @param {string} file
|
|
160
|
+
*/
|
|
161
|
+
constructor (msg, line, file) {
|
|
162
|
+
super('取り込みエラー', msg, file, line)
|
|
163
|
+
this.file = file
|
|
164
|
+
this.line = line
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
module.exports = {
|
|
169
|
+
NakoError,
|
|
170
|
+
NakoIndentError,
|
|
171
|
+
NakoLexerError,
|
|
172
|
+
InternalLexerError,
|
|
173
|
+
NakoSyntaxError,
|
|
174
|
+
NakoRuntimeError,
|
|
175
|
+
NakoImportError
|
|
176
|
+
}
|