functionalscript 0.44.0 → 0.46.0
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/README.md +5 -3
- package/fjs/asn.1/module.f.mjs +8 -1
- package/fjs/asn.1/proof.f.d.mts +15 -0
- package/fjs/asn.1/proof.f.mjs +31 -3
- package/fjs/asserts/module.f.d.mts +14 -0
- package/fjs/asserts/module.f.mjs +20 -0
- package/fjs/asserts/proof.f.d.mts +3 -0
- package/fjs/asserts/proof.f.mjs +15 -1
- package/fjs/basen/base128/module.f.mjs +22 -5
- package/fjs/basen/base128/proof.f.d.mts +3 -1
- package/fjs/basen/base128/proof.f.mjs +3 -1
- package/fjs/basen/base64/module.f.mjs +7 -3
- package/fjs/basen/base64/proof.f.d.mts +3 -1
- package/fjs/basen/base64/proof.f.mjs +7 -4
- package/fjs/basen/cbase32/proof.f.d.mts +3 -1
- package/fjs/basen/cbase32/proof.f.mjs +3 -1
- package/fjs/bnf/data/module.f.d.mts +32 -6
- package/fjs/bnf/data/module.f.mjs +112 -7
- package/fjs/bnf/data/proof.f.d.mts +2 -0
- package/fjs/bnf/data/proof.f.mjs +74 -4
- package/fjs/bnf/data/types.d.ts +20 -2
- package/fjs/bnf/descent/module.f.d.mts +34 -5
- package/fjs/bnf/descent/module.f.mjs +176 -54
- package/fjs/bnf/descent/proof.f.d.mts +3 -0
- package/fjs/bnf/descent/proof.f.mjs +189 -27
- package/fjs/bnf/descent/types.d.ts +24 -18
- package/fjs/bnf/ll1/module.f.d.mts +74 -6
- package/fjs/bnf/ll1/module.f.mjs +297 -95
- package/fjs/bnf/ll1/proof.f.d.mts +17 -2
- package/fjs/bnf/ll1/proof.f.mjs +372 -137
- package/fjs/bnf/ll1/types.d.ts +25 -27
- package/fjs/bnf/matcher/module.f.d.mts +66 -0
- package/fjs/bnf/matcher/module.f.mjs +81 -0
- package/fjs/bnf/matcher/proof.f.d.mts +10 -0
- package/fjs/bnf/matcher/proof.f.mjs +79 -0
- package/fjs/bnf/matcher/types.d.ts +54 -0
- package/fjs/bnf/module.f.d.mts +15 -6
- package/fjs/bnf/module.f.mjs +52 -11
- package/fjs/bnf/proof.f.d.mts +2 -0
- package/fjs/bnf/proof.f.mjs +79 -3
- package/fjs/bnf/testlib.f.d.mts +31 -0
- package/fjs/bnf/testlib.f.mjs +80 -0
- package/fjs/bnf/token_symbol/module.f.d.mts +4 -3
- package/fjs/bnf/token_symbol/module.f.mjs +7 -6
- package/fjs/bnf/token_symbol/proof.f.mjs +5 -2
- package/fjs/bnf/token_symbol/types.d.ts +2 -2
- package/fjs/bnf/types.d.ts +10 -3
- package/fjs/cas/cli/module.f.d.mts +1 -1
- package/fjs/cas/cli/module.f.mjs +14 -20
- package/fjs/cas/cli/proof.f.d.mts +4 -4
- package/fjs/cas/cli/proof.f.mjs +47 -34
- package/fjs/cas/evo/module.f.d.mts +71 -31
- package/fjs/cas/evo/module.f.mjs +223 -138
- package/fjs/cas/evo/proof.f.d.mts +10 -1
- package/fjs/cas/evo/proof.f.mjs +311 -226
- package/fjs/cas/evo/types.d.ts +45 -9
- package/fjs/cas/module.f.d.mts +18 -32
- package/fjs/cas/module.f.mjs +164 -176
- package/fjs/cas/proof.f.d.mts +11 -8
- package/fjs/cas/proof.f.mjs +259 -147
- package/fjs/cas/types.d.ts +24 -10
- package/fjs/ci/common/module.f.d.mts +1 -1
- package/fjs/ci/common/module.f.mjs +1 -0
- package/fjs/ci/config/module.f.d.mts +3 -3
- package/fjs/ci/config/module.f.mjs +3 -3
- package/fjs/ci/module.f.d.mts +5 -5
- package/fjs/ci/module.f.mjs +8 -7
- package/fjs/ci/nix/module.f.d.mts +7 -5
- package/fjs/ci/nix/module.f.mjs +13 -12
- package/fjs/ci/nix/proof.f.d.mts +2 -0
- package/fjs/ci/nix/proof.f.mjs +4 -4
- package/fjs/ci/proof.f.d.mts +4 -2
- package/fjs/ci/proof.f.mjs +13 -8
- package/fjs/cli/module.f.d.mts +4 -6
- package/fjs/cli/module.f.mjs +4 -8
- package/fjs/cli/proof.f.d.mts +4 -2
- package/fjs/cli/proof.f.mjs +21 -18
- package/fjs/cli/types.d.ts +2 -3
- package/fjs/common/monoid/module.f.d.mts +70 -12
- package/fjs/common/monoid/module.f.mjs +177 -14
- package/fjs/common/monoid/proof.f.d.mts +12 -1
- package/fjs/common/monoid/proof.f.mjs +88 -4
- package/fjs/common/monoid/types.d.ts +23 -0
- package/fjs/crypto/hmac/module.f.mjs +2 -2
- package/fjs/crypto/secp/proof.f.d.mts +3 -1
- package/fjs/crypto/secp/proof.f.mjs +3 -1
- package/fjs/crypto/sha2/module.f.mjs +3 -1
- package/fjs/crypto/sha2/proof.f.d.mts +4 -1
- package/fjs/crypto/sha2/proof.f.mjs +27 -1
- package/fjs/crypto/sha2/types.d.ts +11 -0
- package/fjs/crypto/sign/module.f.mjs +2 -2
- package/fjs/crypto/vdf/module.f.d.mts +23 -4
- package/fjs/crypto/vdf/module.f.mjs +6 -4
- package/fjs/dev/module.f.d.mts +17 -5
- package/fjs/dev/module.f.mjs +60 -30
- package/fjs/dev/update/module.f.d.mts +11 -3
- package/fjs/dev/update/module.f.mjs +16 -11
- package/fjs/dev/update/proof.f.d.mts +4 -3
- package/fjs/dev/update/proof.f.mjs +11 -7
- package/fjs/djs/module.f.d.mts +13 -5
- package/fjs/djs/module.f.mjs +31 -16
- package/fjs/djs/parser/module.f.d.mts +16 -3
- package/fjs/djs/parser/module.f.mjs +135 -16
- package/fjs/djs/parser/proof.f.d.mts +8 -1
- package/fjs/djs/parser/proof.f.mjs +287 -13
- package/fjs/djs/parser/types.d.ts +7 -1
- package/fjs/djs/proof.f.d.mts +20 -1
- package/fjs/djs/proof.f.mjs +190 -12
- package/fjs/djs/serializer/module.f.d.mts +25 -8
- package/fjs/djs/serializer/module.f.mjs +66 -19
- package/fjs/djs/serializer/proof.f.d.mts +5 -0
- package/fjs/djs/serializer/proof.f.mjs +23 -1
- package/fjs/djs/tokenizer/module.f.d.mts +17 -5
- package/fjs/djs/tokenizer/module.f.mjs +120 -73
- package/fjs/djs/tokenizer/proof.f.d.mts +3 -0
- package/fjs/djs/tokenizer/proof.f.mjs +86 -67
- package/fjs/djs/transpiler/module.f.d.mts +13 -19
- package/fjs/djs/transpiler/module.f.mjs +79 -72
- package/fjs/djs/transpiler/types.d.ts +29 -0
- package/fjs/djs/types.d.ts +7 -1
- package/fjs/effects/list/module.f.d.mts +23 -12
- package/fjs/effects/list/module.f.mjs +16 -12
- package/fjs/effects/list/types.d.ts +27 -7
- package/fjs/effects/memory/module.f.d.mts +6 -3
- package/fjs/effects/memory/module.f.mjs +7 -7
- package/fjs/effects/memory/proof.f.d.mts +4 -0
- package/fjs/effects/memory/proof.f.mjs +18 -9
- package/fjs/effects/memory/types.d.ts +4 -3
- package/fjs/effects/mock/module.f.d.mts +28 -4
- package/fjs/effects/mock/module.f.mjs +39 -5
- package/fjs/effects/mock/types.d.ts +10 -1
- package/fjs/effects/module.d.mts +12 -2
- package/fjs/effects/module.f.d.mts +469 -281
- package/fjs/effects/module.f.mjs +538 -299
- package/fjs/effects/module.mjs +11 -2
- package/fjs/effects/node/memory/module.d.mts +7 -2
- package/fjs/effects/node/memory/module.mjs +9 -5
- package/fjs/effects/node/memory/proof.d.mts +2 -0
- package/fjs/effects/node/memory/proof.mjs +12 -5
- package/fjs/effects/node/module.d.mts +8 -2
- package/fjs/effects/node/module.f.d.mts +183 -43
- package/fjs/effects/node/module.f.mjs +260 -62
- package/fjs/effects/node/module.mjs +61 -50
- package/fjs/effects/node/proof.f.d.mts +28 -2
- package/fjs/effects/node/proof.f.mjs +161 -42
- package/fjs/effects/node/types.d.ts +106 -18
- package/fjs/effects/node/virtual/module.f.d.mts +21 -4
- package/fjs/effects/node/virtual/module.f.mjs +113 -70
- package/fjs/effects/node/virtual/proof.f.d.mts +31 -2
- package/fjs/effects/node/virtual/proof.f.mjs +201 -8
- package/fjs/effects/proof.f.d.mts +69 -34
- package/fjs/effects/proof.f.mjs +413 -130
- package/fjs/effects/types.d.ts +161 -33
- package/fjs/emergent_testing/all.test.d.mts +8 -0
- package/fjs/emergent_testing/all.test.mjs +14 -0
- package/fjs/emergent_testing/module.f.d.mts +22 -10
- package/fjs/emergent_testing/module.f.mjs +119 -85
- package/fjs/emergent_testing/proof.f.d.mts +21 -7
- package/fjs/emergent_testing/proof.f.mjs +169 -35
- package/fjs/emergent_testing/types.d.ts +22 -4
- package/fjs/fsc/bnf.f.d.mts +3 -0
- package/fjs/fsc/bnf.f.mjs +4 -1
- package/fjs/fsc/json.f.d.mts +3 -0
- package/fjs/fsc/json.f.mjs +4 -1
- package/fjs/fsc/module.f.d.mts +9 -0
- package/fjs/fsc/module.f.mjs +5 -3
- package/fjs/fsm/module.f.d.mts +14 -4
- package/fjs/fsm/module.f.mjs +54 -37
- package/fjs/fsm/proof.f.d.mts +5 -0
- package/fjs/fsm/proof.f.mjs +87 -115
- package/fjs/js/keywords/module.f.d.mts +52 -0
- package/fjs/js/keywords/module.f.mjs +72 -0
- package/fjs/{emergent_testing/scenarios/return-value.pass.d.ts → js/keywords/proof.f.d.mts} +1 -1
- package/fjs/js/keywords/proof.f.mjs +13 -0
- package/fjs/js/tokenizer/module.f.d.mts +30 -3
- package/fjs/js/tokenizer/module.f.mjs +161 -211
- package/fjs/js/tokenizer/proof.f.d.mts +1 -0
- package/fjs/js/tokenizer/proof.f.mjs +54 -24
- package/fjs/js/tokenizer/types.d.ts +33 -24
- package/fjs/mcp/cas/module.f.d.mts +1 -6
- package/fjs/mcp/cas/module.f.mjs +55 -51
- package/fjs/mcp/cas/proof.f.d.mts +15 -0
- package/fjs/mcp/cas/proof.f.mjs +174 -0
- package/fjs/mcp/evo/module.f.d.mts +19 -10
- package/fjs/mcp/evo/module.f.mjs +48 -27
- package/fjs/mcp/evo/proof.f.d.mts +6 -1
- package/fjs/mcp/evo/proof.f.mjs +115 -31
- package/fjs/mcp/module.f.d.mts +39 -4
- package/fjs/mcp/module.f.mjs +14 -12
- package/fjs/mcp/proof.f.d.mts +13 -1
- package/fjs/mcp/proof.f.mjs +120 -61
- package/fjs/media/html/module.f.d.mts +12 -0
- package/fjs/media/html/module.f.mjs +7 -5
- package/fjs/media/html/proof.f.d.mts +3 -0
- package/fjs/media/html/proof.f.mjs +4 -1
- package/fjs/media/json/extended/module.f.d.mts +82 -0
- package/fjs/media/json/extended/module.f.mjs +153 -0
- package/fjs/media/json/extended/proof.f.d.mts +42 -0
- package/fjs/media/json/extended/proof.f.mjs +127 -0
- package/fjs/media/json/extended/types.d.ts +23 -0
- package/fjs/media/json/module.f.d.mts +8 -2
- package/fjs/media/json/module.f.mjs +43 -41
- package/fjs/media/json/number/module.f.d.mts +59 -0
- package/fjs/media/json/number/module.f.mjs +136 -0
- package/fjs/media/json/number/proof.f.d.mts +24 -0
- package/fjs/media/json/number/proof.f.mjs +86 -0
- package/fjs/media/json/number/types.d.ts +28 -0
- package/fjs/media/json/parser/module.f.d.mts +25 -13
- package/fjs/media/json/parser/module.f.mjs +133 -72
- package/fjs/media/json/parser/proof.f.d.mts +5 -0
- package/fjs/media/json/parser/proof.f.mjs +31 -1
- package/fjs/media/json/parser/types.d.ts +38 -14
- package/fjs/media/json/rtti/module.f.d.mts +1 -1
- package/fjs/media/json/rtti/module.f.mjs +1 -1
- package/fjs/media/json/rtti/proof.f.d.mts +3 -0
- package/fjs/media/json/rtti/proof.f.mjs +12 -12
- package/fjs/media/json/schema/module.f.d.mts +61 -27
- package/fjs/media/json/schema/module.f.mjs +218 -63
- package/fjs/media/json/schema/proof.f.d.mts +41 -1
- package/fjs/media/json/schema/proof.f.mjs +220 -9
- package/fjs/media/json/serializer/module.f.d.mts +44 -0
- package/fjs/media/json/serializer/module.f.mjs +71 -9
- package/fjs/media/json/tokenizer/module.f.d.mts +8 -0
- package/fjs/media/json/tokenizer/module.f.mjs +31 -8
- package/fjs/media/json/tokenizer/proof.f.d.mts +6 -0
- package/fjs/media/json/tokenizer/proof.f.mjs +62 -21
- package/fjs/media/json/types.d.ts +36 -10
- package/fjs/media/lock/module.f.d.mts +100 -0
- package/fjs/media/lock/module.f.mjs +125 -0
- package/fjs/media/lock/proof.f.d.mts +33 -0
- package/fjs/media/lock/proof.f.mjs +196 -0
- package/fjs/media/lock/types.d.ts +15 -0
- package/fjs/media/module.f.d.mts +6 -5
- package/fjs/media/module.f.mjs +8 -7
- package/fjs/media/nix/module.f.d.mts +13 -0
- package/fjs/media/nix/module.f.mjs +4 -2
- package/fjs/media/nix/proof.f.d.mts +3 -0
- package/fjs/media/nix/proof.f.mjs +4 -1
- package/fjs/media/note/module.f.d.mts +121 -0
- package/fjs/media/note/module.f.mjs +131 -0
- package/fjs/media/note/proof.f.d.mts +29 -0
- package/fjs/media/note/proof.f.mjs +150 -0
- package/fjs/media/note/types.d.ts +10 -0
- package/fjs/media/proof.f.d.mts +4 -1
- package/fjs/media/proof.f.mjs +40 -21
- package/fjs/media/revision/module.f.d.mts +83 -7
- package/fjs/media/revision/module.f.mjs +127 -23
- package/fjs/media/revision/proof.f.d.mts +14 -0
- package/fjs/media/revision/proof.f.mjs +93 -2
- package/fjs/media/revision/types.d.ts +34 -5
- package/fjs/media/type/module.f.d.mts +53 -18
- package/fjs/media/type/module.f.mjs +87 -97
- package/fjs/media/type/proof.f.d.mts +17 -0
- package/fjs/media/type/proof.f.mjs +73 -13
- package/fjs/module.d.mts +5 -0
- package/fjs/module.f.d.mts +8 -0
- package/fjs/module.f.mjs +33 -10
- package/fjs/module.mjs +6 -0
- package/fjs/nanvm/proof.f.mjs +3 -3
- package/fjs/nanvm/rust/module.f.mjs +1 -1
- package/fjs/nanvm/update/module.f.d.mts +4 -4
- package/fjs/nanvm/update/module.f.mjs +8 -9
- package/fjs/nanvm/update/proof.f.mjs +4 -3
- package/fjs/path/module.f.d.mts +8 -0
- package/fjs/path/module.f.mjs +4 -2
- package/fjs/proof.f.d.mts +7 -3
- package/fjs/proof.f.mjs +41 -12
- package/fjs/protocol/json_rpc/module.f.d.mts +3 -3
- package/fjs/protocol/json_rpc/module.f.mjs +10 -7
- package/fjs/protocol/json_rpc/proof.f.d.mts +6 -0
- package/fjs/protocol/json_rpc/proof.f.mjs +26 -5
- package/fjs/protocol/mcp/module.f.d.mts +10 -13
- package/fjs/protocol/mcp/module.f.mjs +74 -58
- package/fjs/protocol/mcp/proof.f.d.mts +16 -3
- package/fjs/protocol/mcp/proof.f.mjs +224 -69
- package/fjs/protocol/mcp/stdio/module.f.d.mts +17 -11
- package/fjs/protocol/mcp/stdio/module.f.mjs +39 -33
- package/fjs/protocol/mcp/stdio/proof.f.d.mts +5 -3
- package/fjs/protocol/mcp/stdio/proof.f.mjs +46 -13
- package/fjs/protocol/mcp/stdio/types.d.ts +14 -0
- package/fjs/protocol/mcp/types.d.ts +17 -6
- package/fjs/sul/id/module.f.d.mts +4 -0
- package/fjs/sul/id/module.f.mjs +6 -6
- package/fjs/sul/level/hash/module.f.d.mts +4 -1
- package/fjs/sul/level/hash/module.f.mjs +6 -4
- package/fjs/sul/level/hash/proof.f.d.mts +4 -0
- package/fjs/sul/level/hash/proof.f.mjs +7 -4
- package/fjs/sul/level/literal/module.f.d.mts +4 -1
- package/fjs/sul/level/literal/module.f.mjs +4 -3
- package/fjs/sul/level/literal/proof.f.d.mts +3 -0
- package/fjs/sul/level/literal/proof.f.mjs +4 -1
- package/fjs/sul/module.f.d.mts +5 -3
- package/fjs/sul/module.f.mjs +23 -17
- package/fjs/sul/proof.f.d.mts +4 -0
- package/fjs/sul/proof.f.mjs +5 -2
- package/fjs/text/ascii/module.f.d.mts +26 -0
- package/fjs/text/ascii/module.f.mjs +49 -1
- package/fjs/text/ascii/proof.f.d.mts +10 -0
- package/fjs/text/ascii/proof.f.mjs +33 -1
- package/fjs/text/code_point/module.f.d.mts +29 -3
- package/fjs/text/code_point/module.f.mjs +32 -9
- package/fjs/text/code_point/proof.f.d.mts +2 -0
- package/fjs/text/code_point/proof.f.mjs +39 -0
- package/fjs/text/module.f.d.mts +4 -2
- package/fjs/text/module.f.mjs +4 -3
- package/fjs/text/proof.f.d.mts +3 -0
- package/fjs/text/proof.f.mjs +4 -1
- package/fjs/text/sgr/module.f.d.mts +6 -5
- package/fjs/text/sgr/module.f.mjs +8 -8
- package/fjs/text/sgr/proof.f.d.mts +3 -0
- package/fjs/text/sgr/proof.f.mjs +4 -1
- package/fjs/text/utf16/module.f.d.mts +5 -1
- package/fjs/text/utf16/module.f.mjs +38 -35
- package/fjs/text/utf16/proof.f.d.mts +3 -1
- package/fjs/text/utf16/proof.f.mjs +19 -2
- package/fjs/text/utf8/module.f.d.mts +9 -5
- package/fjs/text/utf8/module.f.mjs +20 -20
- package/fjs/types/array/module.f.d.mts +2 -1
- package/fjs/types/array/module.f.mjs +16 -4
- package/fjs/types/bigfloat/module.f.d.mts +21 -1
- package/fjs/types/bigfloat/module.f.mjs +33 -7
- package/fjs/types/bigfloat/proof.f.d.mts +1 -0
- package/fjs/types/bigfloat/proof.f.mjs +46 -0
- package/fjs/types/bigint/module.f.d.mts +4 -0
- package/fjs/types/bigint/module.f.mjs +4 -3
- package/fjs/types/bit_vec/module.f.d.mts +10 -16
- package/fjs/types/bit_vec/module.f.mjs +99 -95
- package/fjs/types/bit_vec/proof.f.d.mts +6 -0
- package/fjs/types/bit_vec/proof.f.mjs +31 -5
- package/fjs/types/btree/find/module.f.d.mts +5 -1
- package/fjs/types/btree/find/module.f.mjs +5 -5
- package/fjs/types/btree/find/proof.f.d.mts +5 -1
- package/fjs/types/btree/find/proof.f.mjs +5 -3
- package/fjs/types/btree/module.f.d.mts +3 -0
- package/fjs/types/btree/module.f.mjs +3 -2
- package/fjs/types/btree/proof.f.d.mts +5 -1
- package/fjs/types/btree/proof.f.mjs +5 -3
- package/fjs/types/btree/remove/module.f.d.mts +11 -0
- package/fjs/types/btree/remove/module.f.mjs +10 -10
- package/fjs/types/btree/remove/proof.f.d.mts +3 -0
- package/fjs/types/btree/remove/proof.f.mjs +4 -1
- package/fjs/types/btree/set/module.f.d.mts +9 -0
- package/fjs/types/btree/set/module.f.mjs +14 -17
- package/fjs/types/btree/set/proof.f.d.mts +3 -0
- package/fjs/types/btree/set/proof.f.mjs +16 -1
- package/fjs/types/btree/types/module.f.d.mts +2 -1
- package/fjs/types/btree/types/module.f.mjs +2 -1
- package/fjs/types/byte_set/module.f.d.mts +20 -4
- package/fjs/types/byte_set/module.f.mjs +18 -8
- package/fjs/types/byte_set/proof.f.d.mts +3 -1
- package/fjs/types/byte_set/proof.f.mjs +10 -8
- package/fjs/types/function/compare/module.f.d.mts +3 -2
- package/fjs/types/function/compare/module.f.mjs +13 -5
- package/fjs/types/function/module.f.d.mts +8 -1
- package/fjs/types/function/module.f.mjs +8 -1
- package/fjs/types/function/operator/module.f.d.mts +2 -1
- package/fjs/types/function/operator/module.f.mjs +2 -2
- package/fjs/types/list/module.f.d.mts +10 -3
- package/fjs/types/list/module.f.mjs +6 -4
- package/fjs/types/list/proof.f.d.mts +4 -1
- package/fjs/types/list/proof.f.mjs +4 -2
- package/fjs/types/nibble_set/module.f.d.mts +2 -1
- package/fjs/types/nibble_set/module.f.mjs +2 -2
- package/fjs/types/nominal/module.f.d.mts +2 -1
- package/fjs/types/nominal/module.f.mjs +2 -1
- package/fjs/types/nullable/module.f.d.mts +26 -6
- package/fjs/types/nullable/module.f.mjs +25 -6
- package/fjs/types/nullable/proof.f.d.mts +4 -0
- package/fjs/types/nullable/proof.f.mjs +15 -0
- package/fjs/types/number/module.f.d.mts +4 -0
- package/fjs/types/number/module.f.mjs +4 -3
- package/fjs/types/object/module.f.d.mts +26 -4
- package/fjs/types/object/module.f.mjs +26 -7
- package/fjs/types/object/proof.f.d.mts +5 -2
- package/fjs/types/object/proof.f.mjs +6 -3
- package/fjs/types/object/structurally_same/module.f.d.mts +39 -0
- package/fjs/types/object/structurally_same/module.f.mjs +59 -0
- package/fjs/types/object/structurally_same/proof.f.d.mts +6 -0
- package/fjs/types/object/structurally_same/proof.f.mjs +73 -0
- package/fjs/types/ordered_map/module.f.d.mts +5 -0
- package/fjs/types/ordered_map/module.f.mjs +5 -4
- package/fjs/types/ordered_map/proof.f.d.mts +3 -0
- package/fjs/types/ordered_map/proof.f.mjs +4 -1
- package/fjs/types/patricia_trie/module.f.d.mts +2 -1
- package/fjs/types/patricia_trie/module.f.mjs +27 -12
- package/fjs/types/patricia_trie/proof.f.d.mts +3 -0
- package/fjs/types/patricia_trie/proof.f.mjs +4 -1
- package/fjs/types/prime_field/module.f.d.mts +3 -1
- package/fjs/types/prime_field/module.f.mjs +3 -2
- package/fjs/types/range/module.f.d.mts +2 -1
- package/fjs/types/range/module.f.mjs +2 -2
- package/fjs/types/range_map/module.f.d.mts +6 -0
- package/fjs/types/range_map/module.f.mjs +6 -9
- package/fjs/types/range_map/proof.f.d.mts +5 -1
- package/fjs/types/range_map/proof.f.mjs +5 -3
- package/fjs/types/range_set/module.f.d.mts +5 -0
- package/fjs/types/range_set/module.f.mjs +1 -0
- package/fjs/types/range_set/proof.f.d.mts +3 -0
- package/fjs/types/range_set/proof.f.mjs +4 -1
- package/fjs/types/result/module.d.mts +8 -0
- package/fjs/types/result/module.f.d.mts +37 -7
- package/fjs/types/result/module.f.mjs +38 -8
- package/fjs/types/result/module.mjs +9 -1
- package/fjs/types/result/proof.f.d.mts +5 -0
- package/fjs/types/result/proof.f.mjs +22 -2
- package/fjs/types/rtti/common/module.f.d.mts +44 -14
- package/fjs/types/rtti/common/module.f.mjs +42 -36
- package/fjs/types/rtti/common/proof.f.d.mts +4 -0
- package/fjs/types/rtti/common/proof.f.mjs +10 -7
- package/fjs/types/rtti/data/module.f.d.mts +134 -0
- package/fjs/types/rtti/data/module.f.mjs +1053 -0
- package/fjs/types/rtti/data/proof.f.d.mts +76 -0
- package/fjs/types/rtti/data/proof.f.mjs +589 -0
- package/fjs/types/rtti/data/types.d.ts +83 -0
- package/fjs/types/rtti/module.f.d.mts +12 -5
- package/fjs/types/rtti/module.f.mjs +7 -5
- package/fjs/types/rtti/parse/module.f.d.mts +48 -0
- package/fjs/types/rtti/parse/module.f.mjs +45 -34
- package/fjs/types/rtti/parse/proof.f.d.mts +3 -2
- package/fjs/types/rtti/parse/proof.f.mjs +51 -52
- package/fjs/types/rtti/proof.f.d.mts +3 -1
- package/fjs/types/rtti/proof.f.mjs +6 -2
- package/fjs/types/rtti/ts/module.f.d.mts +68 -9
- package/fjs/types/rtti/ts/module.f.mjs +258 -30
- package/fjs/types/rtti/ts/proof.f.d.mts +44 -0
- package/fjs/types/rtti/ts/proof.f.mjs +152 -4
- package/fjs/types/rtti/ts/types.d.ts +25 -1
- package/fjs/types/rtti/types.d.ts +40 -0
- package/fjs/types/sorted_list/module.f.d.mts +4 -1
- package/fjs/types/sorted_list/module.f.mjs +21 -12
- package/fjs/types/sorted_list/proof.f.d.mts +3 -1
- package/fjs/types/sorted_list/proof.f.mjs +3 -1
- package/fjs/types/sorted_set/module.f.d.mts +49 -1
- package/fjs/types/sorted_set/module.f.mjs +26 -2
- package/fjs/types/sorted_set/proof.f.d.mts +4 -1
- package/fjs/types/sorted_set/proof.f.mjs +19 -2
- package/fjs/types/string/module.f.d.mts +4 -0
- package/fjs/types/string/module.f.mjs +4 -3
- package/fjs/types/string_set/module.f.d.mts +3 -1
- package/fjs/types/string_set/module.f.mjs +3 -2
- package/fjs/types/ts/module.f.d.mts +2 -0
- package/fjs/types/ts/module.f.mjs +3 -3
- package/fjs/types/ts/proof.f.d.mts +1 -0
- package/fjs/types/ts/proof.f.mjs +5 -0
- package/fjs/types/ts/types.d.ts +6 -1
- package/fjs/types/uint8array/module.f.d.mts +13 -2
- package/fjs/types/uint8array/module.f.mjs +20 -15
- package/fjs/website/module.f.d.mts +5 -2
- package/fjs/website/module.f.mjs +6 -8
- package/fjs/website/proof.f.mjs +2 -1
- package/package.json +3 -3
- package/fjs/asn.1/types.js +0 -6
- package/fjs/asserts/types.js +0 -6
- package/fjs/basen/types.js +0 -6
- package/fjs/bnf/data/types.js +0 -6
- package/fjs/bnf/descent/types.js +0 -6
- package/fjs/bnf/ll1/types.js +0 -6
- package/fjs/bnf/token_symbol/types.js +0 -6
- package/fjs/bnf/types.js +0 -6
- package/fjs/cas/evo/types.js +0 -7
- package/fjs/cas/types.js +0 -6
- package/fjs/ci/common/types.js +0 -1
- package/fjs/ci/nix/types.js +0 -6
- package/fjs/ci/types.js +0 -6
- package/fjs/cli/types.js +0 -6
- package/fjs/common/monoid/types.js +0 -6
- package/fjs/crypto/pow/types.js +0 -6
- package/fjs/crypto/secp/types.js +0 -6
- package/fjs/crypto/sha2/types.js +0 -6
- package/fjs/crypto/sign/types.js +0 -6
- package/fjs/crypto/vdf/types.js +0 -6
- package/fjs/dev/package_json/module.f.d.mts +0 -32
- package/fjs/dev/package_json/module.f.mjs +0 -37
- package/fjs/dev/package_json/proof.f.d.mts +0 -6
- package/fjs/dev/package_json/proof.f.mjs +0 -32
- package/fjs/dev/types.js +0 -6
- package/fjs/djs/ast/types.js +0 -8
- package/fjs/djs/parser/types.js +0 -7
- package/fjs/djs/tokenizer/types.js +0 -7
- package/fjs/djs/types.js +0 -7
- package/fjs/effects/eff/module.f.d.mts +0 -10
- package/fjs/effects/eff/module.f.mjs +0 -68
- package/fjs/effects/eff/proof.f.d.mts +0 -12
- package/fjs/effects/eff/proof.f.mjs +0 -66
- package/fjs/effects/eff/types.d.ts +0 -71
- package/fjs/effects/eff/types.js +0 -6
- package/fjs/effects/list/types.js +0 -6
- package/fjs/effects/memory/types.js +0 -6
- package/fjs/effects/mock/types.js +0 -6
- package/fjs/effects/node/types.js +0 -6
- package/fjs/effects/node/virtual/types.js +0 -7
- package/fjs/effects/types.js +0 -6
- package/fjs/emergent_testing/all.test.d.ts +0 -1
- package/fjs/emergent_testing/all.test.js +0 -5
- package/fjs/emergent_testing/scenarios/all.d.ts +0 -1
- package/fjs/emergent_testing/scenarios/all.js +0 -1
- package/fjs/emergent_testing/scenarios/async-subtests.fail.d.ts +0 -6
- package/fjs/emergent_testing/scenarios/async-subtests.fail.js +0 -9
- package/fjs/emergent_testing/scenarios/async-subtests.pass.d.ts +0 -6
- package/fjs/emergent_testing/scenarios/async-subtests.pass.js +0 -9
- package/fjs/emergent_testing/scenarios/async.fail.d.ts +0 -3
- package/fjs/emergent_testing/scenarios/async.fail.js +0 -6
- package/fjs/emergent_testing/scenarios/async.pass.d.ts +0 -3
- package/fjs/emergent_testing/scenarios/async.pass.js +0 -5
- package/fjs/emergent_testing/scenarios/fail.fail.d.ts +0 -3
- package/fjs/emergent_testing/scenarios/fail.fail.js +0 -3
- package/fjs/emergent_testing/scenarios/return-value.pass.js +0 -4
- package/fjs/emergent_testing/scenarios/thenable.pass.d.ts +0 -5
- package/fjs/emergent_testing/scenarios/thenable.pass.js +0 -11
- package/fjs/emergent_testing/scenarios/thenable2.pass.d.ts +0 -5
- package/fjs/emergent_testing/scenarios/thenable2.pass.js +0 -3
- package/fjs/emergent_testing/scenarios/throw.pass.d.ts +0 -5
- package/fjs/emergent_testing/scenarios/throw.pass.js +0 -3
- package/fjs/emergent_testing/types.js +0 -6
- package/fjs/js/tokenizer/types.js +0 -6
- package/fjs/media/html/types.js +0 -6
- package/fjs/media/json/parser/types.js +0 -6
- package/fjs/media/json/tokenizer/types.js +0 -6
- package/fjs/media/json/types.js +0 -13
- package/fjs/media/nix/types.js +0 -6
- package/fjs/media/revision/types.js +0 -8
- package/fjs/media/type/types.js +0 -6
- package/fjs/media/types.js +0 -7
- package/fjs/nanvm/types.js +0 -11
- package/fjs/protocol/json_rpc/types.js +0 -8
- package/fjs/protocol/mcp/types.js +0 -8
- package/fjs/sul/id/types.js +0 -6
- package/fjs/sul/level/hash/types.js +0 -6
- package/fjs/sul/level/literal/types.js +0 -6
- package/fjs/sul/types.js +0 -6
- package/fjs/text/sgr/types.js +0 -6
- package/fjs/text/types.js +0 -6
- package/fjs/text/utf16/types.js +0 -6
- package/fjs/text/utf8/types.js +0 -6
- package/fjs/types/array/types.js +0 -6
- package/fjs/types/bigfloat/types.js +0 -6
- package/fjs/types/bigint/types.js +0 -6
- package/fjs/types/bit_vec/types.js +0 -6
- package/fjs/types/btree/find/types.js +0 -6
- package/fjs/types/btree/types/types.js +0 -6
- package/fjs/types/byte_set/types.js +0 -6
- package/fjs/types/function/compare/types.js +0 -6
- package/fjs/types/function/operator/types.js +0 -6
- package/fjs/types/function/types.js +0 -6
- package/fjs/types/list/types.js +0 -6
- package/fjs/types/nibble_set/types.js +0 -6
- package/fjs/types/nominal/types.js +0 -6
- package/fjs/types/nullable/types.js +0 -6
- package/fjs/types/object/types.js +0 -8
- package/fjs/types/option/types.js +0 -6
- package/fjs/types/ordered_map/types.js +0 -6
- package/fjs/types/patricia_trie/types.js +0 -6
- package/fjs/types/phantom/types.js +0 -11
- package/fjs/types/prime_field/types.js +0 -6
- package/fjs/types/range/types.js +0 -6
- package/fjs/types/range_map/types.js +0 -6
- package/fjs/types/result/types.js +0 -6
- package/fjs/types/rtti/common/types.js +0 -1
- package/fjs/types/rtti/parse/types.js +0 -1
- package/fjs/types/rtti/ts/types.js +0 -1
- package/fjs/types/rtti/types.js +0 -1
- package/fjs/types/rtti/validate/module.f.d.mts +0 -6
- package/fjs/types/rtti/validate/module.f.mjs +0 -169
- package/fjs/types/rtti/validate/proof.f.d.mts +0 -125
- package/fjs/types/rtti/validate/proof.f.mjs +0 -437
- package/fjs/types/rtti/validate/types.d.ts +0 -6
- package/fjs/types/rtti/validate/types.js +0 -1
- package/fjs/types/sorted_list/types.js +0 -6
- package/fjs/types/sorted_set/types.js +0 -6
- package/fjs/types/string_set/types.js +0 -6
- package/fjs/types/ts/types.js +0 -8
|
@@ -1,30 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* JSON parser
|
|
2
|
+
* The shared structural JSON parser: one tokenizer, one container state
|
|
3
|
+
* machine, and a numeric policy per codec.
|
|
4
|
+
*
|
|
5
|
+
* The state machine builds objects and arrays; a number token is handed to the
|
|
6
|
+
* `NumberPolicy` the caller supplies, together with its exact lexeme. Numeric
|
|
7
|
+
* syntax therefore stays lossless all the way to the policy, and each codec
|
|
8
|
+
* chooses its own runtime numeric domain from the same parse:
|
|
9
|
+
*
|
|
10
|
+
* ```text
|
|
11
|
+
* JSON text -> tokenizer -> parse(policy) -+-> json.Unknown (number)
|
|
12
|
+
* +-> extended.Unknown (number | bigint)
|
|
13
|
+
* +-> another policy's domain
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* No codec has to materialize another codec's domain first: standard JSON
|
|
17
|
+
* parsing never needs an intermediate `bigint`, and extended parsing never
|
|
18
|
+
* needs an intermediate rounded `number`.
|
|
3
19
|
*
|
|
4
20
|
* @module
|
|
5
21
|
*
|
|
6
|
-
* @import { Unknown } from '../types.ts'
|
|
7
22
|
* @import { Result } from '../../../types/result/types.ts'
|
|
8
23
|
* @import { List } from '../../../types/list/types.ts'
|
|
9
24
|
* @import { Fold } from '../../../types/function/operator/types.ts'
|
|
10
25
|
* @import { JsonToken } from '../tokenizer/types.ts'
|
|
11
|
-
* @import { _JsonObject, _JsonArray, _StateParse, _JsonState, _JsonStack } from './types.ts'
|
|
26
|
+
* @import { NumberPolicy, ParseUnknown, _JsonObject, _JsonArray, _StateParse, _JsonState, _JsonStack, _ValueToken } from './types.ts'
|
|
12
27
|
*/
|
|
13
|
-
import type { Unknown } from '../types.ts';
|
|
14
28
|
import type { Result } from '../../../types/result/types.ts';
|
|
15
29
|
import type { List } from '../../../types/list/types.ts';
|
|
16
30
|
import type { JsonToken } from '../tokenizer/types.ts';
|
|
31
|
+
import type { NumberPolicy, ParseUnknown } from './types.ts';
|
|
17
32
|
/**
|
|
18
|
-
* Parses a list of JSON tokens into
|
|
33
|
+
* Parses a list of JSON tokens into the value domain `policy` materializes
|
|
34
|
+
* numbers into.
|
|
19
35
|
*
|
|
20
36
|
* Returns `ok` with the parsed value on success, or `error` with a message
|
|
21
|
-
* when the token sequence is invalid or incomplete
|
|
37
|
+
* when the token sequence is invalid or incomplete — or when `policy` rejects
|
|
38
|
+
* a number token that its domain cannot represent.
|
|
22
39
|
*
|
|
23
|
-
* @type {(tokenList: List<JsonToken>) => Result<
|
|
40
|
+
* @type {<P>(policy: NumberPolicy<P>) => (tokenList: List<JsonToken>) => Result<ParseUnknown<P>, string>}
|
|
24
41
|
*/
|
|
25
|
-
export declare const parse: (tokenList: List<JsonToken>) => Result<
|
|
26
|
-
export declare const proof: {
|
|
27
|
-
pushKey: {
|
|
28
|
-
nonObjectTop: () => void;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
42
|
+
export declare const parse: <P>(policy: NumberPolicy<P>) => (tokenList: List<JsonToken>) => Result<ParseUnknown<P>, string>;
|
|
@@ -1,48 +1,86 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* JSON parser
|
|
2
|
+
* The shared structural JSON parser: one tokenizer, one container state
|
|
3
|
+
* machine, and a numeric policy per codec.
|
|
4
|
+
*
|
|
5
|
+
* The state machine builds objects and arrays; a number token is handed to the
|
|
6
|
+
* `NumberPolicy` the caller supplies, together with its exact lexeme. Numeric
|
|
7
|
+
* syntax therefore stays lossless all the way to the policy, and each codec
|
|
8
|
+
* chooses its own runtime numeric domain from the same parse:
|
|
9
|
+
*
|
|
10
|
+
* ```text
|
|
11
|
+
* JSON text -> tokenizer -> parse(policy) -+-> json.Unknown (number)
|
|
12
|
+
* +-> extended.Unknown (number | bigint)
|
|
13
|
+
* +-> another policy's domain
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* No codec has to materialize another codec's domain first: standard JSON
|
|
17
|
+
* parsing never needs an intermediate `bigint`, and extended parsing never
|
|
18
|
+
* needs an intermediate rounded `number`.
|
|
3
19
|
*
|
|
4
20
|
* @module
|
|
5
21
|
*
|
|
6
|
-
* @import { Unknown } from '../types.ts'
|
|
7
22
|
* @import { Result } from '../../../types/result/types.ts'
|
|
8
23
|
* @import { List } from '../../../types/list/types.ts'
|
|
9
24
|
* @import { Fold } from '../../../types/function/operator/types.ts'
|
|
10
25
|
* @import { JsonToken } from '../tokenizer/types.ts'
|
|
11
|
-
* @import { _JsonObject, _JsonArray, _StateParse, _JsonState, _JsonStack } from './types.ts'
|
|
26
|
+
* @import { NumberPolicy, ParseUnknown, _JsonObject, _JsonArray, _StateParse, _JsonState, _JsonStack, _ValueToken } from './types.ts'
|
|
12
27
|
*/
|
|
13
28
|
|
|
29
|
+
import { assert } from '../../../asserts/module.f.mjs'
|
|
14
30
|
import { error, ok } from '../../../types/result/module.f.mjs'
|
|
15
31
|
import { fold, next, toArray, concat } from '../../../types/list/module.f.mjs'
|
|
16
32
|
import { setReplace } from '../../../types/ordered_map/module.f.mjs'
|
|
17
33
|
import { fromMap } from '../../../types/object/module.f.mjs'
|
|
18
|
-
import { assertEq } from '../../../asserts/module.f.mjs'
|
|
19
34
|
|
|
20
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Every syntax error the parser can report is the same one: a token that
|
|
37
|
+
* cannot follow the state it arrived in. It carries no position or metadata,
|
|
38
|
+
* so one shared value serves all of them — and no numeric policy either, so
|
|
39
|
+
* the same value serves every instantiation of the parser.
|
|
40
|
+
*
|
|
41
|
+
* @type {_JsonState<never>}
|
|
42
|
+
*/
|
|
43
|
+
const unexpectedToken = { status: 'error', message: 'unexpected token' }
|
|
44
|
+
|
|
45
|
+
/** @type {<P>(obj: _JsonObject<P>) => (key: string) => _JsonObject<P>} */
|
|
21
46
|
const addKeyToObject =
|
|
22
47
|
obj => key => ({ kind: 'object', values: obj.values, key: key })
|
|
23
48
|
|
|
24
|
-
/** @type {(obj: _JsonObject) => (value:
|
|
49
|
+
/** @type {<P>(obj: _JsonObject<P>) => (value: ParseUnknown<P>) => _JsonObject<P>} */
|
|
25
50
|
const addValueToObject =
|
|
26
51
|
obj => value => ({ kind: 'object', values: setReplace(obj.key)(value)(obj.values), key: '' })
|
|
27
52
|
|
|
28
|
-
/** @type {(array: _JsonArray) => (value:
|
|
53
|
+
/** @type {<P>(array: _JsonArray<P>) => (value: ParseUnknown<P>) => _JsonArray<P>} */
|
|
29
54
|
const addToArray =
|
|
30
55
|
array => value => ({ kind: 'array', values: concat(array.values)([value]) })
|
|
31
56
|
|
|
32
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* `pushKey` only ever runs while parsing the object `startObject` opened
|
|
59
|
+
* (status `'{'`/`'{,'`), so `state.top` is always that object here — the same
|
|
60
|
+
* construction guarantee `endArray` relies on below.
|
|
61
|
+
*
|
|
62
|
+
* @template P
|
|
63
|
+
* @param {_StateParse<P>} state
|
|
64
|
+
* @returns {(key: string) => _JsonState<P>}
|
|
65
|
+
*/
|
|
33
66
|
const pushKey = state => value => {
|
|
34
|
-
|
|
35
|
-
|
|
67
|
+
const { top } = state
|
|
68
|
+
assert(top !== null && top.kind === 'object', top)
|
|
69
|
+
return {
|
|
70
|
+
status: '{k',
|
|
71
|
+
top: addKeyToObject(top)(value),
|
|
72
|
+
stack: state.stack,
|
|
73
|
+
}
|
|
36
74
|
}
|
|
37
75
|
|
|
38
|
-
/** @type {(state: _StateParse) => (value:
|
|
76
|
+
/** @type {<P>(state: _StateParse<P>) => (value: ParseUnknown<P>) => _JsonState<P>} */
|
|
39
77
|
const pushValue = state => value => {
|
|
40
78
|
if (state.top === null) { return { status: 'result', value: value } }
|
|
41
79
|
if (state.top.kind === 'array') { return { status: '[v', top: addToArray(state.top)(value), stack: state.stack } }
|
|
42
80
|
return { status: '{v', top: addValueToObject(state.top)(value), stack: state.stack }
|
|
43
81
|
}
|
|
44
82
|
|
|
45
|
-
/** @type {(state: _StateParse) => _JsonState} */
|
|
83
|
+
/** @type {<P>(state: _StateParse<P>) => _JsonState<P>} */
|
|
46
84
|
const startArray = state => {
|
|
47
85
|
const newStack = state.top === null ? null : { first: state.top, tail: state.stack }
|
|
48
86
|
return { status: '[', top: { kind: 'array', values: null }, stack: newStack }
|
|
@@ -54,7 +92,7 @@ const startArray = state => {
|
|
|
54
92
|
* always as a literal cons, and a lazy pop would leave one unforced thunk per
|
|
55
93
|
* closed container — a chain that overflows the stack when it is finally forced.
|
|
56
94
|
*
|
|
57
|
-
* @type {(stack: _JsonStack) => _StateParse}
|
|
95
|
+
* @type {<P>(stack: _JsonStack<P>) => _StateParse<P>}
|
|
58
96
|
*/
|
|
59
97
|
const popStack = stack => {
|
|
60
98
|
const ne = next(stack)
|
|
@@ -63,39 +101,72 @@ const popStack = stack => {
|
|
|
63
101
|
: { status: '', top: ne.first, stack: ne.tail }
|
|
64
102
|
}
|
|
65
103
|
|
|
66
|
-
/**
|
|
104
|
+
/**
|
|
105
|
+
* `endArray` only ever runs while parsing the array `startArray` opened
|
|
106
|
+
* (status `'['`/`'[v'`), so `state.top` is always that array here.
|
|
107
|
+
*
|
|
108
|
+
* @template P
|
|
109
|
+
* @param {_StateParse<P>} state
|
|
110
|
+
* @returns {_JsonState<P>}
|
|
111
|
+
*/
|
|
67
112
|
const endArray = state => {
|
|
68
|
-
const
|
|
113
|
+
const { top } = state
|
|
114
|
+
assert(top !== null && top.kind === 'array', top)
|
|
115
|
+
const array = toArray(top.values)
|
|
69
116
|
const newState = popStack(state.stack)
|
|
70
117
|
return pushValue(newState)(array)
|
|
71
118
|
}
|
|
72
119
|
|
|
73
|
-
/** @type {(state: _StateParse) => _JsonState} */
|
|
120
|
+
/** @type {<P>(state: _StateParse<P>) => _JsonState<P>} */
|
|
74
121
|
const startObject = state => {
|
|
75
122
|
const newStack = state.top === null ? null : { first: state.top, tail: state.stack }
|
|
76
123
|
return { status: '{', top: { kind: 'object', values: null, key: '' }, stack: newStack }
|
|
77
124
|
}
|
|
78
125
|
|
|
79
|
-
/**
|
|
126
|
+
/**
|
|
127
|
+
* `endObject` only ever runs while parsing the object `startObject` opened
|
|
128
|
+
* (status `'{'`/`'{v'`), so `state.top` is always that object here.
|
|
129
|
+
*
|
|
130
|
+
* @template P
|
|
131
|
+
* @param {_StateParse<P>} state
|
|
132
|
+
* @returns {_JsonState<P>}
|
|
133
|
+
*/
|
|
80
134
|
const endObject = state => {
|
|
81
|
-
const
|
|
135
|
+
const { top } = state
|
|
136
|
+
assert(top !== null && top.kind === 'object', top)
|
|
137
|
+
const obj = fromMap(top.values)
|
|
82
138
|
const newState = popStack(state.stack)
|
|
83
139
|
return pushValue(newState)(obj)
|
|
84
140
|
}
|
|
85
141
|
|
|
86
|
-
/**
|
|
87
|
-
|
|
142
|
+
/**
|
|
143
|
+
* Only ever called on a token `isValueToken` has already confirmed carries a
|
|
144
|
+
* value, so the switch covers every `_ValueToken` case with no fallback arm.
|
|
145
|
+
* A number is the one leaf the parser does not know how to build: `policy`
|
|
146
|
+
* owns that decision and may reject the token.
|
|
147
|
+
*
|
|
148
|
+
* @type {<P>(policy: NumberPolicy<P>) => (token: _ValueToken) => Result<ParseUnknown<P>, string>}
|
|
149
|
+
*/
|
|
150
|
+
const tokenToValue = policy => token => {
|
|
88
151
|
switch (token.kind) {
|
|
89
|
-
case 'null': return null
|
|
90
|
-
case 'false': return false
|
|
91
|
-
case 'true': return true
|
|
92
|
-
case 'number': return
|
|
93
|
-
case 'string': return token.value
|
|
94
|
-
default: return null
|
|
152
|
+
case 'null': return ok(null)
|
|
153
|
+
case 'false': return ok(false)
|
|
154
|
+
case 'true': return ok(true)
|
|
155
|
+
case 'number': return policy(token)
|
|
156
|
+
case 'string': return ok(token.value)
|
|
95
157
|
}
|
|
96
158
|
}
|
|
97
159
|
|
|
98
|
-
/** @type {(token:
|
|
160
|
+
/** @type {<P>(policy: NumberPolicy<P>) => (state: _StateParse<P>) => (token: _ValueToken) => _JsonState<P>} */
|
|
161
|
+
const pushLeaf = policy => state => token => {
|
|
162
|
+
const [kind, value] = tokenToValue(policy)(token)
|
|
163
|
+
return kind === 'error' ? { status: 'error', message: value } : pushValue(state)(value)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* @param {JsonToken} token
|
|
168
|
+
* @returns {token is _ValueToken}
|
|
169
|
+
*/
|
|
99
170
|
const isValueToken = token => {
|
|
100
171
|
switch (token.kind) {
|
|
101
172
|
case 'null':
|
|
@@ -107,95 +178,99 @@ const isValueToken = token => {
|
|
|
107
178
|
}
|
|
108
179
|
}
|
|
109
180
|
|
|
110
|
-
/** @type {(token: JsonToken) => (state: _StateParse) => _JsonState} */
|
|
111
|
-
const parseValueOp = token => state => {
|
|
181
|
+
/** @type {<P>(policy: NumberPolicy<P>) => (token: JsonToken) => (state: _StateParse<P>) => _JsonState<P>} */
|
|
182
|
+
const parseValueOp = policy => token => state => {
|
|
112
183
|
switch (token.kind) {
|
|
113
184
|
// A value is required here (top level, after `[`+`,`, or after `:`),
|
|
114
185
|
// so `]` is never valid — strict JSON has no trailing commas.
|
|
115
186
|
case ']':
|
|
116
|
-
return
|
|
187
|
+
return unexpectedToken
|
|
117
188
|
case '[': return startArray(state)
|
|
118
189
|
case '{': return startObject(state)
|
|
119
190
|
default:
|
|
120
|
-
if (isValueToken(token)) { return
|
|
121
|
-
return
|
|
191
|
+
if (isValueToken(token)) { return pushLeaf(policy)(state)(token) }
|
|
192
|
+
return unexpectedToken
|
|
122
193
|
}
|
|
123
194
|
}
|
|
124
195
|
|
|
125
|
-
/** @type {(token: JsonToken) => (state: _StateParse) => _JsonState} */
|
|
126
|
-
const parseArrayStartOp = token => state => {
|
|
127
|
-
if (isValueToken(token)) { return
|
|
196
|
+
/** @type {<P>(policy: NumberPolicy<P>) => (token: JsonToken) => (state: _StateParse<P>) => _JsonState<P>} */
|
|
197
|
+
const parseArrayStartOp = policy => token => state => {
|
|
198
|
+
if (isValueToken(token)) { return pushLeaf(policy)(state)(token) }
|
|
128
199
|
if (token.kind === '[') { return startArray(state) }
|
|
129
200
|
if (token.kind === ']') { return endArray(state) }
|
|
130
201
|
if (token.kind === '{') { return startObject(state) }
|
|
131
|
-
return
|
|
202
|
+
return unexpectedToken
|
|
132
203
|
}
|
|
133
204
|
|
|
134
|
-
/** @type {(token: JsonToken) => (state: _StateParse) => _JsonState} */
|
|
205
|
+
/** @type {<P>(token: JsonToken) => (state: _StateParse<P>) => _JsonState<P>} */
|
|
135
206
|
const parseArrayValueOp = token => state => {
|
|
136
207
|
if (token.kind === ']') { return endArray(state) }
|
|
137
208
|
if (token.kind === ',') { return { status: '[,', top: state.top, stack: state.stack } }
|
|
138
|
-
return
|
|
209
|
+
return unexpectedToken
|
|
139
210
|
}
|
|
140
211
|
|
|
141
|
-
/** @type {(token: JsonToken) => (state: _StateParse) => _JsonState} */
|
|
212
|
+
/** @type {<P>(token: JsonToken) => (state: _StateParse<P>) => _JsonState<P>} */
|
|
142
213
|
const parseObjectStartOp = token => state => {
|
|
143
214
|
if (token.kind === 'string') { return pushKey(state)(token.value) }
|
|
144
215
|
if (token.kind === '}') { return endObject(state) }
|
|
145
|
-
return
|
|
216
|
+
return unexpectedToken
|
|
146
217
|
}
|
|
147
218
|
|
|
148
|
-
/** @type {(token: JsonToken) => (state: _StateParse) => _JsonState} */
|
|
219
|
+
/** @type {<P>(token: JsonToken) => (state: _StateParse<P>) => _JsonState<P>} */
|
|
149
220
|
const parseObjectKeyOp = token => state => {
|
|
150
221
|
if (token.kind === ':') { return { status: '{:', top: state.top, stack: state.stack } }
|
|
151
|
-
return
|
|
222
|
+
return unexpectedToken
|
|
152
223
|
}
|
|
153
224
|
|
|
154
|
-
/** @type {(token: JsonToken) => (state: _StateParse) => _JsonState} */
|
|
225
|
+
/** @type {<P>(token: JsonToken) => (state: _StateParse<P>) => _JsonState<P>} */
|
|
155
226
|
const parseObjectNextOp = token => state => {
|
|
156
227
|
if (token.kind === '}') { return endObject(state) }
|
|
157
228
|
if (token.kind === ',') { return { status: '{,', top: state.top, stack: state.stack } }
|
|
158
|
-
return
|
|
229
|
+
return unexpectedToken
|
|
159
230
|
}
|
|
160
231
|
|
|
161
|
-
/** @type {(token: JsonToken) => (state: _StateParse) => _JsonState} */
|
|
232
|
+
/** @type {<P>(token: JsonToken) => (state: _StateParse<P>) => _JsonState<P>} */
|
|
162
233
|
const parseObjectCommaOp = token => state => {
|
|
163
234
|
// After a `,` a member (string key) is required — `}` here would be a
|
|
164
235
|
// trailing comma, which strict JSON rejects.
|
|
165
236
|
if (token.kind === 'string') { return pushKey(state)(token.value) }
|
|
166
|
-
return
|
|
237
|
+
return unexpectedToken
|
|
167
238
|
}
|
|
168
239
|
|
|
169
|
-
/** @type {Fold<JsonToken, _JsonState
|
|
170
|
-
const foldOp = token => state => {
|
|
240
|
+
/** @type {<P>(policy: NumberPolicy<P>) => Fold<JsonToken, _JsonState<P>>} */
|
|
241
|
+
const foldOp = policy => token => state => {
|
|
171
242
|
if (token.kind === 'eof')
|
|
172
243
|
return state
|
|
173
244
|
|
|
174
245
|
switch (state.status) {
|
|
175
|
-
case 'result': return
|
|
246
|
+
case 'result': return unexpectedToken
|
|
176
247
|
case 'error': return { status: 'error', message: state.message }
|
|
177
|
-
case '': return parseValueOp(token)(state)
|
|
178
|
-
case '[': return parseArrayStartOp(token)(state)
|
|
248
|
+
case '': return parseValueOp(policy)(token)(state)
|
|
249
|
+
case '[': return parseArrayStartOp(policy)(token)(state)
|
|
179
250
|
case '[v': return parseArrayValueOp(token)(state)
|
|
180
|
-
case '[,': return parseValueOp(token)(state)
|
|
251
|
+
case '[,': return parseValueOp(policy)(token)(state)
|
|
181
252
|
case '{': return parseObjectStartOp(token)(state)
|
|
182
253
|
case '{k': return parseObjectKeyOp(token)(state)
|
|
183
|
-
case '{:': return parseValueOp(token)(state)
|
|
254
|
+
case '{:': return parseValueOp(policy)(token)(state)
|
|
184
255
|
case '{v': return parseObjectNextOp(token)(state)
|
|
185
256
|
case '{,': return parseObjectCommaOp(token)(state)
|
|
186
257
|
}
|
|
187
258
|
}
|
|
188
259
|
|
|
189
260
|
/**
|
|
190
|
-
* Parses a list of JSON tokens into
|
|
261
|
+
* Parses a list of JSON tokens into the value domain `policy` materializes
|
|
262
|
+
* numbers into.
|
|
191
263
|
*
|
|
192
264
|
* Returns `ok` with the parsed value on success, or `error` with a message
|
|
193
|
-
* when the token sequence is invalid or incomplete
|
|
265
|
+
* when the token sequence is invalid or incomplete — or when `policy` rejects
|
|
266
|
+
* a number token that its domain cannot represent.
|
|
194
267
|
*
|
|
195
|
-
* @type {(tokenList: List<JsonToken>) => Result<
|
|
268
|
+
* @type {<P>(policy: NumberPolicy<P>) => (tokenList: List<JsonToken>) => Result<ParseUnknown<P>, string>}
|
|
196
269
|
*/
|
|
197
|
-
export const parse = tokenList => {
|
|
198
|
-
|
|
270
|
+
export const parse = policy => tokenList => {
|
|
271
|
+
/** @type {_JsonState<never>} */
|
|
272
|
+
const init = { status: '', top: null, stack: null }
|
|
273
|
+
const state = fold(foldOp(policy))(init)(tokenList)
|
|
199
274
|
switch (state.status) {
|
|
200
275
|
case 'result': return ok(state.value)
|
|
201
276
|
case 'error': return error(state.message)
|
|
@@ -203,17 +278,3 @@ export const parse = tokenList => {
|
|
|
203
278
|
}
|
|
204
279
|
}
|
|
205
280
|
|
|
206
|
-
export const proof = {
|
|
207
|
-
pushKey: {
|
|
208
|
-
// `pushKey` is only ever invoked while `state.top` is an object (the
|
|
209
|
-
// state machine's `'{'`/`'{,'` statuses guarantee it), so its
|
|
210
|
-
// non-object guard is a defensive branch unreachable through `parse`.
|
|
211
|
-
// Call it directly to cover that branch.
|
|
212
|
-
nonObjectTop: () => {
|
|
213
|
-
/** @type {_StateParse} */
|
|
214
|
-
const state = { status: '[', top: { kind: 'array', values: null }, stack: null }
|
|
215
|
-
const result = pushKey(state)('key')
|
|
216
|
-
assertEq(result.status, 'error')
|
|
217
|
-
},
|
|
218
|
-
},
|
|
219
|
-
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @import { JsonToken } from '../tokenizer/types.ts'
|
|
3
|
+
* @import { NumberPolicy } from './types.ts'
|
|
3
4
|
*/
|
|
4
5
|
export declare const proof: {
|
|
5
6
|
valid: (() => void)[];
|
|
6
7
|
invalid: (() => void)[];
|
|
7
8
|
siblingContainers: (() => void)[];
|
|
9
|
+
policy: {
|
|
10
|
+
exactLexeme: () => void;
|
|
11
|
+
rejected: () => void;
|
|
12
|
+
};
|
|
8
13
|
};
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @import { JsonToken } from '../tokenizer/types.ts'
|
|
3
|
+
* @import { NumberPolicy } from './types.ts'
|
|
3
4
|
*/
|
|
4
5
|
|
|
5
|
-
import { parse } from './module.f.mjs'
|
|
6
|
+
import { parse as parseWithPolicy } from './module.f.mjs'
|
|
6
7
|
import { tokenize } from '../tokenizer/module.f.mjs'
|
|
7
8
|
import { toArray } from '../../../types/list/module.f.mjs'
|
|
8
9
|
import { stringify as jsonStringify } from '../module.f.mjs'
|
|
9
10
|
import { sort } from '../../../types/object/module.f.mjs'
|
|
10
11
|
import { stringToList } from '../../../text/utf16/module.f.mjs'
|
|
12
|
+
import { error, ok } from '../../../types/result/module.f.mjs'
|
|
11
13
|
import { assertEq } from '../../../asserts/module.f.mjs'
|
|
12
14
|
|
|
13
15
|
/** @type {(s: string) => readonly JsonToken[]} */
|
|
14
16
|
const tokenizeString = s => toArray(tokenize(stringToList(s)))
|
|
15
17
|
|
|
18
|
+
/** The structural machine is proved through the ordinary `number` policy. */
|
|
19
|
+
/** @type {NumberPolicy<number>} */
|
|
20
|
+
const numberPolicy = token => ok(parseFloat(token.value))
|
|
21
|
+
|
|
22
|
+
const parse = parseWithPolicy(numberPolicy)
|
|
23
|
+
|
|
16
24
|
const stringify = jsonStringify(sort)
|
|
17
25
|
|
|
18
26
|
export const proof = {
|
|
@@ -311,4 +319,26 @@ export const proof = {
|
|
|
311
319
|
assertEq(Array.isArray(value) ? value.length : -1, 12000)
|
|
312
320
|
},
|
|
313
321
|
],
|
|
322
|
+
// The numeric policy is the parser's only opinion about numbers: it is
|
|
323
|
+
// handed the token, so it reads the exact lexeme, and it may reject one.
|
|
324
|
+
policy: {
|
|
325
|
+
// the lexeme reaches the policy unrounded — `1.0`, `1e0` and `1` are
|
|
326
|
+
// one `number` but three tokens
|
|
327
|
+
exactLexeme: () => {
|
|
328
|
+
/** @type {NumberPolicy<string>} */
|
|
329
|
+
const lexemePolicy = token => ok(token.value)
|
|
330
|
+
const [tag, value] = parseWithPolicy(lexemePolicy)(tokenizeString('[1.0,1e0,1,-0]'))
|
|
331
|
+
assertEq(tag, 'ok')
|
|
332
|
+
assertEq(stringify(value), '["1.0","1e0","1","-0"]')
|
|
333
|
+
},
|
|
334
|
+
// a policy that cannot represent the number fails the parse as an
|
|
335
|
+
// ordinary `Result`, with its own message
|
|
336
|
+
rejected: () => {
|
|
337
|
+
/** @type {NumberPolicy<never>} */
|
|
338
|
+
const rejectPolicy = () => error('no numbers here')
|
|
339
|
+
const [tag, message] = parseWithPolicy(rejectPolicy)(tokenizeString('{"a":[1]}'))
|
|
340
|
+
assertEq(tag, 'error')
|
|
341
|
+
assertEq(message, 'no numbers here')
|
|
342
|
+
},
|
|
343
|
+
},
|
|
314
344
|
}
|
|
@@ -1,34 +1,58 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Types for the shared structural JSON parser: its numeric policy, the tree
|
|
3
|
+
* that policy produces, and the parser's internal state.
|
|
3
4
|
*
|
|
4
5
|
* @module
|
|
5
6
|
*/
|
|
6
|
-
import type {
|
|
7
|
+
import type { Tree } from '../types.ts';
|
|
7
8
|
import type { OrderedMap } from '../../../types/ordered_map/types.ts';
|
|
8
9
|
import type { List } from '../../../types/list/types.ts';
|
|
9
|
-
|
|
10
|
+
import type { Result } from '../../../types/result/types.ts';
|
|
11
|
+
import type { JsonToken } from '../tokenizer/types.ts';
|
|
12
|
+
import type { NumberToken } from '../../../js/tokenizer/types.ts';
|
|
13
|
+
/** JSON tokens that carry a directly-usable value. */
|
|
14
|
+
export type _ValueToken = Extract<JsonToken, {
|
|
15
|
+
readonly kind: 'null' | 'false' | 'true' | 'string' | 'number';
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* A numeric policy: how one codec materializes a JSON number token into its
|
|
19
|
+
* own numeric domain `P`.
|
|
20
|
+
*
|
|
21
|
+
* The policy is handed the token itself, so it decides from the exact lexeme —
|
|
22
|
+
* before any narrowing the parser might otherwise have imposed. It may fail:
|
|
23
|
+
* a valid JSON number can be outside the domain the codec offers (the extended
|
|
24
|
+
* codec has no non-finite `number`), and that has to be an ordinary parse
|
|
25
|
+
* error rather than an escaping runtime exception.
|
|
26
|
+
*/
|
|
27
|
+
export type NumberPolicy<P> = (token: NumberToken) => Result<P, string>;
|
|
28
|
+
/**
|
|
29
|
+
* The tree a numeric policy `P` parses into: JSON's containers over `P` plus
|
|
30
|
+
* the primitives every policy shares.
|
|
31
|
+
*/
|
|
32
|
+
export type ParseUnknown<P> = Tree<P | null | boolean | string>;
|
|
33
|
+
export type _JsonObject<P> = {
|
|
10
34
|
readonly kind: 'object';
|
|
11
|
-
readonly values: OrderedMap<
|
|
35
|
+
readonly values: OrderedMap<ParseUnknown<P>>;
|
|
12
36
|
readonly key: string;
|
|
13
37
|
};
|
|
14
|
-
export type _JsonArray = {
|
|
38
|
+
export type _JsonArray<P> = {
|
|
15
39
|
readonly kind: 'array';
|
|
16
|
-
readonly values: List<
|
|
40
|
+
readonly values: List<ParseUnknown<P>>;
|
|
17
41
|
};
|
|
18
|
-
type _JsonStackElement = _JsonObject | _JsonArray
|
|
19
|
-
export type _JsonStack = List<_JsonStackElement
|
|
20
|
-
export type _StateParse = {
|
|
42
|
+
type _JsonStackElement<P> = _JsonObject<P> | _JsonArray<P>;
|
|
43
|
+
export type _JsonStack<P> = List<_JsonStackElement<P>>;
|
|
44
|
+
export type _StateParse<P> = {
|
|
21
45
|
readonly status: '' | '[' | '[v' | '[,' | '{' | '{k' | '{:' | '{v' | '{,';
|
|
22
|
-
readonly top: _JsonStackElement | null;
|
|
23
|
-
readonly stack: _JsonStack
|
|
46
|
+
readonly top: _JsonStackElement<P> | null;
|
|
47
|
+
readonly stack: _JsonStack<P>;
|
|
24
48
|
};
|
|
25
|
-
type _StateResult = {
|
|
49
|
+
type _StateResult<P> = {
|
|
26
50
|
readonly status: 'result';
|
|
27
|
-
readonly value:
|
|
51
|
+
readonly value: ParseUnknown<P>;
|
|
28
52
|
};
|
|
29
53
|
type _StateError = {
|
|
30
54
|
readonly status: 'error';
|
|
31
55
|
readonly message: string;
|
|
32
56
|
};
|
|
33
|
-
export type _JsonState = _StateParse | _StateResult | _StateError;
|
|
57
|
+
export type _JsonState<P> = _StateParse<P> | _StateResult<P> | _StateError;
|
|
34
58
|
export {};
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* `typeof`. That spelling is deliberate: `@type {const}` also type-checks here,
|
|
9
9
|
* but leaves declaration emit no name for the recursive positions, so it
|
|
10
10
|
* inlines the structure, gives up at depth, and degrades the emitted `.d.mts`
|
|
11
|
-
* to `any`. See AGENTS.md §
|
|
11
|
+
* to `any`. See `fjs/AGENTS.md` §3.2.
|
|
12
12
|
*
|
|
13
13
|
* The TypeScript counterparts live in the sibling
|
|
14
14
|
* [`../types.ts`](../types.ts), which pins them against these schemas with
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* `typeof`. That spelling is deliberate: `@type {const}` also type-checks here,
|
|
9
9
|
* but leaves declaration emit no name for the recursive positions, so it
|
|
10
10
|
* inlines the structure, gives up at depth, and degrades the emitted `.d.mts`
|
|
11
|
-
* to `any`. See AGENTS.md §
|
|
11
|
+
* to `any`. See `fjs/AGENTS.md` §3.2.
|
|
12
12
|
*
|
|
13
13
|
* The TypeScript counterparts live in the sibling
|
|
14
14
|
* [`../types.ts`](../types.ts), which pins them against these schemas with
|
|
@@ -2,26 +2,26 @@
|
|
|
2
2
|
* Proof for the JSON rtti schemas.
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
|
+
*
|
|
6
|
+
* @import { ValidateE } from '../../../types/rtti/common/types.ts'
|
|
7
|
+
* @import { Unknown } from '../../../types/rtti/ts/types.ts'
|
|
5
8
|
*/
|
|
6
9
|
|
|
7
10
|
import { assertEq } from '../../../asserts/module.f.mjs'
|
|
8
|
-
import {
|
|
11
|
+
import { parse } from '../../../types/rtti/parse/module.f.mjs'
|
|
9
12
|
import { primitive, unknown, object, array } from './module.f.mjs'
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
//
|
|
15
|
-
// accepted, not about the payload, which validation returns unchanged. The
|
|
16
|
-
// erased `ValidateE` keeps the shared helper from re-instantiating each
|
|
17
|
-
// schema's deep recursive result type (TS2589).
|
|
14
|
+
// Reduces a parse to its `ok`/`error` tag: these schemas are about what is
|
|
15
|
+
// accepted, not about the payload `parse` rebuilds. The erased `ValidateE`
|
|
16
|
+
// keeps the shared helper from re-instantiating each schema's deep recursive
|
|
17
|
+
// result type (TS2589).
|
|
18
18
|
/** @type {(v: ValidateE) => (value: Unknown) => string} */
|
|
19
19
|
const tag = v => value => v(value)[0]
|
|
20
20
|
|
|
21
|
-
const primitiveAccepts = tag(
|
|
22
|
-
const unknownAccepts = tag(
|
|
23
|
-
const objectAccepts = tag(
|
|
24
|
-
const arrayAccepts = tag(
|
|
21
|
+
const primitiveAccepts = tag(parse(primitive))
|
|
22
|
+
const unknownAccepts = tag(parse(unknown))
|
|
23
|
+
const objectAccepts = tag(parse(object))
|
|
24
|
+
const arrayAccepts = tag(parse(array))
|
|
25
25
|
|
|
26
26
|
export const proof = {
|
|
27
27
|
primitive: {
|