functionalscript 0.1.609 → 0.2.1
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/com/cpp/module.f.mjs +20 -25
- package/com/cpp/testlib.f.mjs +3 -4
- package/com/cs/module.f.mjs +18 -23
- package/com/cs/testlib.f.mjs +3 -5
- package/com/rust/module.f.mjs +25 -30
- package/com/rust/testlib.f.mjs +3 -5
- package/com/test/build.f.mjs +2 -2
- package/com/test/build.mjs +4 -4
- package/com/types/module.f.mjs +5 -12
- package/commonjs/build/module.f.mjs +23 -28
- package/commonjs/build/test.f.mjs +4 -4
- package/commonjs/module/function/module.f.mjs +0 -2
- package/commonjs/module/module.f.mjs +2 -9
- package/commonjs/module.f.mjs +0 -2
- package/commonjs/module.mjs +2 -7
- package/commonjs/package/dependencies/module.f.mjs +5 -10
- package/commonjs/package/dependencies/test.f.mjs +1 -1
- package/commonjs/package/module.f.mjs +6 -13
- package/commonjs/package/test.f.mjs +1 -1
- package/commonjs/path/module.f.mjs +12 -23
- package/commonjs/path/test.f.mjs +11 -11
- package/commonjs/test.mjs +1 -1
- package/dev/module.f.mjs +1 -4
- package/dev/module.mjs +1 -1
- package/dev/test/module.f.mjs +4 -6
- package/djs/module.f.mjs +12 -19
- package/djs/parser/module.f.mjs +18 -24
- package/djs/parser/test.f.mjs +9 -9
- package/djs/test.f.mjs +4 -4
- package/djs/tokenizer/module.f.mjs +18 -23
- package/djs/tokenizer/test.f.mjs +6 -6
- package/fsc/module.f.mjs +17 -24
- package/fsc/test.f.mjs +3 -3
- package/fsm/module.f.mjs +27 -38
- package/fsm/test.f.mjs +8 -8
- package/html/module.f.mjs +14 -23
- package/html/test.f.mjs +4 -4
- package/js/tokenizer/module.f.mjs +55 -62
- package/js/tokenizer/test.f.mjs +6 -6
- package/json/module.f.mjs +18 -31
- package/json/parser/module.f.mjs +9 -14
- package/json/parser/test.f.mjs +7 -7
- package/json/serializer/module.f.mjs +14 -29
- package/json/serializer/test.f.mjs +2 -2
- package/json/test.f.mjs +3 -3
- package/json/tokenizer/module.f.mjs +14 -19
- package/json/tokenizer/test.f.mjs +6 -6
- package/jsr.json +59 -59
- package/nodejs/version/main.mjs +1 -1
- package/nodejs/version/module.f.mjs +2 -7
- package/nodejs/version/test.f.mjs +3 -3
- package/out/com/cpp/module.f.d.mts +4 -0
- package/out/com/cpp/module.f.mjs +123 -0
- package/out/com/cpp/test.f.mjs +40 -0
- package/out/com/cpp/testlib.f.mjs +7 -0
- package/out/com/cs/module.f.d.mts +4 -0
- package/out/com/cs/module.f.mjs +95 -0
- package/out/com/cs/test.f.mjs +43 -0
- package/out/com/cs/testlib.f.mjs +7 -0
- package/{com → out/com}/rust/module.f.d.mts +3 -7
- package/out/com/rust/module.f.mjs +213 -0
- package/out/com/rust/test.f.mjs +123 -0
- package/out/com/rust/testlib.f.mjs +7 -0
- package/{com → out/com}/test/build.f.d.mts +2 -2
- package/out/com/test/build.f.mjs +98 -0
- package/out/com/test/build.mjs +40 -0
- package/{com → out/com}/types/module.f.d.mts +5 -10
- package/out/com/types/module.f.mjs +51 -0
- package/out/com/types/testlib.f.mjs +30 -0
- package/out/commonjs/build/module.f.d.mts +20 -0
- package/out/commonjs/build/module.f.mjs +107 -0
- package/out/commonjs/build/test.f.mjs +102 -0
- package/{commonjs → out/commonjs}/module/function/module.f.d.mts +0 -2
- package/out/commonjs/module/function/module.f.mjs +15 -0
- package/{commonjs → out/commonjs}/module/module.f.d.mts +16 -21
- package/out/commonjs/module/module.f.mjs +48 -0
- package/out/commonjs/module.d.mts +3 -0
- package/{commonjs → out/commonjs}/module.f.d.mts +0 -2
- package/out/commonjs/module.f.mjs +10 -0
- package/out/commonjs/module.mjs +26 -0
- package/out/commonjs/package/dependencies/module.f.d.mts +6 -0
- package/out/commonjs/package/dependencies/module.f.mjs +21 -0
- package/out/commonjs/package/dependencies/test.f.mjs +15 -0
- package/out/commonjs/package/module.f.d.mts +21 -0
- package/out/commonjs/package/module.f.mjs +40 -0
- package/out/commonjs/package/test.f.mjs +27 -0
- package/{commonjs → out/commonjs}/path/module.f.d.mts +25 -32
- package/out/commonjs/path/module.f.mjs +171 -0
- package/out/commonjs/path/test.f.mjs +231 -0
- package/out/commonjs/test.mjs +87 -0
- package/out/dev/index.mjs +2 -0
- package/out/dev/module.f.d.mts +1 -0
- package/out/dev/module.f.mjs +2 -0
- package/out/dev/module.mjs +167 -0
- package/{dev → out/dev}/test/module.f.d.mts +2 -3
- package/out/dev/test/module.f.mjs +134 -0
- package/out/dev/test.f.mjs +58 -0
- package/out/dev/test.mjs +52 -0
- package/{djs → out/djs}/module.f.d.mts +13 -18
- package/out/djs/module.f.mjs +75 -0
- package/{djs → out/djs}/parser/module.f.d.mts +11 -15
- package/out/djs/parser/module.f.mjs +432 -0
- package/out/djs/parser/test.f.mjs +535 -0
- package/out/djs/test.f.mjs +84 -0
- package/out/djs/tokenizer/module.f.d.mts +13 -0
- package/out/djs/tokenizer/module.f.mjs +87 -0
- package/out/djs/tokenizer/test.f.mjs +480 -0
- package/out/fsc/module.f.d.mts +7 -0
- package/out/fsc/module.f.mjs +105 -0
- package/out/fsc/test.f.mjs +19 -0
- package/out/fsm/module.f.d.mts +14 -0
- package/out/fsm/module.f.mjs +80 -0
- package/out/fsm/test.f.mjs +138 -0
- package/out/html/module.f.d.mts +15 -0
- package/out/html/module.f.mjs +94 -0
- package/out/html/test.f.mjs +45 -0
- package/out/issues/test.f.mjs +66 -0
- package/{js → out/js}/tokenizer/module.f.d.mts +10 -15
- package/out/js/tokenizer/module.f.mjs +686 -0
- package/out/js/tokenizer/test.f.mjs +844 -0
- package/out/json/module.f.d.mts +33 -0
- package/out/json/module.f.mjs +89 -0
- package/{json → out/json}/parser/module.f.d.mts +9 -13
- package/out/json/parser/module.f.mjs +224 -0
- package/out/json/parser/test.f.mjs +321 -0
- package/out/json/serializer/module.f.d.mts +36 -0
- package/out/json/serializer/module.f.mjs +67 -0
- package/out/json/serializer/test.f.mjs +87 -0
- package/out/json/test.f.mjs +61 -0
- package/out/json/tokenizer/module.f.d.mts +13 -0
- package/out/json/tokenizer/module.f.mjs +78 -0
- package/out/json/tokenizer/test.f.mjs +420 -0
- package/out/nanvm-lib/tests/test.f.mjs +87 -0
- package/out/nodejs/version/main.mjs +3 -0
- package/{nodejs → out/nodejs}/version/module.f.d.mts +4 -9
- package/out/nodejs/version/module.f.mjs +34 -0
- package/out/nodejs/version/test.f.mjs +97 -0
- package/{prime_field → out/prime_field}/module.f.d.mts +20 -23
- package/out/prime_field/module.f.mjs +87 -0
- package/out/prime_field/test.f.mjs +145 -0
- package/{secp → out/secp}/module.f.d.mts +27 -28
- package/out/secp/module.f.mjs +113 -0
- package/out/secp/test.f.mjs +63 -0
- package/out/sha2/module.f.d.mts +15 -0
- package/out/sha2/module.f.mjs +172 -0
- package/out/sha2/test.f.mjs +86 -0
- package/out/text/ascii/module.f.d.mts +70 -0
- package/out/text/ascii/module.f.mjs +154 -0
- package/out/text/ascii/test.f.mjs +14 -0
- package/out/text/module.f.d.mts +13 -0
- package/out/text/module.f.mjs +19 -0
- package/out/text/sgr/module.f.d.mts +12 -0
- package/out/text/sgr/module.f.mjs +17 -0
- package/out/text/test.f.mjs +19 -0
- package/out/text/utf16/module.f.d.mts +12 -0
- package/out/text/utf16/module.f.mjs +86 -0
- package/out/text/utf16/test.f.mjs +145 -0
- package/out/text/utf8/module.f.d.mts +10 -0
- package/out/text/utf8/module.f.mjs +126 -0
- package/out/text/utf8/test.f.mjs +175 -0
- package/{types → out/types}/array/module.f.d.mts +14 -24
- package/out/types/array/module.f.mjs +95 -0
- package/out/types/array/test.f.mjs +116 -0
- package/out/types/bigfloat/module.f.d.mts +6 -0
- package/out/types/bigfloat/module.f.mjs +77 -0
- package/out/types/bigfloat/test.f.mjs +349 -0
- package/out/types/bigint/module.f.d.mts +29 -0
- package/{types/bigint/module.f.d.mts → out/types/bigint/module.f.mjs} +64 -27
- package/out/types/bigint/test.f.mjs +192 -0
- package/{types → out/types}/btree/find/module.f.d.mts +20 -26
- package/out/types/btree/find/module.f.mjs +137 -0
- package/out/types/btree/find/test.f.mjs +156 -0
- package/out/types/btree/module.f.d.mts +5 -0
- package/out/types/btree/module.f.mjs +34 -0
- package/{types → out/types}/btree/remove/module.f.d.mts +7 -12
- package/out/types/btree/remove/module.f.mjs +209 -0
- package/out/types/btree/remove/test.f.mjs +638 -0
- package/{types → out/types}/btree/set/module.f.d.mts +3 -7
- package/out/types/btree/set/module.f.mjs +114 -0
- package/out/types/btree/set/test.f.mjs +390 -0
- package/out/types/btree/test.f.mjs +83 -0
- package/{types → out/types}/btree/types/module.f.d.mts +0 -2
- package/out/types/btree/types/module.f.mjs +50 -0
- package/out/types/byte_set/module.f.d.mts +25 -0
- package/out/types/byte_set/module.f.mjs +42 -0
- package/out/types/byte_set/test.f.mjs +123 -0
- package/{types → out/types}/function/compare/module.f.d.mts +9 -15
- package/out/types/function/compare/module.f.mjs +22 -0
- package/out/types/function/compare/test.f.mjs +8 -0
- package/{types → out/types}/function/module.f.d.mts +20 -27
- package/out/types/function/module.f.mjs +44 -0
- package/{types → out/types}/function/operator/module.f.d.mts +28 -43
- package/out/types/function/operator/module.f.mjs +60 -0
- package/out/types/function/test.f.mjs +15 -0
- package/out/types/list/module.f.d.mts +82 -0
- package/out/types/list/module.f.mjs +269 -0
- package/out/types/list/test.f.mjs +401 -0
- package/out/types/map/module.f.d.mts +21 -0
- package/out/types/map/module.f.mjs +54 -0
- package/out/types/map/test.f.mjs +115 -0
- package/out/types/nibble_set/module.f.d.mts +16 -0
- package/out/types/nibble_set/module.f.mjs +19 -0
- package/out/types/nibble_set/test.f.mjs +90 -0
- package/out/types/nullable/module.f.d.mts +9 -0
- package/out/types/nullable/module.f.mjs +9 -0
- package/out/types/nullable/test.f.mjs +12 -0
- package/out/types/number/module.f.d.mts +7 -0
- package/out/types/number/module.f.mjs +12 -0
- package/out/types/number/test.f.mjs +126 -0
- package/out/types/object/module.f.d.mts +22 -0
- package/out/types/object/module.f.mjs +27 -0
- package/out/types/object/test.f.mjs +17 -0
- package/out/types/range/module.f.d.mts +6 -0
- package/out/types/range/module.f.mjs +6 -0
- package/out/types/range/test.f.mjs +18 -0
- package/{types → out/types}/range_map/module.f.d.mts +9 -15
- package/out/types/range_map/module.f.mjs +84 -0
- package/out/types/range_map/test.f.mjs +201 -0
- package/out/types/result/module.d.mts +7 -0
- package/{types → out/types}/result/module.f.d.mts +6 -12
- package/out/types/result/module.f.mjs +25 -0
- package/out/types/result/module.mjs +16 -0
- package/{types → out/types}/sorted_list/module.f.d.mts +22 -28
- package/out/types/sorted_list/module.f.mjs +102 -0
- package/out/types/sorted_list/test.f.mjs +66 -0
- package/{types → out/types}/sorted_set/module.f.d.mts +6 -12
- package/out/types/sorted_set/module.f.mjs +29 -0
- package/out/types/sorted_set/test.f.mjs +80 -0
- package/out/types/string/module.f.d.mts +9 -0
- package/out/types/string/module.f.mjs +17 -0
- package/out/types/string/test.f.mjs +58 -0
- package/out/types/string_set/module.f.d.mts +13 -0
- package/out/types/string_set/module.f.mjs +29 -0
- package/out/types/string_set/test.f.mjs +65 -0
- package/package.json +5 -4
- package/prime_field/module.f.mjs +9 -12
- package/prime_field/test.f.mjs +1 -1
- package/secp/module.f.mjs +38 -39
- package/secp/test.f.mjs +4 -4
- package/sha2/module.f.mjs +7 -20
- package/sha2/test.f.mjs +4 -4
- package/text/ascii/module.f.mjs +5 -10
- package/text/ascii/test.f.mjs +3 -3
- package/text/module.f.mjs +7 -14
- package/text/sgr/module.f.mjs +2 -4
- package/text/test.f.mjs +3 -3
- package/text/utf16/module.f.mjs +17 -28
- package/text/utf16/test.f.mjs +5 -5
- package/text/utf8/module.f.mjs +9 -16
- package/text/utf8/test.f.mjs +4 -4
- package/tsconfig.json +2 -2
- package/types/array/module.f.mjs +8 -25
- package/types/array/test.f.mjs +3 -3
- package/types/bigfloat/module.f.mjs +3 -10
- package/types/bigfloat/test.f.mjs +1 -1
- package/types/bigint/module.f.mjs +11 -30
- package/types/bigint/test.f.mjs +1 -1
- package/types/btree/find/module.f.mjs +8 -17
- package/types/btree/find/test.f.mjs +7 -7
- package/types/btree/module.f.mjs +6 -11
- package/types/btree/remove/module.f.mjs +10 -17
- package/types/btree/remove/test.f.mjs +5 -5
- package/types/btree/set/module.f.mjs +4 -9
- package/types/btree/set/test.f.mjs +4 -4
- package/types/btree/test.f.mjs +9 -9
- package/types/btree/types/module.f.mjs +0 -2
- package/types/byte_set/module.f.mjs +14 -39
- package/types/byte_set/test.f.mjs +5 -5
- package/types/function/compare/module.f.mjs +3 -12
- package/types/function/compare/test.f.mjs +1 -1
- package/types/function/module.f.mjs +4 -15
- package/types/function/operator/module.f.mjs +14 -41
- package/types/function/test.f.mjs +1 -1
- package/types/list/module.f.mjs +45 -114
- package/types/list/test.f.mjs +10 -10
- package/types/map/module.f.mjs +15 -30
- package/types/map/test.f.mjs +2 -2
- package/types/nibble_set/module.f.mjs +7 -24
- package/types/nibble_set/test.f.mjs +2 -2
- package/types/nullable/module.f.mjs +2 -9
- package/types/nullable/test.f.mjs +1 -1
- package/types/number/module.f.mjs +8 -19
- package/types/number/test.f.mjs +1 -1
- package/types/object/module.f.mjs +9 -20
- package/types/object/test.f.mjs +1 -1
- package/types/range/module.f.mjs +2 -9
- package/types/range/test.f.mjs +1 -1
- package/types/range_map/module.f.mjs +9 -18
- package/types/range_map/test.f.mjs +32 -32
- package/types/result/module.f.mjs +3 -12
- package/types/result/module.mjs +2 -2
- package/types/sorted_list/module.f.mjs +10 -19
- package/types/sorted_list/test.f.mjs +7 -7
- package/types/sorted_set/module.f.mjs +7 -16
- package/types/sorted_set/test.f.mjs +7 -7
- package/types/string/module.f.mjs +10 -21
- package/types/string/test.f.mjs +2 -2
- package/types/string_set/module.f.mjs +12 -27
- package/types/string_set/test.f.mjs +1 -1
- package/com/cpp/module.f.d.mts +0 -8
- package/com/cs/module.f.d.mts +0 -8
- package/commonjs/build/module.f.d.mts +0 -24
- package/commonjs/module.d.mts +0 -7
- package/commonjs/package/dependencies/module.f.d.mts +0 -10
- package/commonjs/package/module.f.d.mts +0 -27
- package/dev/module.f.d.mts +0 -4
- package/djs/tokenizer/module.f.d.mts +0 -17
- package/fsc/module.f.d.mts +0 -12
- package/fsm/module.f.d.mts +0 -21
- package/html/module.f.d.mts +0 -20
- package/json/module.f.d.mts +0 -41
- package/json/serializer/module.f.d.mts +0 -45
- package/json/tokenizer/module.f.d.mts +0 -17
- package/sha2/module.f.d.mts +0 -23
- package/text/ascii/module.f.d.mts +0 -73
- package/text/module.f.d.mts +0 -18
- package/text/sgr/module.f.d.mts +0 -14
- package/text/utf16/module.f.d.mts +0 -19
- package/text/utf8/module.f.d.mts +0 -15
- package/types/bigfloat/module.f.d.mts +0 -11
- package/types/btree/module.f.d.mts +0 -9
- package/types/byte_set/module.f.d.mts +0 -38
- package/types/list/module.f.d.mts +0 -117
- package/types/map/module.f.d.mts +0 -30
- package/types/nibble_set/module.f.d.mts +0 -26
- package/types/nullable/module.f.d.mts +0 -14
- package/types/number/module.f.d.mts +0 -13
- package/types/object/module.f.d.mts +0 -29
- package/types/range/module.f.d.mts +0 -11
- package/types/result/module.d.mts +0 -7
- package/types/string/module.f.d.mts +0 -15
- package/types/string_set/module.f.d.mts +0 -21
- /package/{com → out/com}/cpp/test.f.d.mts +0 -0
- /package/{com → out/com}/cpp/testlib.f.d.mts +0 -0
- /package/{com → out/com}/cs/test.f.d.mts +0 -0
- /package/{com → out/com}/cs/testlib.f.d.mts +0 -0
- /package/{com → out/com}/rust/test.f.d.mts +0 -0
- /package/{com → out/com}/rust/testlib.f.d.mts +0 -0
- /package/{com → out/com}/test/build.d.mts +0 -0
- /package/{com → out/com}/types/testlib.f.d.mts +0 -0
- /package/{commonjs → out/commonjs}/build/test.f.d.mts +0 -0
- /package/{commonjs → out/commonjs}/package/dependencies/test.f.d.mts +0 -0
- /package/{commonjs → out/commonjs}/package/test.f.d.mts +0 -0
- /package/{commonjs → out/commonjs}/path/test.f.d.mts +0 -0
- /package/{commonjs → out/commonjs}/test.d.mts +0 -0
- /package/{dev → out/dev}/index.d.mts +0 -0
- /package/{dev → out/dev}/module.d.mts +0 -0
- /package/{dev → out/dev}/test.d.mts +0 -0
- /package/{dev → out/dev}/test.f.d.mts +0 -0
- /package/{djs → out/djs}/parser/test.f.d.mts +0 -0
- /package/{djs → out/djs}/test.f.d.mts +0 -0
- /package/{djs → out/djs}/tokenizer/test.f.d.mts +0 -0
- /package/{fsc → out/fsc}/test.f.d.mts +0 -0
- /package/{fsm → out/fsm}/test.f.d.mts +0 -0
- /package/{html → out/html}/test.f.d.mts +0 -0
- /package/{issues → out/issues}/test.f.d.mts +0 -0
- /package/{js → out/js}/tokenizer/test.f.d.mts +0 -0
- /package/{json → out/json}/parser/test.f.d.mts +0 -0
- /package/{json → out/json}/serializer/test.f.d.mts +0 -0
- /package/{json → out/json}/test.f.d.mts +0 -0
- /package/{json → out/json}/tokenizer/test.f.d.mts +0 -0
- /package/{nanvm-lib → out/nanvm-lib}/tests/test.f.d.mts +0 -0
- /package/{nodejs → out/nodejs}/version/main.d.mts +0 -0
- /package/{nodejs → out/nodejs}/version/test.f.d.mts +0 -0
- /package/{prime_field → out/prime_field}/test.f.d.mts +0 -0
- /package/{secp → out/secp}/test.f.d.mts +0 -0
- /package/{sha2 → out/sha2}/test.f.d.mts +0 -0
- /package/{text → out/text}/ascii/test.f.d.mts +0 -0
- /package/{text → out/text}/test.f.d.mts +0 -0
- /package/{text → out/text}/utf16/test.f.d.mts +0 -0
- /package/{text → out/text}/utf8/test.f.d.mts +0 -0
- /package/{types → out/types}/array/test.f.d.mts +0 -0
- /package/{types → out/types}/bigfloat/test.f.d.mts +0 -0
- /package/{types → out/types}/bigint/test.f.d.mts +0 -0
- /package/{types → out/types}/btree/find/test.f.d.mts +0 -0
- /package/{types → out/types}/btree/remove/test.f.d.mts +0 -0
- /package/{types → out/types}/btree/set/test.f.d.mts +0 -0
- /package/{types → out/types}/btree/test.f.d.mts +0 -0
- /package/{types → out/types}/byte_set/test.f.d.mts +0 -0
- /package/{types → out/types}/function/compare/test.f.d.mts +0 -0
- /package/{types → out/types}/function/test.f.d.mts +0 -0
- /package/{types → out/types}/list/test.f.d.mts +0 -0
- /package/{types → out/types}/map/test.f.d.mts +0 -0
- /package/{types → out/types}/nibble_set/test.f.d.mts +0 -0
- /package/{types → out/types}/nullable/test.f.d.mts +0 -0
- /package/{types → out/types}/number/test.f.d.mts +0 -0
- /package/{types → out/types}/object/test.f.d.mts +0 -0
- /package/{types → out/types}/range/test.f.d.mts +0 -0
- /package/{types → out/types}/range_map/test.f.d.mts +0 -0
- /package/{types → out/types}/sorted_list/test.f.d.mts +0 -0
- /package/{types → out/types}/sorted_set/test.f.d.mts +0 -0
- /package/{types → out/types}/string/test.f.d.mts +0 -0
- /package/{types → out/types}/string_set/test.f.d.mts +0 -0
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// @ts-self-types="./module.f.d.mts"
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import * as operator from '../../types/function/operator/module.f.mjs'
|
|
3
|
+
import * as range_map from '../../types/range_map/module.f.mjs'
|
|
4
4
|
const { merge, fromRange, get } = range_map
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import * as list from '../../types/list/module.f.mjs'
|
|
6
|
+
import * as map from '../../types/map/module.f.mjs'
|
|
7
7
|
const { at } = map
|
|
8
|
-
import
|
|
8
|
+
import * as _range from '../../types/range/module.f.mjs'
|
|
9
9
|
const { one } = _range
|
|
10
10
|
const { empty, stateScan, flat, toArray, reduce: listReduce, scan } = list
|
|
11
11
|
import * as bigfloatT from '../../types/bigfloat/module.f.mjs'
|
|
12
12
|
const { fromCharCode } = String
|
|
13
|
-
import ascii from '../../text/ascii/module.f.mjs'
|
|
13
|
+
import * as ascii from '../../text/ascii/module.f.mjs'
|
|
14
|
+
const { range } = ascii
|
|
14
15
|
const {
|
|
15
|
-
range,
|
|
16
16
|
//
|
|
17
17
|
backspace,
|
|
18
18
|
ht,
|
|
@@ -68,7 +68,7 @@ const {
|
|
|
68
68
|
leftCurlyBracket,
|
|
69
69
|
rightCurlyBracket,
|
|
70
70
|
dollarSign
|
|
71
|
-
} = ascii
|
|
71
|
+
} = ascii.ascii
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* @typedef {{
|
|
@@ -157,9 +157,9 @@ const {
|
|
|
157
157
|
|
|
158
158
|
const rangeOneNine = range('19')
|
|
159
159
|
|
|
160
|
-
const rangeSetNewLine = [
|
|
160
|
+
const rangeSetNewLine = [
|
|
161
161
|
one(lf),
|
|
162
|
-
one(cr)
|
|
162
|
+
one(cr)
|
|
163
163
|
]
|
|
164
164
|
|
|
165
165
|
const rangeSetWhiteSpace = [
|
|
@@ -309,14 +309,14 @@ const rangeId = [digitRange, ...rangeIdStart]
|
|
|
309
309
|
|
|
310
310
|
/** @typedef {number|null} CharCodeOrEof */
|
|
311
311
|
|
|
312
|
-
/** @typedef {(input: number) => readonly[
|
|
312
|
+
/** @typedef {(input: number) => readonly[list.List<JsToken>, TokenizerState]} ToToken */
|
|
313
313
|
|
|
314
314
|
/**
|
|
315
315
|
* @template T
|
|
316
316
|
* @typedef {(state: T) => ToToken} CreateToToken<T>
|
|
317
317
|
*/
|
|
318
318
|
|
|
319
|
-
/** @typedef {
|
|
319
|
+
/** @typedef {list.List<_range.Range>} RangeSet */
|
|
320
320
|
|
|
321
321
|
/**
|
|
322
322
|
* @template T
|
|
@@ -325,7 +325,7 @@ const rangeId = [digitRange, ...rangeIdStart]
|
|
|
325
325
|
|
|
326
326
|
/**
|
|
327
327
|
* @template T
|
|
328
|
-
* @typedef {
|
|
328
|
+
* @typedef {range_map.RangeMapArray<CreateToToken<T>>} RangeMapToToken<T>
|
|
329
329
|
*/
|
|
330
330
|
|
|
331
331
|
/** @type {(old: string) => (input: number) => string} */
|
|
@@ -338,34 +338,34 @@ const union = def => a => b => {
|
|
|
338
338
|
throw [a, b]
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
-
/** @type {<T>(def: CreateToToken<T>) =>
|
|
341
|
+
/** @type {<T>(def: CreateToToken<T>) => range_map.RangeMerge<CreateToToken<T>>} */
|
|
342
342
|
const rangeMapMerge = def => merge({
|
|
343
343
|
union: union(def),
|
|
344
344
|
equal: operator.strictEqual,
|
|
345
345
|
})
|
|
346
346
|
|
|
347
|
-
/** @type {<T>(r:
|
|
347
|
+
/** @type {<T>(r: _range.Range) => (f: CreateToToken<T>) => RangeFunc<T>} */
|
|
348
348
|
const rangeFunc = r => f => def => fromRange(def)(r)(f)
|
|
349
349
|
|
|
350
|
-
/** @type {<T>(def: CreateToToken<T>) => (
|
|
350
|
+
/** @type {<T>(def: CreateToToken<T>) => (operator.Scan<RangeFunc<T>, RangeMapToToken<T>>)} */
|
|
351
351
|
const scanRangeOp = def => f => [f(def), scanRangeOp(def)]
|
|
352
352
|
|
|
353
|
-
/** @type {<T>(def: CreateToToken<T>) => (a:
|
|
353
|
+
/** @type {<T>(def: CreateToToken<T>) => (a: list.List<RangeFunc<T>>) => RangeMapToToken<T>} */
|
|
354
354
|
const reduceRangeMap = def => a => {
|
|
355
355
|
const rm = scan(scanRangeOp(def))(a)
|
|
356
356
|
return toArray(listReduce(rangeMapMerge(def))(empty)(rm))
|
|
357
357
|
}
|
|
358
358
|
|
|
359
|
-
/** @type {<T>(def: CreateToToken<T>) => (f: CreateToToken<T>) => (
|
|
359
|
+
/** @type {<T>(def: CreateToToken<T>) => (f: CreateToToken<T>) => (operator.Scan<_range.Range, RangeMapToToken<T>>)} */
|
|
360
360
|
const scanRangeSetOp = def => f => r => [fromRange(def)(r)(f), scanRangeSetOp(def)(f)]
|
|
361
361
|
|
|
362
|
-
/** @type {<T>(rs:
|
|
362
|
+
/** @type {<T>(rs: list.List<_range.Range>) => (f: CreateToToken<T>) => RangeFunc<T>} */
|
|
363
363
|
const rangeSetFunc = rs => f => def => {
|
|
364
364
|
const rm = scan(scanRangeSetOp(def)(f))(rs)
|
|
365
365
|
return toArray(listReduce(rangeMapMerge(def))(empty)(rm))
|
|
366
366
|
}
|
|
367
367
|
|
|
368
|
-
/** @type {<T>(def: CreateToToken<T>) => (a:
|
|
368
|
+
/** @type {<T>(def: CreateToToken<T>) => (a: list.List<RangeFunc<T>>) => CreateToToken<T>} */
|
|
369
369
|
const create = def => a => {
|
|
370
370
|
/** @typedef {typeof def extends CreateToToken<infer T> ? T : never} T */
|
|
371
371
|
const i = reduceRangeMap(def)(a)
|
|
@@ -402,7 +402,7 @@ const bufferToNumberToken = ({numberKind, value, b}) =>
|
|
|
402
402
|
|
|
403
403
|
/**
|
|
404
404
|
* @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#keywords
|
|
405
|
-
* @type {
|
|
405
|
+
* @type {list.List<map.Entry<JsToken>>}
|
|
406
406
|
*/
|
|
407
407
|
const keywordEntries = [
|
|
408
408
|
['arguments', { kind: 'arguments'}],
|
|
@@ -458,11 +458,11 @@ const keywordEntries = [
|
|
|
458
458
|
const keywordMap = map.fromEntries(keywordEntries)
|
|
459
459
|
|
|
460
460
|
/** @type {(token: JsToken) => Boolean} */
|
|
461
|
-
const isKeywordToken = token => at(token.kind)(keywordMap) !== null
|
|
461
|
+
export const isKeywordToken = token => at(token.kind)(keywordMap) !== null
|
|
462
462
|
|
|
463
463
|
/**
|
|
464
464
|
* @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators
|
|
465
|
-
* @type {
|
|
465
|
+
* @type {list.List<map.Entry<JsToken>>}
|
|
466
466
|
*/
|
|
467
467
|
const operatorEntries = [
|
|
468
468
|
['!', { kind: '!'}],
|
|
@@ -530,7 +530,7 @@ const getOperatorToken = op => at(op)(operatorMap) ?? { kind: 'error', message:
|
|
|
530
530
|
/** @type {(op: string) => Boolean} */
|
|
531
531
|
const hasOperatorToken = op => at(op)(operatorMap) !== null
|
|
532
532
|
|
|
533
|
-
/** @type {(state: InitialState) => (input: number) => readonly[
|
|
533
|
+
/** @type {(state: InitialState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
534
534
|
const initialStateOp = create(state => () => [[{ kind: 'error', message: 'unexpected character' }], state])([
|
|
535
535
|
rangeFunc(rangeOneNine)(() => input => [empty, { kind: 'number', value: fromCharCode(input), b: startNumber(input), numberKind: 'int' }]),
|
|
536
536
|
rangeSetFunc(rangeIdStart)(() => input => [empty, { kind: 'id', value: fromCharCode(input) }]),
|
|
@@ -541,14 +541,14 @@ const initialStateOp = create(state => () => [[{ kind: 'error', message: 'unexpe
|
|
|
541
541
|
rangeSetFunc(rangeOpStart)(() => input => [empty, { kind: 'op', value: fromCharCode(input) }])
|
|
542
542
|
])
|
|
543
543
|
|
|
544
|
-
/** @type {(state: ParseNumberState) => (input: number) => readonly[
|
|
544
|
+
/** @type {(state: ParseNumberState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
545
545
|
const invalidNumberToToken = () => input =>
|
|
546
546
|
{
|
|
547
547
|
const next = tokenizeOp({ kind: 'initial' })(input)
|
|
548
548
|
return [{ first: { kind: 'error', message: 'invalid number' }, tail: next[0] }, next[1]]
|
|
549
549
|
}
|
|
550
550
|
|
|
551
|
-
/** @type {(state: ParseNumberState) => (input: number) => readonly[
|
|
551
|
+
/** @type {(state: ParseNumberState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
552
552
|
const fullStopToToken = state => input => {
|
|
553
553
|
switch (state.numberKind) {
|
|
554
554
|
case '0':
|
|
@@ -557,7 +557,7 @@ const fullStopToToken = state => input => {
|
|
|
557
557
|
}
|
|
558
558
|
}
|
|
559
559
|
|
|
560
|
-
/** @type {(state: ParseNumberState) => (input: number) => readonly[
|
|
560
|
+
/** @type {(state: ParseNumberState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
561
561
|
const digit0ToToken = state => input => {
|
|
562
562
|
switch (state.numberKind) {
|
|
563
563
|
case '0': return tokenizeOp({ kind: 'invalidNumber' })(input)
|
|
@@ -571,7 +571,7 @@ const digit0ToToken = state => input => {
|
|
|
571
571
|
}
|
|
572
572
|
}
|
|
573
573
|
|
|
574
|
-
/** @type {(state: ParseNumberState) => (input: number) => readonly[
|
|
574
|
+
/** @type {(state: ParseNumberState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
575
575
|
const digit19ToToken = state => input => {
|
|
576
576
|
switch (state.numberKind) {
|
|
577
577
|
case '0': return tokenizeOp({ kind: 'invalidNumber' })(input)
|
|
@@ -585,7 +585,7 @@ const digit19ToToken = state => input => {
|
|
|
585
585
|
}
|
|
586
586
|
}
|
|
587
587
|
|
|
588
|
-
/** @type {(state: ParseNumberState) => (input: number) => readonly[
|
|
588
|
+
/** @type {(state: ParseNumberState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
589
589
|
const expToToken = state => input => {
|
|
590
590
|
switch (state.numberKind) {
|
|
591
591
|
case '0':
|
|
@@ -595,7 +595,7 @@ const expToToken = state => input => {
|
|
|
595
595
|
}
|
|
596
596
|
}
|
|
597
597
|
|
|
598
|
-
/** @type {(state: ParseNumberState) => (input: number) => readonly[
|
|
598
|
+
/** @type {(state: ParseNumberState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
599
599
|
const hyphenMinusToToken = state => input => {
|
|
600
600
|
switch (state.numberKind) {
|
|
601
601
|
case 'e': return [empty, { kind: 'number', value: appendChar(state.value)(input), b: { ... state.b, es: -1}, numberKind: 'e-' }]
|
|
@@ -603,7 +603,7 @@ const hyphenMinusToToken = state => input => {
|
|
|
603
603
|
}
|
|
604
604
|
}
|
|
605
605
|
|
|
606
|
-
/** @type {(state: ParseNumberState) => (input: number) => readonly[
|
|
606
|
+
/** @type {(state: ParseNumberState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
607
607
|
const plusSignToToken = state => input => {
|
|
608
608
|
switch (state.numberKind) {
|
|
609
609
|
case 'e': return [empty, { kind: 'number', value: appendChar(state.value)(input), b: state.b, numberKind: 'e+' }]
|
|
@@ -611,7 +611,7 @@ const plusSignToToken = state => input => {
|
|
|
611
611
|
}
|
|
612
612
|
}
|
|
613
613
|
|
|
614
|
-
/** @type {(state: ParseNumberState) => (input: number) => readonly[
|
|
614
|
+
/** @type {(state: ParseNumberState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
615
615
|
const terminalToToken = state => input => {
|
|
616
616
|
switch (state.numberKind) {
|
|
617
617
|
case '.':
|
|
@@ -630,7 +630,7 @@ const terminalToToken = state => input => {
|
|
|
630
630
|
}
|
|
631
631
|
}
|
|
632
632
|
|
|
633
|
-
/** @type {(state: ParseNumberState) => (input: number) => readonly[
|
|
633
|
+
/** @type {(state: ParseNumberState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
634
634
|
const bigintToToken = state => input => {
|
|
635
635
|
switch (state.numberKind) {
|
|
636
636
|
case '0':
|
|
@@ -646,7 +646,7 @@ const bigintToToken = state => input => {
|
|
|
646
646
|
}
|
|
647
647
|
}
|
|
648
648
|
|
|
649
|
-
/** @type {(state: ParseNumberState) => (input: number) => readonly[
|
|
649
|
+
/** @type {(state: ParseNumberState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
650
650
|
const parseNumberStateOp = create(invalidNumberToToken)([
|
|
651
651
|
rangeFunc(one(fullStop))(fullStopToToken),
|
|
652
652
|
rangeFunc(one(digit0))(digit0ToToken),
|
|
@@ -658,7 +658,7 @@ const parseNumberStateOp = create(invalidNumberToToken)([
|
|
|
658
658
|
rangeFunc(one(latinSmallLetterN))(bigintToToken),
|
|
659
659
|
])
|
|
660
660
|
|
|
661
|
-
/** @type {(state: InvalidNumberState) => (input: number) => readonly[
|
|
661
|
+
/** @type {(state: InvalidNumberState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
662
662
|
const invalidNumberStateOp = create(() => () => [empty, { kind: 'invalidNumber' }])([
|
|
663
663
|
rangeSetFunc(rangeSetTerminalForNumber)(() => input => {
|
|
664
664
|
const next = tokenizeOp({ kind: 'initial' })(input)
|
|
@@ -666,26 +666,26 @@ const invalidNumberStateOp = create(() => () => [empty, { kind: 'invalidNumber'
|
|
|
666
666
|
})
|
|
667
667
|
])
|
|
668
668
|
|
|
669
|
-
/** @type {(state: ParseMinusState) => (input: number) => readonly[
|
|
669
|
+
/** @type {(state: ParseMinusState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
670
670
|
const parseMinusStateOp = create(() => input => tokenizeOp({ kind: 'op', value: '-' })(input))([
|
|
671
671
|
rangeFunc(one(fullStop))(() => input => tokenizeOp({ kind: 'invalidNumber' })(input)),
|
|
672
672
|
rangeFunc(one(digit0))(() => () => [empty, { kind: 'number', value: '-0', b: startNegativeNumber, numberKind: '0' }]),
|
|
673
673
|
rangeFunc(rangeOneNine)(() => input => [empty, { kind: 'number', value: appendChar('-')(input), b: addIntDigit(input)(startNegativeNumber), numberKind: 'int' }]),
|
|
674
674
|
])
|
|
675
675
|
|
|
676
|
-
/** @type {(state: ParseStringState) => (input: number) => readonly[
|
|
676
|
+
/** @type {(state: ParseStringState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
677
677
|
const parseStringStateOp = create(state => input => [empty, { kind: 'string', value: appendChar(state.value)(input) }])([
|
|
678
678
|
rangeFunc(one(quotationMark))(state => () => [[{ kind: 'string', value: state.value }], { kind: 'initial' }]),
|
|
679
679
|
rangeFunc(one(reverseSolidus))(state => () => [empty, { kind: 'escapeChar', value: state.value }])
|
|
680
680
|
])
|
|
681
681
|
|
|
682
|
-
/** @type {(state: ParseEscapeCharState) => (input: number) => readonly[
|
|
682
|
+
/** @type {(state: ParseEscapeCharState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
683
683
|
const parseEscapeDefault = state => input => {
|
|
684
684
|
const next = tokenizeOp({ kind: 'string', value: state.value })(input)
|
|
685
685
|
return [{ first: { kind: 'error', message: 'unescaped character' }, tail: next[0] }, next[1]]
|
|
686
686
|
}
|
|
687
687
|
|
|
688
|
-
/** @type {(state: ParseEscapeCharState) => (input: number) => readonly[
|
|
688
|
+
/** @type {(state: ParseEscapeCharState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
689
689
|
const parseEscapeCharStateOp = create(parseEscapeDefault)([
|
|
690
690
|
rangeSetFunc([one(quotationMark), one(reverseSolidus), one(solidus)])(state => input => [empty, { kind: 'string', value: appendChar(state.value)(input) }]),
|
|
691
691
|
rangeFunc(one(latinSmallLetterB))(state => () => [empty, { kind: 'string', value: appendChar(state.value)(backspace) }]),
|
|
@@ -696,13 +696,13 @@ const parseEscapeCharStateOp = create(parseEscapeDefault)([
|
|
|
696
696
|
rangeFunc(one(latinSmallLetterU))(state => () => [empty, { kind: 'unicodeChar', value: state.value, unicode: 0, hexIndex: 0 }]),
|
|
697
697
|
])
|
|
698
698
|
|
|
699
|
-
/** @type {(state: ParseUnicodeCharState) => (input: number) => readonly[
|
|
699
|
+
/** @type {(state: ParseUnicodeCharState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
700
700
|
const parseUnicodeCharDefault = state => input => {
|
|
701
701
|
const next = tokenizeOp({ kind: 'string', value: state.value })(input)
|
|
702
702
|
return [{ first: { kind: 'error', message: 'invalid hex value' }, tail: next[0] }, next[1]]
|
|
703
703
|
}
|
|
704
704
|
|
|
705
|
-
/** @type {(offser: number) => (state: ParseUnicodeCharState) => (input: number) => readonly[
|
|
705
|
+
/** @type {(offser: number) => (state: ParseUnicodeCharState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
706
706
|
const parseUnicodeCharHex = offset => state => input => {
|
|
707
707
|
const hexValue = input - offset
|
|
708
708
|
const newUnicode = state.unicode | (hexValue << (3 - state.hexIndex) * 4)
|
|
@@ -711,7 +711,7 @@ const parseUnicodeCharHex = offset => state => input => {
|
|
|
711
711
|
{ kind: 'unicodeChar', value: state.value, unicode: newUnicode, hexIndex: state.hexIndex + 1 }]
|
|
712
712
|
}
|
|
713
713
|
|
|
714
|
-
/** @type {(state: ParseUnicodeCharState) => (input: number) => readonly[
|
|
714
|
+
/** @type {(state: ParseUnicodeCharState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
715
715
|
const parseUnicodeCharStateOp = create(parseUnicodeCharDefault)([
|
|
716
716
|
rangeFunc(digitRange)(parseUnicodeCharHex(digit0)),
|
|
717
717
|
rangeFunc(rangeSmallAF)(parseUnicodeCharHex(latinSmallLetterA - 10)),
|
|
@@ -721,19 +721,19 @@ const parseUnicodeCharStateOp = create(parseUnicodeCharDefault)([
|
|
|
721
721
|
/** @type {(s: string) => JsToken} */
|
|
722
722
|
const idToToken = s => at(s)(keywordMap) ?? { kind: 'id', value: s }
|
|
723
723
|
|
|
724
|
-
/** @type {(state: ParseIdState) => (input: number) => readonly[
|
|
724
|
+
/** @type {(state: ParseIdState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
725
725
|
const parseIdDefault = state => input => {
|
|
726
726
|
const keyWordToken = idToToken(state.value)
|
|
727
727
|
const next = tokenizeOp({ kind: 'initial' })(input)
|
|
728
728
|
return [{ first: keyWordToken, tail: next[0] }, next[1]]
|
|
729
729
|
}
|
|
730
730
|
|
|
731
|
-
/** @type {(state: ParseIdState) => (input: number) => readonly[
|
|
731
|
+
/** @type {(state: ParseIdState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
732
732
|
const parseIdStateOp = create(parseIdDefault)([
|
|
733
733
|
rangeSetFunc(rangeId)(state => input => [empty, { kind: 'id', value: appendChar(state.value)(input) }])
|
|
734
734
|
])
|
|
735
735
|
|
|
736
|
-
/** @type {(state: ParseOperatorState) => (input: number) => readonly[
|
|
736
|
+
/** @type {(state: ParseOperatorState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
737
737
|
const parseOperatorStateOp = state => input => {
|
|
738
738
|
const nextStateValue = appendChar(state.value)(input)
|
|
739
739
|
if (hasOperatorToken(nextStateValue))
|
|
@@ -742,34 +742,34 @@ const parseOperatorStateOp = state => input => {
|
|
|
742
742
|
return [{ first: getOperatorToken(state.value), tail: next[0] }, next[1]]
|
|
743
743
|
}
|
|
744
744
|
|
|
745
|
-
/** @type {(state: ParseWhitespaceState) => (input: number) => readonly[
|
|
745
|
+
/** @type {(state: ParseWhitespaceState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
746
746
|
const parseWhitespaceDefault = state => input => {
|
|
747
747
|
const next = tokenizeOp({ kind: 'initial' })(input)
|
|
748
748
|
return [{ first: { kind: 'ws' }, tail: next[0] }, next[1]]
|
|
749
749
|
}
|
|
750
750
|
|
|
751
|
-
/** @type {(state: ParseWhitespaceState) => (input: number) => readonly[
|
|
751
|
+
/** @type {(state: ParseWhitespaceState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
752
752
|
const parseWhitespaceStateOp = create(parseWhitespaceDefault)([
|
|
753
753
|
rangeSetFunc(rangeSetWhiteSpace)(state => () => [empty, state]),
|
|
754
754
|
rangeSetFunc(rangeSetNewLine)(state => () => [empty, { kind: 'nl' }])
|
|
755
755
|
])
|
|
756
756
|
|
|
757
|
-
/** @type {(state: ParseNewLineState) => (input: number) => readonly[
|
|
757
|
+
/** @type {(state: ParseNewLineState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
758
758
|
const parseNewLineDefault = state => input => {
|
|
759
759
|
const next = tokenizeOp({ kind: 'initial' })(input)
|
|
760
760
|
return [{ first: { kind: 'nl' }, tail: next[0] }, next[1]]
|
|
761
761
|
}
|
|
762
762
|
|
|
763
|
-
/** @type {(state: ParseNewLineState) => (input: number) => readonly[
|
|
763
|
+
/** @type {(state: ParseNewLineState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
764
764
|
const parseNewLineStateOp = create(parseNewLineDefault)([
|
|
765
765
|
rangeSetFunc(rangeSetWhiteSpace)(state => () => [empty, state]),
|
|
766
766
|
rangeSetFunc(rangeSetNewLine)(state => () => [empty, state])
|
|
767
767
|
])
|
|
768
768
|
|
|
769
|
-
/** @type {(state: EofState) => (input: number) => readonly[
|
|
769
|
+
/** @type {(state: EofState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
770
770
|
const eofStateOp = create(state => () => [[{ kind: 'error', message: 'eof' }], state])([])
|
|
771
771
|
|
|
772
|
-
/** @type {
|
|
772
|
+
/** @type {operator.StateScan<number, TokenizerState, list.List<JsToken>>} */
|
|
773
773
|
const tokenizeCharCodeOp = state => {
|
|
774
774
|
switch (state.kind) {
|
|
775
775
|
case 'initial': return initialStateOp(state)
|
|
@@ -787,7 +787,7 @@ const tokenizeCharCodeOp = state => {
|
|
|
787
787
|
}
|
|
788
788
|
}
|
|
789
789
|
|
|
790
|
-
/** @type {(state: TokenizerState) => readonly[
|
|
790
|
+
/** @type {(state: TokenizerState) => readonly[list.List<JsToken>, TokenizerState]} */
|
|
791
791
|
const tokenizeEofOp = state => {
|
|
792
792
|
switch (state.kind) {
|
|
793
793
|
case 'initial': return [empty, { kind: 'eof' }]
|
|
@@ -812,19 +812,12 @@ const tokenizeEofOp = state => {
|
|
|
812
812
|
}
|
|
813
813
|
}
|
|
814
814
|
|
|
815
|
-
/** @type {
|
|
815
|
+
/** @type {operator.StateScan<CharCodeOrEof, TokenizerState, list.List<JsToken>>} */
|
|
816
816
|
const tokenizeOp = state => input => input === null ? tokenizeEofOp(state) : tokenizeCharCodeOp(state)(input)
|
|
817
817
|
|
|
818
818
|
const scanTokenize = stateScan(tokenizeOp)
|
|
819
819
|
|
|
820
820
|
const initial = scanTokenize({ kind: 'initial' })
|
|
821
821
|
|
|
822
|
-
/** @type {(input:
|
|
823
|
-
const tokenize = input => flat(initial(flat([/** @type {
|
|
824
|
-
|
|
825
|
-
export default {
|
|
826
|
-
/** @readonly */
|
|
827
|
-
tokenize,
|
|
828
|
-
/** @readonly */
|
|
829
|
-
isKeywordToken
|
|
830
|
-
}
|
|
822
|
+
/** @type {(input: list.List<number>) => list.List<JsToken>} */
|
|
823
|
+
export const tokenize = input => flat(initial(flat([/** @type {list.List<CharCodeOrEof>} */(input), [null]])))
|
package/js/tokenizer/test.f.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import list from '../../types/list/module.f.mjs'
|
|
1
|
+
import * as tokenizer from './module.f.mjs'
|
|
2
|
+
import * as list from '../../types/list/module.f.mjs'
|
|
3
3
|
const { toArray } = list
|
|
4
|
-
import djs from '../../djs/module.f.mjs'
|
|
5
|
-
import o from '../../types/object/module.f.mjs'
|
|
4
|
+
import * as djs from '../../djs/module.f.mjs'
|
|
5
|
+
import * as o from '../../types/object/module.f.mjs'
|
|
6
6
|
const { sort } = o
|
|
7
|
-
import encoding from '../../text/utf16/module.f.mjs'
|
|
7
|
+
import * as encoding from '../../text/utf16/module.f.mjs'
|
|
8
8
|
|
|
9
|
-
/** @type {(s: string) => readonly
|
|
9
|
+
/** @type {(s: string) => readonly tokenizer.JsToken[]} */
|
|
10
10
|
const tokenizeString = s => toArray(tokenizer.tokenize(encoding.stringToList(s)))
|
|
11
11
|
|
|
12
12
|
const stringify = djs.stringify(sort)
|
package/json/module.f.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// @ts-self-types="./module.f.d.mts"
|
|
2
|
-
import
|
|
2
|
+
import * as list from '../types/list/module.f.mjs'
|
|
3
3
|
const { next, flat, map } = list
|
|
4
|
-
import string from '../types/string/module.f.mjs'
|
|
4
|
+
import * as string from '../types/string/module.f.mjs'
|
|
5
5
|
const { concat } = string
|
|
6
|
-
import
|
|
6
|
+
import * as object from '../types/object/module.f.mjs'
|
|
7
7
|
const { at } = object
|
|
8
|
-
import f from '../types/function/module.f.mjs'
|
|
8
|
+
import * as f from '../types/function/module.f.mjs'
|
|
9
9
|
const { compose, fn } = f
|
|
10
10
|
const { entries } = Object
|
|
11
|
-
import s from './serializer/module.f.mjs'
|
|
11
|
+
import * as s from './serializer/module.f.mjs'
|
|
12
12
|
const { objectWrap, arrayWrap, stringSerialize, numberSerialize, nullSerialize, boolSerialize } = s
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -21,9 +21,9 @@ const { objectWrap, arrayWrap, stringSerialize, numberSerialize, nullSerialize,
|
|
|
21
21
|
|
|
22
22
|
/** @typedef {Object|boolean|string|number|null|Array} Unknown */
|
|
23
23
|
|
|
24
|
-
/** @type {(value: Unknown) => (path:
|
|
25
|
-
const setProperty = value => {
|
|
26
|
-
/** @type {(path:
|
|
24
|
+
/** @type {(value: Unknown) => (path: list.List<string>) => (src: Unknown) => Unknown} */
|
|
25
|
+
export const setProperty = value => {
|
|
26
|
+
/** @type {(path: list.List<string>) => (src: Unknown) => Unknown} */
|
|
27
27
|
const f = path => src => {
|
|
28
28
|
const result = next(path)
|
|
29
29
|
if (result === null) { return value }
|
|
@@ -36,28 +36,28 @@ const setProperty = value => {
|
|
|
36
36
|
|
|
37
37
|
const colon = [':']
|
|
38
38
|
|
|
39
|
-
/** @typedef {
|
|
39
|
+
/** @typedef {object.Entry<Unknown>} Entry*/
|
|
40
40
|
|
|
41
|
-
/** @typedef {(
|
|
41
|
+
/** @typedef {(list.List<Entry>)} Entries */
|
|
42
42
|
|
|
43
43
|
/** @typedef {(entries: Entries) => Entries} MapEntries */
|
|
44
44
|
|
|
45
|
-
/** @type {(mapEntries: MapEntries) => (value: Unknown) =>
|
|
46
|
-
const serialize = sort => {
|
|
47
|
-
/** @type {(kv: readonly[string, Unknown]) =>
|
|
45
|
+
/** @type {(mapEntries: MapEntries) => (value: Unknown) => list.List<string>} */
|
|
46
|
+
export const serialize = sort => {
|
|
47
|
+
/** @type {(kv: readonly[string, Unknown]) => list.List<string>} */
|
|
48
48
|
const propertySerialize = ([k, v]) => flat([
|
|
49
49
|
stringSerialize(k),
|
|
50
50
|
colon,
|
|
51
51
|
f(v)
|
|
52
52
|
])
|
|
53
53
|
const mapPropertySerialize = map(propertySerialize)
|
|
54
|
-
/** @type {(object: Object) =>
|
|
54
|
+
/** @type {(object: Object) => list.List<string>} */
|
|
55
55
|
const objectSerialize = fn(entries)
|
|
56
56
|
.then(sort)
|
|
57
57
|
.then(mapPropertySerialize)
|
|
58
58
|
.then(objectWrap)
|
|
59
59
|
.result
|
|
60
|
-
/** @type {(value: Unknown) =>
|
|
60
|
+
/** @type {(value: Unknown) => list.List<string>} */
|
|
61
61
|
const f = value => {
|
|
62
62
|
switch (typeof value) {
|
|
63
63
|
case 'boolean': { return boolSerialize(value) }
|
|
@@ -80,23 +80,10 @@ const serialize = sort => {
|
|
|
80
80
|
*
|
|
81
81
|
* @type {(mapEntries: MapEntries) => (value: Unknown) => string}
|
|
82
82
|
*/
|
|
83
|
-
const stringify = sort => compose(serialize(sort))(concat)
|
|
83
|
+
export const stringify = sort => compose(serialize(sort))(concat)
|
|
84
84
|
|
|
85
85
|
/** @type {(value: string) => Unknown} */
|
|
86
|
-
const parse = JSON.parse
|
|
86
|
+
export const parse = JSON.parse
|
|
87
87
|
|
|
88
88
|
/** @type {(value: Unknown) => value is Object} */
|
|
89
|
-
const isObject = value => typeof value === 'object' && value !== null && !(value instanceof Array)
|
|
90
|
-
|
|
91
|
-
export default {
|
|
92
|
-
/** @readonly */
|
|
93
|
-
setProperty,
|
|
94
|
-
/** @readonly */
|
|
95
|
-
stringify,
|
|
96
|
-
/** @readonly */
|
|
97
|
-
serialize,
|
|
98
|
-
/** @readonly */
|
|
99
|
-
parse,
|
|
100
|
-
/** @readonly */
|
|
101
|
-
isObject,
|
|
102
|
-
}
|
|
89
|
+
export const isObject = value => typeof value === 'object' && value !== null && !(value instanceof Array)
|
package/json/parser/module.f.mjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
// @ts-self-types="./module.f.d.mts"
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import * as result from '../../types/result/module.f.mjs'
|
|
3
|
+
import * as list from '../../types/list/module.f.mjs'
|
|
4
4
|
const { fold, first, drop, toArray } = list
|
|
5
5
|
import * as Operator from '../../types/function/operator/module.f.mjs'
|
|
6
6
|
import * as Tokenizer from '../tokenizer/module.f.mjs'
|
|
7
|
-
import
|
|
7
|
+
import * as map from '../../types/map/module.f.mjs'
|
|
8
8
|
const { setReplace } = map
|
|
9
9
|
import * as Json from '../module.f.mjs'
|
|
10
|
-
import o from '../../types/object/module.f.mjs'
|
|
10
|
+
import * as o from '../../types/object/module.f.mjs'
|
|
11
11
|
const { fromMap } = o
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* @typedef {{
|
|
16
16
|
* readonly kind: 'object'
|
|
17
|
-
* readonly values:
|
|
17
|
+
* readonly values: map.Map<Json.Unknown>
|
|
18
18
|
* readonly key: string
|
|
19
19
|
* }} JsonObject
|
|
20
20
|
* */
|
|
@@ -22,7 +22,7 @@ const { fromMap } = o
|
|
|
22
22
|
/**
|
|
23
23
|
* @typedef {{
|
|
24
24
|
* readonly kind: 'array'
|
|
25
|
-
* readonly values:
|
|
25
|
+
* readonly values: list.List<Json.Unknown>
|
|
26
26
|
* }} JsonArray
|
|
27
27
|
* */
|
|
28
28
|
|
|
@@ -33,7 +33,7 @@ const { fromMap } = o
|
|
|
33
33
|
* } JsonStackElement
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
|
-
/** @typedef {
|
|
36
|
+
/** @typedef {list.List<JsonStackElement>} JsonStack */
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* @typedef {{
|
|
@@ -206,8 +206,8 @@ const foldOp = token => state => {
|
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
/** @type {(tokenList:
|
|
210
|
-
const parse = tokenList => {
|
|
209
|
+
/** @type {(tokenList: list.List<Tokenizer.JsonToken>) => result.Result<Json.Unknown, string>} */
|
|
210
|
+
export const parse = tokenList => {
|
|
211
211
|
const state = fold(foldOp)({ status: '', top: null, stack: null })(tokenList)
|
|
212
212
|
switch (state.status) {
|
|
213
213
|
case 'result': return result.ok(state.value)
|
|
@@ -215,8 +215,3 @@ const parse = tokenList => {
|
|
|
215
215
|
default: return result.error('unexpected end')
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
-
|
|
219
|
-
export default {
|
|
220
|
-
/** @readonly */
|
|
221
|
-
parse
|
|
222
|
-
}
|
package/json/parser/test.f.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import parser from './module.f.mjs'
|
|
2
|
-
import
|
|
3
|
-
import list from '../../types/list/module.f.mjs'
|
|
1
|
+
import * as parser from './module.f.mjs'
|
|
2
|
+
import * as tokenizer from '../tokenizer/module.f.mjs'
|
|
3
|
+
import * as list from '../../types/list/module.f.mjs'
|
|
4
4
|
const { toArray } = list
|
|
5
|
-
import json from '../module.f.mjs'
|
|
6
|
-
import o from '../../types/object/module.f.mjs'
|
|
5
|
+
import * as json from '../module.f.mjs'
|
|
6
|
+
import * as o from '../../types/object/module.f.mjs'
|
|
7
7
|
const { sort } = o
|
|
8
|
-
import encoding from '../../text/utf16/module.f.mjs'
|
|
8
|
+
import * as encoding from '../../text/utf16/module.f.mjs'
|
|
9
9
|
|
|
10
|
-
/** @type {(s: string) => readonly
|
|
10
|
+
/** @type {(s: string) => readonly tokenizer.JsonToken[]} */
|
|
11
11
|
const tokenizeString = s => toArray(tokenizer.tokenize(encoding.stringToList(s)))
|
|
12
12
|
|
|
13
13
|
const stringify = json.stringify(sort)
|