functionalscript 0.37.0 → 0.39.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 +1 -1
- package/{fs → fjs}/asn.1/proof.f.js +32 -94
- package/fjs/asserts/module.f.d.ts +36 -0
- package/fjs/asserts/module.f.js +39 -0
- package/fjs/asserts/proof.f.d.ts +11 -0
- package/fjs/asserts/proof.f.js +18 -0
- package/{fs → fjs}/base_n/proof.f.js +12 -36
- package/{fs → fjs}/basen/base64/proof.f.d.ts +1 -0
- package/{fs → fjs}/basen/base64/proof.f.js +15 -1
- package/{fs → fjs}/basen/cbase32/proof.f.js +15 -42
- package/fjs/bnf/data/module.f.d.ts +52 -0
- package/{fs → fjs}/bnf/data/module.f.js +53 -3
- package/{fs → fjs}/bnf/data/proof.f.d.ts +1 -0
- package/{fs → fjs}/bnf/data/proof.f.js +54 -19
- package/{fs → fjs}/bnf/descent/module.f.d.ts +4 -14
- package/fjs/bnf/descent/module.f.js +124 -0
- package/{fs → fjs}/bnf/descent/proof.f.d.ts +1 -0
- package/{fs → fjs}/bnf/descent/proof.f.js +55 -24
- package/{fs → fjs}/bnf/ll1/module.f.d.ts +4 -4
- package/{fs → fjs}/bnf/ll1/module.f.js +7 -5
- package/{fs → fjs}/bnf/ll1/proof.f.d.ts +1 -0
- package/{fs → fjs}/bnf/ll1/proof.f.js +27 -10
- package/{fs → fjs}/bnf/module.f.d.ts +19 -5
- package/{fs → fjs}/bnf/module.f.js +10 -11
- package/fjs/bnf/proof.f.js +69 -0
- package/{fs → fjs}/bnf/testlib.f.js +2 -2
- package/fjs/bnf/token_symbol/module.f.d.ts +38 -0
- package/fjs/bnf/token_symbol/module.f.js +48 -0
- package/fjs/bnf/token_symbol/proof.f.d.ts +10 -0
- package/fjs/bnf/token_symbol/proof.f.js +37 -0
- package/{fs → fjs}/cas/cli/module.f.js +6 -9
- package/{fs → fjs}/cas/cli/proof.f.d.ts +4 -1
- package/{fs → fjs}/cas/cli/proof.f.js +29 -66
- package/fjs/cas/evo/mcp/module.f.d.ts +27 -0
- package/fjs/cas/evo/mcp/module.f.js +94 -0
- package/fjs/cas/evo/mcp/proof.f.d.ts +11 -0
- package/fjs/cas/evo/mcp/proof.f.js +126 -0
- package/fjs/cas/evo/module.f.d.ts +202 -0
- package/fjs/cas/evo/module.f.js +421 -0
- package/fjs/cas/evo/proof.f.d.ts +39 -0
- package/fjs/cas/evo/proof.f.js +572 -0
- package/fjs/cas/mcp/module.f.d.ts +49 -0
- package/{fs → fjs}/cas/mcp/module.f.js +61 -81
- package/{fs → fjs}/cas/mcp/proof.f.d.ts +4 -1
- package/{fs → fjs}/cas/mcp/proof.f.js +45 -17
- package/{fs → fjs}/cas/module.f.d.ts +10 -0
- package/{fs → fjs}/cas/module.f.js +89 -36
- package/fjs/cas/proof.f.d.ts +18 -0
- package/fjs/cas/proof.f.js +305 -0
- package/{fs → fjs}/ci/bun/module.f.js +3 -3
- package/{fs → fjs}/ci/common/module.f.d.ts +1 -2
- package/{fs → fjs}/ci/common/module.f.js +1 -5
- package/{fs → fjs}/ci/config/module.f.d.ts +8 -8
- package/{fs → fjs}/ci/config/module.f.js +8 -8
- package/{fs → fjs}/ci/deno/module.f.js +3 -3
- package/{fs → fjs}/ci/module.f.js +3 -4
- package/{fs → fjs}/ci/node/module.f.js +11 -9
- package/{fs → fjs}/ci/proof.f.js +16 -9
- package/{fs → fjs}/ci/rust/module.f.js +9 -1
- package/{fs → fjs}/cli/module.f.js +2 -2
- package/{fs → fjs}/cli/proof.f.js +22 -63
- package/{fs → fjs}/common/monoid/module.f.d.ts +46 -2
- package/fjs/common/monoid/module.f.js +88 -0
- package/fjs/common/monoid/proof.f.d.ts +9 -0
- package/fjs/common/monoid/proof.f.js +48 -0
- package/{fs → fjs}/crypto/hmac/proof.f.js +4 -12
- package/fjs/crypto/pow/proof.f.js +111 -0
- package/{fs → fjs}/crypto/secp/proof.f.js +12 -33
- package/{fs → fjs}/crypto/sha2/proof.f.js +18 -49
- package/{fs → fjs}/crypto/sign/module.f.d.ts +0 -5
- package/{fs → fjs}/crypto/sign/module.f.js +7 -4
- package/{fs → fjs}/crypto/sign/proof.f.js +36 -105
- package/{fs → fjs}/crypto/vdf/proof.f.js +22 -63
- package/{fs → fjs}/dev/module.f.js +25 -25
- package/{fs → fjs}/dev/package_json/proof.f.js +7 -7
- package/{fs → fjs}/dev/proof.f.js +2 -4
- package/{fs → fjs}/djs/ast/proof.f.js +4 -12
- package/{fs → fjs}/djs/module.f.js +5 -8
- package/{fs → fjs}/djs/parser/module.f.d.ts +8 -0
- package/{fs → fjs}/djs/parser/module.f.js +37 -0
- package/{fs → fjs}/djs/parser/proof.f.js +138 -400
- package/{fs → fjs}/djs/proof.f.js +13 -36
- package/{fs → fjs}/djs/serializer/proof.f.js +14 -39
- package/fjs/djs/tokenizer/module.f.d.ts +24 -0
- package/fjs/djs/tokenizer/module.f.js +472 -0
- package/{fs/djs/tokenizer-new → fjs/djs/tokenizer}/proof.f.d.ts +4 -3
- package/{fs/djs/tokenizer-new → fjs/djs/tokenizer}/proof.f.js +446 -445
- package/{fs → fjs}/djs/transpiler/module.f.js +6 -6
- package/{fs → fjs}/djs/transpiler/proof.f.d.ts +3 -0
- package/{fs → fjs}/djs/transpiler/proof.f.js +29 -30
- package/fjs/effects/eff/module.f.d.ts +72 -0
- package/fjs/effects/eff/module.f.js +46 -0
- package/fjs/effects/eff/proof.f.d.ts +11 -0
- package/fjs/effects/eff/proof.f.js +58 -0
- package/{fs → fjs}/effects/list/module.f.d.ts +11 -5
- package/{fs → fjs}/effects/list/module.f.js +2 -1
- package/{fs → fjs}/effects/memory/proof.f.js +15 -29
- package/fjs/effects/module.f.d.ts +388 -0
- package/fjs/effects/module.f.js +288 -0
- package/{fs → fjs}/effects/node/memory/proof.js +7 -13
- package/{fs → fjs}/effects/node/module.d.ts +1 -1
- package/{fs → fjs}/effects/node/module.f.d.ts +2 -2
- package/{fs → fjs}/effects/node/module.f.js +9 -11
- package/{fs → fjs}/effects/node/module.js +3 -3
- package/{fs → fjs}/effects/node/proof.f.d.ts +1 -0
- package/{fs → fjs}/effects/node/proof.f.js +121 -299
- package/{fs → fjs}/effects/node/virtual/proof.f.d.ts +1 -0
- package/{fs → fjs}/effects/node/virtual/proof.f.js +36 -29
- package/fjs/effects/proof.f.d.ts +51 -0
- package/fjs/effects/proof.f.js +178 -0
- package/{fs → fjs}/emergent_testing/module.f.js +55 -39
- package/{fs → fjs}/emergent_testing/proof.f.d.ts +4 -0
- package/{fs → fjs}/emergent_testing/proof.f.js +60 -27
- package/{fs → fjs}/fsc/proof.f.js +12 -34
- package/{fs → fjs}/fsm/proof.f.js +5 -12
- package/{fs → fjs}/mcp/module.f.d.ts +7 -0
- package/{fs → fjs}/mcp/module.f.js +17 -10
- package/{fs → fjs}/mcp/proof.f.js +17 -16
- package/{fs → fjs}/mcp/stdio/module.f.d.ts +4 -4
- package/{fs → fjs}/mcp/stdio/module.f.js +14 -14
- package/{fs → fjs}/media/html/proof.f.js +12 -33
- package/{fs → fjs}/media/json/parser/module.f.d.ts +5 -0
- package/{fs → fjs}/media/json/parser/module.f.js +14 -0
- package/{fs → fjs}/media/json/parser/proof.f.js +39 -114
- package/{fs → fjs}/media/json/rpc/module.f.js +1 -1
- package/{fs → fjs}/media/json/schema/module.f.d.ts +2 -2
- package/{fs → fjs}/media/json/schema/module.f.js +23 -39
- package/{fs → fjs}/media/json/schema/proof.f.js +3 -6
- package/{fs → fjs}/media/json/serializer/proof.f.js +10 -27
- package/{fs → fjs}/media/module.f.d.ts +6 -6
- package/{fs → fjs}/media/module.f.js +3 -4
- package/{fs → fjs}/media/proof.f.js +5 -4
- package/{fs → fjs}/media/revision/module.f.d.ts +31 -4
- package/{fs → fjs}/media/revision/module.f.js +35 -23
- package/{fs → fjs}/media/revision/proof.f.d.ts +10 -8
- package/fjs/media/revision/proof.f.js +140 -0
- package/{fs → fjs}/media/type/module.f.js +2 -2
- package/{fs → fjs}/media/type/proof.f.js +8 -15
- package/{fs → fjs}/module.f.js +5 -9
- package/{fs → fjs}/path/proof.f.js +27 -78
- package/{fs → fjs}/proof.f.js +2 -0
- package/{fs → fjs}/sul/id/proof.f.js +7 -21
- package/{fs → fjs}/sul/level/hash/proof.f.js +5 -5
- package/{fs → fjs}/sul/level/literal/proof.f.js +12 -26
- package/fjs/text/ascii/proof.f.d.ts +6 -0
- package/{fs → fjs}/text/ascii/proof.f.js +4 -14
- package/{fs → fjs}/text/code_point/module.f.js +10 -10
- package/{fs → fjs}/text/proof.f.js +4 -9
- package/{fs → fjs}/text/sgr/proof.f.js +6 -15
- package/{fs → fjs}/text/utf16/module.f.js +1 -1
- package/{fs → fjs}/text/utf16/proof.f.js +23 -66
- package/{fs → fjs}/text/utf8/proof.f.js +56 -125
- package/{fs → fjs}/types/array/proof.f.js +18 -52
- package/fjs/types/bigfloat/proof.f.js +217 -0
- package/{fs → fjs}/types/bigint/module.f.js +4 -3
- package/{fs → fjs}/types/bigint/proof.f.js +49 -145
- package/{fs → fjs}/types/bit_vec/module.f.js +5 -15
- package/{fs → fjs}/types/bit_vec/proof.f.js +72 -214
- package/{fs → fjs}/types/btree/find/proof.f.js +23 -66
- package/{fs → fjs}/types/btree/proof.f.js +5 -12
- package/{fs → fjs}/types/btree/remove/module.f.d.ts +5 -0
- package/{fs → fjs}/types/btree/remove/module.f.js +12 -0
- package/{fs → fjs}/types/btree/remove/proof.f.d.ts +2 -0
- package/{fs → fjs}/types/btree/remove/proof.f.js +83 -230
- package/{fs → fjs}/types/btree/set/module.f.js +5 -2
- package/{fs → fjs}/types/btree/set/proof.f.js +35 -24
- package/{fs → fjs}/types/byte_set/proof.f.js +22 -63
- package/{fs → fjs}/types/function/compare/proof.f.js +13 -36
- package/{fs → fjs}/types/function/operator/proof.f.js +17 -48
- package/{fs → fjs}/types/function/proof.f.js +2 -3
- package/{fs → fjs}/types/list/module.f.d.ts +21 -0
- package/{fs → fjs}/types/list/module.f.js +17 -0
- package/{fs → fjs}/types/list/proof.f.d.ts +1 -0
- package/{fs → fjs}/types/list/proof.f.js +79 -164
- package/{fs → fjs}/types/map/proof.f.js +4 -12
- package/{fs → fjs}/types/nibble_set/proof.f.js +16 -45
- package/{fs → fjs}/types/nominal/proof.f.js +5 -10
- package/fjs/types/nullable/proof.f.js +29 -0
- package/{fs → fjs}/types/number/module.f.js +2 -1
- package/{fs → fjs}/types/number/proof.f.js +9 -24
- package/{fs → fjs}/types/object/proof.f.js +3 -6
- package/{fs → fjs}/types/patricia_trie/proof.f.js +21 -21
- package/{fs → fjs}/types/prime_field/module.f.js +2 -7
- package/{fs → fjs}/types/range/module.f.d.ts +1 -1
- package/fjs/types/range/module.f.js +2 -0
- package/fjs/types/range/proof.f.js +9 -0
- package/{fs → fjs}/types/range_map/proof.f.js +28 -81
- package/{fs → fjs}/types/result/proof.f.d.ts +3 -2
- package/fjs/types/result/proof.f.js +31 -0
- package/{fs → fjs}/types/rtti/common/module.f.d.ts +36 -1
- package/{fs → fjs}/types/rtti/common/module.f.js +44 -0
- package/fjs/types/rtti/common/proof.f.d.ts +8 -0
- package/fjs/types/rtti/common/proof.f.js +51 -0
- package/{fs → fjs}/types/rtti/parse/module.f.js +13 -22
- package/{fs → fjs}/types/rtti/parse/proof.f.js +7 -18
- package/{fs → fjs}/types/rtti/ts/module.f.d.ts +10 -4
- package/{fs → fjs}/types/rtti/validate/module.f.js +8 -29
- package/{fs → fjs}/types/rtti/validate/proof.f.js +4 -9
- package/{fs → fjs}/types/sorted_list/proof.f.js +8 -21
- package/{fs → fjs}/types/sorted_set/proof.f.js +14 -39
- package/{fs → fjs}/types/string/module.f.js +10 -2
- package/fjs/types/string/proof.f.js +77 -0
- package/fjs/types/string_set/proof.f.js +43 -0
- package/{fs → fjs}/types/ts/proof.f.js +15 -42
- package/{fs → fjs}/types/uint8array/module.f.js +7 -7
- package/{fs → fjs}/types/uint8array/proof.f.d.ts +4 -1
- package/{fs → fjs}/types/uint8array/proof.f.js +7 -7
- package/{fs → fjs}/website/module.f.js +2 -3
- package/{fs → fjs}/website/proof.f.js +3 -6
- package/package.json +8 -8
- package/fs/asserts/module.f.d.ts +0 -4
- package/fs/asserts/module.f.js +0 -9
- package/fs/asserts/proof.f.d.ts +0 -8
- package/fs/asserts/proof.f.js +0 -51
- package/fs/bnf/data/module.f.d.ts +0 -30
- package/fs/bnf/descent/module.f.js +0 -119
- package/fs/bnf/proof.f.js +0 -104
- package/fs/cas/mcp/module.f.d.ts +0 -36
- package/fs/cas/proof.f.d.ts +0 -20
- package/fs/cas/proof.f.js +0 -294
- package/fs/common/monoid/module.f.js +0 -44
- package/fs/common/monoid/proof.f.d.ts +0 -4
- package/fs/common/monoid/proof.f.js +0 -27
- package/fs/crypto/pow/proof.f.js +0 -161
- package/fs/djs/tokenizer/module.f.d.ts +0 -12
- package/fs/djs/tokenizer/module.f.js +0 -62
- package/fs/djs/tokenizer/proof.f.d.ts +0 -7
- package/fs/djs/tokenizer/proof.f.js +0 -543
- package/fs/djs/tokenizer-new/module.f.d.ts +0 -3
- package/fs/djs/tokenizer-new/module.f.js +0 -155
- package/fs/effects/module.f.d.ts +0 -106
- package/fs/effects/module.f.js +0 -80
- package/fs/effects/proof.f.d.ts +0 -25
- package/fs/effects/proof.f.js +0 -115
- package/fs/media/revision/proof.f.js +0 -119
- package/fs/text/ascii/proof.f.d.ts +0 -4
- package/fs/types/bigfloat/proof.f.js +0 -348
- package/fs/types/nullable/proof.f.js +0 -50
- package/fs/types/range/module.f.js +0 -2
- package/fs/types/range/proof.f.js +0 -18
- package/fs/types/result/proof.f.js +0 -52
- package/fs/types/string/proof.f.js +0 -118
- package/fs/types/string_set/proof.f.js +0 -82
- /package/{fs → fjs}/asn.1/module.f.d.ts +0 -0
- /package/{fs → fjs}/asn.1/module.f.js +0 -0
- /package/{fs → fjs}/asn.1/proof.f.d.ts +0 -0
- /package/{fs → fjs}/base_n/module.f.d.ts +0 -0
- /package/{fs → fjs}/base_n/module.f.js +0 -0
- /package/{fs → fjs}/base_n/proof.f.d.ts +0 -0
- /package/{fs → fjs}/basen/base128/module.f.d.ts +0 -0
- /package/{fs → fjs}/basen/base128/module.f.js +0 -0
- /package/{fs → fjs}/basen/base128/proof.f.d.ts +0 -0
- /package/{fs → fjs}/basen/base128/proof.f.js +0 -0
- /package/{fs → fjs}/basen/base64/module.f.d.ts +0 -0
- /package/{fs → fjs}/basen/base64/module.f.js +0 -0
- /package/{fs → fjs}/basen/cbase32/module.f.d.ts +0 -0
- /package/{fs → fjs}/basen/cbase32/module.f.js +0 -0
- /package/{fs → fjs}/basen/cbase32/proof.f.d.ts +0 -0
- /package/{fs → fjs}/bnf/proof.f.d.ts +0 -0
- /package/{fs → fjs}/bnf/testlib.f.d.ts +0 -0
- /package/{fs → fjs}/cas/cli/module.f.d.ts +0 -0
- /package/{fs → fjs}/ci/bun/module.f.d.ts +0 -0
- /package/{fs → fjs}/ci/deno/module.f.d.ts +0 -0
- /package/{fs → fjs}/ci/module.f.d.ts +0 -0
- /package/{fs → fjs}/ci/node/module.f.d.ts +0 -0
- /package/{fs → fjs}/ci/playwright/module.f.d.ts +0 -0
- /package/{fs → fjs}/ci/playwright/module.f.js +0 -0
- /package/{fs → fjs}/ci/proof.f.d.ts +0 -0
- /package/{fs → fjs}/ci/rust/module.f.d.ts +0 -0
- /package/{fs → fjs}/cli/module.f.d.ts +0 -0
- /package/{fs → fjs}/cli/proof.f.d.ts +0 -0
- /package/{fs → fjs}/crypto/hmac/module.f.d.ts +0 -0
- /package/{fs → fjs}/crypto/hmac/module.f.js +0 -0
- /package/{fs → fjs}/crypto/hmac/proof.f.d.ts +0 -0
- /package/{fs → fjs}/crypto/pow/module.f.d.ts +0 -0
- /package/{fs → fjs}/crypto/pow/module.f.js +0 -0
- /package/{fs → fjs}/crypto/pow/proof.f.d.ts +0 -0
- /package/{fs → fjs}/crypto/secp/module.f.d.ts +0 -0
- /package/{fs → fjs}/crypto/secp/module.f.js +0 -0
- /package/{fs → fjs}/crypto/secp/proof.f.d.ts +0 -0
- /package/{fs → fjs}/crypto/sha2/module.f.d.ts +0 -0
- /package/{fs → fjs}/crypto/sha2/module.f.js +0 -0
- /package/{fs → fjs}/crypto/sha2/proof.f.d.ts +0 -0
- /package/{fs → fjs}/crypto/sign/proof.f.d.ts +0 -0
- /package/{fs → fjs}/crypto/vdf/module.f.d.ts +0 -0
- /package/{fs → fjs}/crypto/vdf/module.f.js +0 -0
- /package/{fs → fjs}/crypto/vdf/proof.f.d.ts +0 -0
- /package/{fs → fjs}/dev/module.f.d.ts +0 -0
- /package/{fs → fjs}/dev/package_json/module.f.d.ts +0 -0
- /package/{fs → fjs}/dev/package_json/module.f.js +0 -0
- /package/{fs → fjs}/dev/package_json/proof.f.d.ts +0 -0
- /package/{fs → fjs}/dev/proof.f.d.ts +0 -0
- /package/{fs → fjs}/djs/ast/module.f.d.ts +0 -0
- /package/{fs → fjs}/djs/ast/module.f.js +0 -0
- /package/{fs → fjs}/djs/ast/proof.f.d.ts +0 -0
- /package/{fs → fjs}/djs/examples/input.f.d.ts +0 -0
- /package/{fs → fjs}/djs/examples/input.f.js +0 -0
- /package/{fs → fjs}/djs/examples/m.f.d.ts +0 -0
- /package/{fs → fjs}/djs/examples/m.f.js +0 -0
- /package/{fs → fjs}/djs/module.f.d.ts +0 -0
- /package/{fs → fjs}/djs/parser/proof.f.d.ts +0 -0
- /package/{fs → fjs}/djs/proof.f.d.ts +0 -0
- /package/{fs → fjs}/djs/serializer/module.f.d.ts +0 -0
- /package/{fs → fjs}/djs/serializer/module.f.js +0 -0
- /package/{fs → fjs}/djs/serializer/proof.f.d.ts +0 -0
- /package/{fs → fjs}/djs/transpiler/module.f.d.ts +0 -0
- /package/{fs → fjs}/effects/memory/module.f.d.ts +0 -0
- /package/{fs → fjs}/effects/memory/module.f.js +0 -0
- /package/{fs → fjs}/effects/memory/proof.f.d.ts +0 -0
- /package/{fs → fjs}/effects/mock/module.f.d.ts +0 -0
- /package/{fs → fjs}/effects/mock/module.f.js +0 -0
- /package/{fs → fjs}/effects/module.d.ts +0 -0
- /package/{fs → fjs}/effects/module.js +0 -0
- /package/{fs → fjs}/effects/node/memory/module.d.ts +0 -0
- /package/{fs → fjs}/effects/node/memory/module.js +0 -0
- /package/{fs → fjs}/effects/node/memory/proof.d.ts +0 -0
- /package/{fs → fjs}/effects/node/virtual/module.f.d.ts +0 -0
- /package/{fs → fjs}/effects/node/virtual/module.f.js +0 -0
- /package/{fs → fjs}/emergent_testing/all.test.d.ts +0 -0
- /package/{fs → fjs}/emergent_testing/all.test.js +0 -0
- /package/{fs → fjs}/emergent_testing/example.f.d.ts +0 -0
- /package/{fs → fjs}/emergent_testing/example.f.js +0 -0
- /package/{fs → fjs}/emergent_testing/module.f.d.ts +0 -0
- /package/{fs → fjs}/emergent_testing/scenarios/all.d.ts +0 -0
- /package/{fs → fjs}/emergent_testing/scenarios/all.js +0 -0
- /package/{fs → fjs}/emergent_testing/scenarios/async-subtests.fail.d.ts +0 -0
- /package/{fs → fjs}/emergent_testing/scenarios/async-subtests.fail.js +0 -0
- /package/{fs → fjs}/emergent_testing/scenarios/async-subtests.pass.d.ts +0 -0
- /package/{fs → fjs}/emergent_testing/scenarios/async-subtests.pass.js +0 -0
- /package/{fs → fjs}/emergent_testing/scenarios/async.fail.d.ts +0 -0
- /package/{fs → fjs}/emergent_testing/scenarios/async.fail.js +0 -0
- /package/{fs → fjs}/emergent_testing/scenarios/async.pass.d.ts +0 -0
- /package/{fs → fjs}/emergent_testing/scenarios/async.pass.js +0 -0
- /package/{fs → fjs}/emergent_testing/scenarios/fail.fail.d.ts +0 -0
- /package/{fs → fjs}/emergent_testing/scenarios/fail.fail.js +0 -0
- /package/{fs → fjs}/emergent_testing/scenarios/return-value.pass.d.ts +0 -0
- /package/{fs → fjs}/emergent_testing/scenarios/return-value.pass.js +0 -0
- /package/{fs → fjs}/emergent_testing/scenarios/thenable.pass.d.ts +0 -0
- /package/{fs → fjs}/emergent_testing/scenarios/thenable.pass.js +0 -0
- /package/{fs → fjs}/emergent_testing/scenarios/thenable2.pass.d.ts +0 -0
- /package/{fs → fjs}/emergent_testing/scenarios/thenable2.pass.js +0 -0
- /package/{fs → fjs}/emergent_testing/scenarios/throw.pass.d.ts +0 -0
- /package/{fs → fjs}/emergent_testing/scenarios/throw.pass.js +0 -0
- /package/{fs → fjs}/fsc/bnf.f.d.ts +0 -0
- /package/{fs → fjs}/fsc/bnf.f.js +0 -0
- /package/{fs → fjs}/fsc/json.f.d.ts +0 -0
- /package/{fs → fjs}/fsc/json.f.js +0 -0
- /package/{fs → fjs}/fsc/module.f.d.ts +0 -0
- /package/{fs → fjs}/fsc/module.f.js +0 -0
- /package/{fs → fjs}/fsc/proof.f.d.ts +0 -0
- /package/{fs → fjs}/fsm/module.f.d.ts +0 -0
- /package/{fs → fjs}/fsm/module.f.js +0 -0
- /package/{fs → fjs}/fsm/proof.f.d.ts +0 -0
- /package/{fs → fjs}/js/tokenizer/module.f.d.ts +0 -0
- /package/{fs → fjs}/js/tokenizer/module.f.js +0 -0
- /package/{fs → fjs}/js/tokenizer/proof.f.d.ts +0 -0
- /package/{fs → fjs}/js/tokenizer/proof.f.js +0 -0
- /package/{fs → fjs}/mcp/proof.f.d.ts +0 -0
- /package/{fs → fjs}/mcp/stdio/proof.f.d.ts +0 -0
- /package/{fs → fjs}/mcp/stdio/proof.f.js +0 -0
- /package/{fs → fjs}/media/html/module.f.d.ts +0 -0
- /package/{fs → fjs}/media/html/module.f.js +0 -0
- /package/{fs → fjs}/media/html/proof.f.d.ts +0 -0
- /package/{fs → fjs}/media/json/module.f.d.ts +0 -0
- /package/{fs → fjs}/media/json/module.f.js +0 -0
- /package/{fs → fjs}/media/json/parser/proof.f.d.ts +0 -0
- /package/{fs → fjs}/media/json/proof.f.d.ts +0 -0
- /package/{fs → fjs}/media/json/proof.f.js +0 -0
- /package/{fs → fjs}/media/json/rpc/module.f.d.ts +0 -0
- /package/{fs → fjs}/media/json/rpc/proof.f.d.ts +0 -0
- /package/{fs → fjs}/media/json/rpc/proof.f.js +0 -0
- /package/{fs → fjs}/media/json/schema/proof.f.d.ts +0 -0
- /package/{fs → fjs}/media/json/serializer/module.f.d.ts +0 -0
- /package/{fs → fjs}/media/json/serializer/module.f.js +0 -0
- /package/{fs → fjs}/media/json/serializer/proof.f.d.ts +0 -0
- /package/{fs → fjs}/media/json/tokenizer/module.f.d.ts +0 -0
- /package/{fs → fjs}/media/json/tokenizer/module.f.js +0 -0
- /package/{fs → fjs}/media/json/tokenizer/proof.f.d.ts +0 -0
- /package/{fs → fjs}/media/json/tokenizer/proof.f.js +0 -0
- /package/{fs → fjs}/media/proof.f.d.ts +0 -0
- /package/{fs → fjs}/media/type/module.f.d.ts +0 -0
- /package/{fs → fjs}/media/type/proof.f.d.ts +0 -0
- /package/{fs → fjs}/module.d.ts +0 -0
- /package/{fs → fjs}/module.f.d.ts +0 -0
- /package/{fs → fjs}/module.js +0 -0
- /package/{fs → fjs}/path/module.f.d.ts +0 -0
- /package/{fs → fjs}/path/module.f.js +0 -0
- /package/{fs → fjs}/path/proof.f.d.ts +0 -0
- /package/{fs → fjs}/proof.f.d.ts +0 -0
- /package/{fs → fjs}/sul/id/module.f.d.ts +0 -0
- /package/{fs → fjs}/sul/id/module.f.js +0 -0
- /package/{fs → fjs}/sul/id/proof.f.d.ts +0 -0
- /package/{fs → fjs}/sul/level/hash/module.f.d.ts +0 -0
- /package/{fs → fjs}/sul/level/hash/module.f.js +0 -0
- /package/{fs → fjs}/sul/level/hash/proof.f.d.ts +0 -0
- /package/{fs → fjs}/sul/level/literal/module.f.d.ts +0 -0
- /package/{fs → fjs}/sul/level/literal/module.f.js +0 -0
- /package/{fs → fjs}/sul/level/literal/proof.f.d.ts +0 -0
- /package/{fs → fjs}/sul/module.f.d.ts +0 -0
- /package/{fs → fjs}/sul/module.f.js +0 -0
- /package/{fs → fjs}/sul/proof.f.d.ts +0 -0
- /package/{fs → fjs}/sul/proof.f.js +0 -0
- /package/{fs → fjs}/text/ascii/module.f.d.ts +0 -0
- /package/{fs → fjs}/text/ascii/module.f.js +0 -0
- /package/{fs → fjs}/text/code_point/module.f.d.ts +0 -0
- /package/{fs → fjs}/text/code_point/proof.f.d.ts +0 -0
- /package/{fs → fjs}/text/code_point/proof.f.js +0 -0
- /package/{fs → fjs}/text/module.f.d.ts +0 -0
- /package/{fs → fjs}/text/module.f.js +0 -0
- /package/{fs → fjs}/text/proof.f.d.ts +0 -0
- /package/{fs → fjs}/text/sgr/module.f.d.ts +0 -0
- /package/{fs → fjs}/text/sgr/module.f.js +0 -0
- /package/{fs → fjs}/text/sgr/proof.f.d.ts +0 -0
- /package/{fs → fjs}/text/utf16/module.f.d.ts +0 -0
- /package/{fs → fjs}/text/utf16/proof.f.d.ts +0 -0
- /package/{fs → fjs}/text/utf8/module.f.d.ts +0 -0
- /package/{fs → fjs}/text/utf8/module.f.js +0 -0
- /package/{fs → fjs}/text/utf8/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/array/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/array/module.f.js +0 -0
- /package/{fs → fjs}/types/array/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/bigfloat/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/bigfloat/module.f.js +0 -0
- /package/{fs → fjs}/types/bigfloat/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/bigint/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/bigint/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/bit_vec/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/bit_vec/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/btree/find/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/btree/find/module.f.js +0 -0
- /package/{fs → fjs}/types/btree/find/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/btree/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/btree/module.f.js +0 -0
- /package/{fs → fjs}/types/btree/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/btree/set/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/btree/set/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/btree/types/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/btree/types/module.f.js +0 -0
- /package/{fs → fjs}/types/byte_set/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/byte_set/module.f.js +0 -0
- /package/{fs → fjs}/types/byte_set/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/function/compare/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/function/compare/module.f.js +0 -0
- /package/{fs → fjs}/types/function/compare/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/function/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/function/module.f.js +0 -0
- /package/{fs → fjs}/types/function/operator/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/function/operator/module.f.js +0 -0
- /package/{fs → fjs}/types/function/operator/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/function/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/map/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/map/module.f.js +0 -0
- /package/{fs → fjs}/types/map/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/nibble_set/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/nibble_set/module.f.js +0 -0
- /package/{fs → fjs}/types/nibble_set/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/nominal/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/nominal/module.f.js +0 -0
- /package/{fs → fjs}/types/nominal/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/nullable/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/nullable/module.f.js +0 -0
- /package/{fs → fjs}/types/nullable/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/number/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/number/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/object/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/object/module.f.js +0 -0
- /package/{fs → fjs}/types/object/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/option/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/option/module.f.js +0 -0
- /package/{fs → fjs}/types/ordered_map/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/ordered_map/module.f.js +0 -0
- /package/{fs → fjs}/types/ordered_map/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/ordered_map/proof.f.js +0 -0
- /package/{fs → fjs}/types/patricia_trie/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/patricia_trie/module.f.js +0 -0
- /package/{fs → fjs}/types/patricia_trie/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/phantom/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/phantom/module.f.js +0 -0
- /package/{fs → fjs}/types/prime_field/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/prime_field/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/prime_field/proof.f.js +0 -0
- /package/{fs → fjs}/types/range/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/range_map/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/range_map/module.f.js +0 -0
- /package/{fs → fjs}/types/range_map/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/result/module.d.ts +0 -0
- /package/{fs → fjs}/types/result/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/result/module.f.js +0 -0
- /package/{fs → fjs}/types/result/module.js +0 -0
- /package/{fs → fjs}/types/rtti/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/rtti/module.f.js +0 -0
- /package/{fs → fjs}/types/rtti/parse/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/rtti/parse/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/rtti/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/rtti/proof.f.js +0 -0
- /package/{fs → fjs}/types/rtti/ts/module.f.js +0 -0
- /package/{fs → fjs}/types/rtti/ts/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/rtti/ts/proof.f.js +0 -0
- /package/{fs → fjs}/types/rtti/validate/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/rtti/validate/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/sorted_list/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/sorted_list/module.f.js +0 -0
- /package/{fs → fjs}/types/sorted_list/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/sorted_set/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/sorted_set/module.f.js +0 -0
- /package/{fs → fjs}/types/sorted_set/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/string/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/string/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/string_set/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/string_set/module.f.js +0 -0
- /package/{fs → fjs}/types/string_set/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/ts/module.f.d.ts +0 -0
- /package/{fs → fjs}/types/ts/module.f.js +0 -0
- /package/{fs → fjs}/types/ts/proof.f.d.ts +0 -0
- /package/{fs → fjs}/types/uint8array/module.f.d.ts +0 -0
- /package/{fs → fjs}/website/module.f.d.ts +0 -0
- /package/{fs → fjs}/website/proof.f.d.ts +0 -0
|
@@ -1,160 +1,13 @@
|
|
|
1
1
|
import { descentParser } from '../../bnf/descent/module.f.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
const tokenizeString = s => {
|
|
13
|
-
const m = descentParser(jsGrammar());
|
|
14
|
-
const cp = toArray(stringToCodePointList(s));
|
|
15
|
-
const [ast, ok, len] = descentParserCpOnly(m, '', cp);
|
|
16
|
-
if (cp.length === 0) {
|
|
17
|
-
return JSON.stringify([{ kind: 'eof' }]);
|
|
18
|
-
}
|
|
19
|
-
if (!ok)
|
|
20
|
-
return 'error';
|
|
21
|
-
if (cp.length > 0 && len !== cp.length)
|
|
22
|
-
return 'error';
|
|
23
|
-
const flatTokens = getTokensFromAstRule(ast);
|
|
24
|
-
const filterTokens = concat(filter(filterFunc)(flatTokens))(['']);
|
|
25
|
-
const tokens = flat(stateScan(scanFunc)(['', []])(filterTokens));
|
|
26
|
-
const jsTokens = concat(map(toJsToken)(tokens))([{ kind: 'eof' }]);
|
|
27
|
-
const result = toArray(filter(v => v !== null)(jsTokens));
|
|
28
|
-
//return JSON.stringify(toArray(filterTokens))
|
|
29
|
-
return JSON.stringify(result);
|
|
30
|
-
};
|
|
31
|
-
const isNlTag = (tag) => tag === '\n' || tag === '\r';
|
|
32
|
-
const isWsTag = (tag) => tag === ' ' || tag === '\t';
|
|
33
|
-
const scanFunc = (input, state) => {
|
|
34
|
-
if (typeof input === 'string') {
|
|
35
|
-
if (isNlTag(input) && isNlTag(state[0]))
|
|
36
|
-
return [null, state];
|
|
37
|
-
if (isWsTag(input) && isWsTag(state[0]))
|
|
38
|
-
return [null, state];
|
|
39
|
-
if (isNlTag(input) && isWsTag(state[0]))
|
|
40
|
-
return [null, [input, []]];
|
|
41
|
-
if (isWsTag(input) && isNlTag(state[0]))
|
|
42
|
-
return [null, state];
|
|
43
|
-
const newState = [input, []];
|
|
44
|
-
if (state[0] === '') {
|
|
45
|
-
return [null, newState];
|
|
46
|
-
}
|
|
47
|
-
const tk = [state[0], toArray(state[1])];
|
|
48
|
-
return [[tk], newState];
|
|
49
|
-
}
|
|
50
|
-
return [null, [state[0], concat(state[1])([input])]];
|
|
51
|
-
};
|
|
52
|
-
// All operator tag strings produced by the grammar's operator rule
|
|
53
|
-
const operatorTags = new Set([
|
|
54
|
-
'.', '=>', '===', '==', '=', '!==', '!=', '!',
|
|
55
|
-
'>>>=', '>>>', '>>=', '>>', '>=', '>',
|
|
56
|
-
'<<<=', '<<<', '<<=', '<<', '<=', '<',
|
|
57
|
-
'+=', '++', '+', '-=', '--', '-',
|
|
58
|
-
'**=', '**', '*=', '*', '/=', '/', '%=', '%', // TODO: '/' here causes multi-char line comments (e.g. //ab\n) to fall through as two '/' operator tokens because the oneline rule only consumes one non-newline character (option vs repeat0Plus). Fix the comment rule to use repeat0Plus, or make filterFunc distinguish operator-branch '/' from slash characters inside comments.
|
|
59
|
-
'&&=', '&&', '&=', '&', '||=', '||', '|=', '|',
|
|
60
|
-
'^=', '^', '~', '??=', '??', '?.', '?',
|
|
61
|
-
'[', ']', '{', '}', '(', ')', ',', ':'
|
|
62
|
-
]);
|
|
63
|
-
const filterFunc = tk => {
|
|
64
|
-
if (typeof tk === 'number')
|
|
65
|
-
return true;
|
|
66
|
-
switch (tk) {
|
|
67
|
-
case 'number':
|
|
68
|
-
case 'string':
|
|
69
|
-
case 'id':
|
|
70
|
-
case '\n':
|
|
71
|
-
case '\r':
|
|
72
|
-
case ' ':
|
|
73
|
-
case '\t':
|
|
74
|
-
return true;
|
|
75
|
-
default:
|
|
76
|
-
return operatorTags.has(tk);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
const rangeCapitalAF = range('AF');
|
|
80
|
-
const stringDecodeScan = (cp, state) => {
|
|
81
|
-
switch (state.kind) {
|
|
82
|
-
case 'escape':
|
|
83
|
-
switch (cp) {
|
|
84
|
-
case quotationMark: return [[quotationMark], { kind: 'normal' }]; // \" → "
|
|
85
|
-
case reverseSolidus: return [[reverseSolidus], { kind: 'normal' }]; // \\ → \
|
|
86
|
-
case solidus: return [[solidus], { kind: 'normal' }]; // \/ → /
|
|
87
|
-
case latinSmallLetterB: return [[backspace], { kind: 'normal' }]; // \b → backspace (BS)
|
|
88
|
-
case latinSmallLetterF: return [[ff], { kind: 'normal' }]; // \f → form feed (FF)
|
|
89
|
-
case latinSmallLetterN: return [[lf], { kind: 'normal' }]; // \n → line feed (LF)
|
|
90
|
-
case latinSmallLetterR: return [[cr], { kind: 'normal' }]; // \r → carriage return (CR)
|
|
91
|
-
case latinSmallLetterT: return [[ht], { kind: 'normal' }]; // \t → horizontal tab (HT)
|
|
92
|
-
case latinSmallLetterU: return [null, { kind: 'unicode', acc: 0, count: 0 }]; // \u → start 4 hex digits
|
|
93
|
-
default: return [[cp], { kind: 'normal' }];
|
|
94
|
-
}
|
|
95
|
-
case 'unicode': {
|
|
96
|
-
// convert hex digit char to its numeric value: '0'-'9', 'A'-'F', 'a'-'f'
|
|
97
|
-
const digit = contains(digitRange)(cp) ? cp - digit0
|
|
98
|
-
: contains(rangeCapitalAF)(cp) ? cp - (latinCapitalLetterA - 10)
|
|
99
|
-
: cp - (latinSmallLetterA - 10);
|
|
100
|
-
const acc = (state.acc << 4) | digit;
|
|
101
|
-
return state.count === 3 ? [[acc], { kind: 'normal' }] : [null, { kind: 'unicode', acc, count: state.count + 1 }];
|
|
102
|
-
}
|
|
103
|
-
default:
|
|
104
|
-
return cp === reverseSolidus ? [null, { kind: 'escape' }] : [[cp], { kind: 'normal' }];
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
const decodeJsonString = codePoints => String.fromCodePoint(...toArray(flat(stateScan(stringDecodeScan)({ kind: 'normal' })(codePoints.slice(1, -1)))));
|
|
108
|
-
const keywords = new Set([
|
|
109
|
-
'true', 'false', 'null', 'undefined',
|
|
110
|
-
'arguments', 'await', 'break', 'case', 'catch', 'class', 'const', 'continue',
|
|
111
|
-
'debugger', 'default', 'delete', 'do', 'else', 'enum', 'eval', 'export',
|
|
112
|
-
'extends', 'finally', 'for', 'function', 'if', 'implements', 'import', 'in',
|
|
113
|
-
'instanceof', 'interface', 'let', 'new', 'package', 'private', 'protected',
|
|
114
|
-
'public', 'return', 'static', 'super', 'switch', 'this', 'throw', 'try',
|
|
115
|
-
'typeof', 'var', 'void', 'while', 'with', 'yield',
|
|
116
|
-
]);
|
|
117
|
-
const toJsToken = tk => {
|
|
118
|
-
switch (tk[0]) {
|
|
119
|
-
case '\n':
|
|
120
|
-
case '\r':
|
|
121
|
-
return { kind: 'nl' };
|
|
122
|
-
case ' ':
|
|
123
|
-
case '\t':
|
|
124
|
-
return { kind: 'ws' };
|
|
125
|
-
case 'string':
|
|
126
|
-
return { kind: 'string', value: decodeJsonString(tk[1]) };
|
|
127
|
-
case 'id': {
|
|
128
|
-
const value = String.fromCodePoint(...tk[1]);
|
|
129
|
-
if (keywords.has(value))
|
|
130
|
-
return { kind: value };
|
|
131
|
-
return { kind: 'id', value };
|
|
132
|
-
}
|
|
133
|
-
default:
|
|
134
|
-
return { kind: tk[0] };
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
const getTokensFromAstRuleOrCodePoint = value => {
|
|
138
|
-
if (value instanceof Array)
|
|
139
|
-
return [value[0]];
|
|
140
|
-
return getTokensFromAstRule(value);
|
|
141
|
-
};
|
|
142
|
-
const getTokensFromAstSequence = seq => {
|
|
143
|
-
return flatMap(getTokensFromAstRuleOrCodePoint)(seq);
|
|
144
|
-
};
|
|
145
|
-
const tagToToken = tag => {
|
|
146
|
-
switch (typeof tag) {
|
|
147
|
-
case 'string': return tag;
|
|
148
|
-
case 'undefined': return 'undefined';
|
|
149
|
-
default: return 'true';
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
const getTokensFromAstRule = ast => {
|
|
153
|
-
const token = tagToToken(ast.tag);
|
|
154
|
-
if (ast.sequence.length === 0)
|
|
155
|
-
return [token];
|
|
156
|
-
return { first: token, tail: getTokensFromAstSequence(ast.sequence) };
|
|
157
|
-
};
|
|
2
|
+
import { stringToCodePointList, stringToList } from '../../text/utf16/module.f.js';
|
|
3
|
+
import { toArray } from '../../types/list/module.f.js';
|
|
4
|
+
import { jsGrammar, tokenizeString, descentParserCpOnly, tokenizeJs, tokenize } from './module.f.js';
|
|
5
|
+
import { assert, assertEq } from '../../asserts/module.f.js';
|
|
6
|
+
import { stringifyAsTree } from '../serializer/module.f.js';
|
|
7
|
+
import { sort } from '../../types/object/module.f.js';
|
|
8
|
+
// DjsTokenWithMetadata carries bigint fields (bf, bigint value) that JSON.stringify can't
|
|
9
|
+
// serialize — reuse the same djs stringifyAsTree serializer tokenizeString uses internally.
|
|
10
|
+
const stringify = stringifyAsTree(sort);
|
|
158
11
|
export const proof = {
|
|
159
12
|
isValid: [() => {
|
|
160
13
|
const m = descentParser(jsGrammar());
|
|
@@ -162,9 +15,7 @@ export const proof = {
|
|
|
162
15
|
const cp = toArray(stringToCodePointList(s));
|
|
163
16
|
const mr = descentParserCpOnly(m, '', cp);
|
|
164
17
|
const success = mr[1] && mr[2] === cp.length;
|
|
165
|
-
|
|
166
|
-
throw JSON.stringify([s, mr]);
|
|
167
|
-
}
|
|
18
|
+
assertEq(success, expected, JSON.stringify([s, mr]));
|
|
168
19
|
};
|
|
169
20
|
expect('"', false);
|
|
170
21
|
expect(' true ', true);
|
|
@@ -201,150 +52,120 @@ export const proof = {
|
|
|
201
52
|
const cp = toArray(stringToCodePointList('tr'));
|
|
202
53
|
const mr = descentParserCpOnly(m, '', cp);
|
|
203
54
|
const seq = mr[0].sequence[0];
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
if (seq.tag !== 'id')
|
|
207
|
-
throw JSON.stringify(mr);
|
|
55
|
+
assert(!(seq instanceof Array), JSON.stringify(mr));
|
|
56
|
+
assertEq(seq.tag, 'id', JSON.stringify(mr));
|
|
208
57
|
},
|
|
209
58
|
() => {
|
|
210
59
|
const m = descentParser(jsGrammar());
|
|
211
60
|
const cp = toArray(stringToCodePointList('"tr"'));
|
|
212
61
|
const mr = descentParserCpOnly(m, '', cp);
|
|
213
62
|
const seq = mr[0].sequence[0];
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
if (seq.tag !== 'string')
|
|
217
|
-
throw JSON.stringify(mr);
|
|
63
|
+
assert(!(seq instanceof Array), JSON.stringify(mr));
|
|
64
|
+
assertEq(seq.tag, 'string', JSON.stringify(mr));
|
|
218
65
|
},
|
|
219
66
|
() => {
|
|
220
67
|
const m = descentParser(jsGrammar());
|
|
221
68
|
const cp = toArray(stringToCodePointList('56.7e+5'));
|
|
222
69
|
const mr = descentParserCpOnly(m, '', cp);
|
|
223
70
|
const seq = mr[0].sequence[0];
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
if (seq.tag !== 'number')
|
|
227
|
-
throw JSON.stringify(mr);
|
|
71
|
+
assert(!(seq instanceof Array), JSON.stringify(mr));
|
|
72
|
+
assertEq(seq.tag, 'number', JSON.stringify(mr));
|
|
228
73
|
},
|
|
229
74
|
() => {
|
|
230
75
|
const m = descentParser(jsGrammar());
|
|
231
76
|
const cp = toArray(stringToCodePointList('56n'));
|
|
232
77
|
const mr = descentParserCpOnly(m, '', cp);
|
|
233
78
|
const seq = mr[0].sequence[0];
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
if (seq.tag !== 'number')
|
|
237
|
-
throw JSON.stringify(mr);
|
|
79
|
+
assert(!(seq instanceof Array), JSON.stringify(mr));
|
|
80
|
+
assertEq(seq.tag, 'number', JSON.stringify(mr));
|
|
238
81
|
},
|
|
239
82
|
() => {
|
|
240
83
|
const m = descentParser(jsGrammar());
|
|
241
84
|
const cp = toArray(stringToCodePointList('*'));
|
|
242
85
|
const mr = descentParserCpOnly(m, '', cp);
|
|
243
86
|
const seq = mr[0].sequence[0];
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
if (seq.tag !== '*')
|
|
247
|
-
throw JSON.stringify(mr);
|
|
87
|
+
assert(!(seq instanceof Array), JSON.stringify(mr));
|
|
88
|
+
assertEq(seq.tag, '*', JSON.stringify(mr));
|
|
248
89
|
},
|
|
249
90
|
() => {
|
|
250
91
|
const m = descentParser(jsGrammar());
|
|
251
92
|
const cp = toArray(stringToCodePointList('**'));
|
|
252
93
|
const mr = descentParserCpOnly(m, '', cp);
|
|
253
94
|
const seq = mr[0].sequence[0];
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
if (seq.tag !== '**')
|
|
257
|
-
throw JSON.stringify(mr);
|
|
95
|
+
assert(!(seq instanceof Array), JSON.stringify(mr));
|
|
96
|
+
assertEq(seq.tag, '**', JSON.stringify(mr));
|
|
258
97
|
},
|
|
259
98
|
() => {
|
|
260
99
|
const m = descentParser(jsGrammar());
|
|
261
100
|
const cp = toArray(stringToCodePointList('=>'));
|
|
262
101
|
const mr = descentParserCpOnly(m, '', cp);
|
|
263
102
|
const seq = mr[0].sequence[0];
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
if (seq.tag !== '=>')
|
|
267
|
-
throw JSON.stringify(mr);
|
|
103
|
+
assert(!(seq instanceof Array), JSON.stringify(mr));
|
|
104
|
+
assertEq(seq.tag, '=>', JSON.stringify(mr));
|
|
268
105
|
},
|
|
269
106
|
() => {
|
|
270
107
|
const m = descentParser(jsGrammar());
|
|
271
108
|
const cp = toArray(stringToCodePointList('=='));
|
|
272
109
|
const mr = descentParserCpOnly(m, '', cp);
|
|
273
110
|
const seq = mr[0].sequence[0];
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
if (seq.tag !== '==')
|
|
277
|
-
throw JSON.stringify(mr);
|
|
111
|
+
assert(!(seq instanceof Array), JSON.stringify(mr));
|
|
112
|
+
assert(!(seq.tag !== '=='), JSON.stringify(mr));
|
|
278
113
|
},
|
|
279
114
|
() => {
|
|
280
115
|
const m = descentParser(jsGrammar());
|
|
281
116
|
const cp = toArray(stringToCodePointList('==='));
|
|
282
117
|
const mr = descentParserCpOnly(m, '', cp);
|
|
283
118
|
const seq = mr[0].sequence[0];
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
if (seq.tag !== '===')
|
|
287
|
-
throw JSON.stringify(mr);
|
|
119
|
+
assert(!(seq instanceof Array), JSON.stringify(mr));
|
|
120
|
+
assert(!(seq.tag !== '==='), JSON.stringify(mr));
|
|
288
121
|
},
|
|
289
122
|
() => {
|
|
290
123
|
const m = descentParser(jsGrammar());
|
|
291
124
|
const cp = toArray(stringToCodePointList('='));
|
|
292
125
|
const mr = descentParserCpOnly(m, '', cp);
|
|
293
126
|
const seq = mr[0].sequence[0];
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
if (seq.tag !== '=')
|
|
297
|
-
throw JSON.stringify(mr);
|
|
127
|
+
assert(!(seq instanceof Array), JSON.stringify(mr));
|
|
128
|
+
assertEq(seq.tag, '=', JSON.stringify(mr));
|
|
298
129
|
},
|
|
299
130
|
() => {
|
|
300
131
|
const m = descentParser(jsGrammar());
|
|
301
132
|
const cp = toArray(stringToCodePointList(' '));
|
|
302
133
|
const mr = descentParserCpOnly(m, '', cp);
|
|
303
134
|
const seq = mr[0].sequence[0];
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
if (seq.tag !== ' ')
|
|
307
|
-
throw JSON.stringify(mr);
|
|
135
|
+
assert(!(seq instanceof Array), JSON.stringify(mr));
|
|
136
|
+
assertEq(seq.tag, ' ', JSON.stringify(mr));
|
|
308
137
|
},
|
|
309
138
|
() => {
|
|
310
139
|
const m = descentParser(jsGrammar());
|
|
311
140
|
const cp = toArray(stringToCodePointList('\n'));
|
|
312
141
|
const mr = descentParserCpOnly(m, '', cp);
|
|
313
142
|
const seq = mr[0].sequence[0];
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
if (seq.tag !== '\n')
|
|
317
|
-
throw JSON.stringify(mr);
|
|
143
|
+
assert(!(seq instanceof Array), JSON.stringify(mr));
|
|
144
|
+
assertEq(seq.tag, '\n', JSON.stringify(mr));
|
|
318
145
|
},
|
|
319
146
|
() => {
|
|
320
147
|
const m = descentParser(jsGrammar());
|
|
321
148
|
const cp = toArray(stringToCodePointList('/\n'));
|
|
322
149
|
const mr = descentParserCpOnly(m, '', cp);
|
|
323
150
|
const seq = mr[0].sequence[0];
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
if (seq.tag !== '/')
|
|
327
|
-
throw JSON.stringify(mr);
|
|
151
|
+
assert(!(seq instanceof Array), JSON.stringify(mr));
|
|
152
|
+
assertEq(seq.tag, '/', JSON.stringify(mr));
|
|
328
153
|
},
|
|
329
154
|
() => {
|
|
330
155
|
const m = descentParser(jsGrammar());
|
|
331
156
|
const cp = toArray(stringToCodePointList('//\n'));
|
|
332
157
|
const mr = descentParserCpOnly(m, '', cp);
|
|
333
158
|
const seq = mr[0].sequence[0];
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
if (seq.tag !== 'comment')
|
|
337
|
-
throw JSON.stringify(mr);
|
|
159
|
+
assert(!(seq instanceof Array), JSON.stringify(mr));
|
|
160
|
+
assertEq(seq.tag, 'comment', JSON.stringify(mr));
|
|
338
161
|
},
|
|
339
162
|
() => {
|
|
340
163
|
const m = descentParser(jsGrammar());
|
|
341
164
|
const cp = toArray(stringToCodePointList('/*1*/'));
|
|
342
165
|
const mr = descentParserCpOnly(m, '', cp);
|
|
343
166
|
const seq = mr[0].sequence[0];
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
if (seq.tag !== 'comment')
|
|
347
|
-
throw JSON.stringify(mr);
|
|
167
|
+
assert(!(seq instanceof Array), JSON.stringify(mr));
|
|
168
|
+
assertEq(seq.tag, 'comment', JSON.stringify(mr));
|
|
348
169
|
}
|
|
349
170
|
],
|
|
350
171
|
djs: [
|
|
@@ -392,9 +213,7 @@ export const proof = {
|
|
|
392
213
|
},
|
|
393
214
|
() => {
|
|
394
215
|
const result = tokenizeString('ᄑ');
|
|
395
|
-
|
|
396
|
-
throw result;
|
|
397
|
-
}
|
|
216
|
+
assertEq(result, 'error');
|
|
398
217
|
},
|
|
399
218
|
() => {
|
|
400
219
|
const result = tokenizeString('{ \t\n\r}');
|
|
@@ -416,9 +235,7 @@ export const proof = {
|
|
|
416
235
|
},
|
|
417
236
|
() => {
|
|
418
237
|
const result = tokenizeString('"value');
|
|
419
|
-
|
|
420
|
-
throw result;
|
|
421
|
-
}
|
|
238
|
+
assertEq(result, 'error');
|
|
422
239
|
},
|
|
423
240
|
() => {
|
|
424
241
|
const result = tokenizeString('"value1" "value2"');
|
|
@@ -428,9 +245,7 @@ export const proof = {
|
|
|
428
245
|
},
|
|
429
246
|
() => {
|
|
430
247
|
const result = tokenizeString('"');
|
|
431
|
-
|
|
432
|
-
throw result;
|
|
433
|
-
}
|
|
248
|
+
assertEq(result, 'error');
|
|
434
249
|
},
|
|
435
250
|
() => {
|
|
436
251
|
const result = tokenizeString('"\\\\"');
|
|
@@ -452,27 +267,19 @@ export const proof = {
|
|
|
452
267
|
},
|
|
453
268
|
() => {
|
|
454
269
|
const result = tokenizeString('"\\x"');
|
|
455
|
-
|
|
456
|
-
throw result;
|
|
457
|
-
}
|
|
270
|
+
assertEq(result, 'error');
|
|
458
271
|
},
|
|
459
272
|
() => {
|
|
460
273
|
const result = tokenizeString('"\\');
|
|
461
|
-
|
|
462
|
-
throw result;
|
|
463
|
-
}
|
|
274
|
+
assertEq(result, 'error');
|
|
464
275
|
},
|
|
465
276
|
() => {
|
|
466
277
|
const result = tokenizeString('"\r"');
|
|
467
|
-
|
|
468
|
-
throw result;
|
|
469
|
-
}
|
|
278
|
+
assertEq(result, 'error');
|
|
470
279
|
},
|
|
471
280
|
() => {
|
|
472
281
|
const result = tokenizeString('"\n null');
|
|
473
|
-
|
|
474
|
-
throw result;
|
|
475
|
-
}
|
|
282
|
+
assertEq(result, 'error');
|
|
476
283
|
},
|
|
477
284
|
() => {
|
|
478
285
|
const result = tokenizeString('"\\b\\f\\n\\r\\t"');
|
|
@@ -494,130 +301,166 @@ export const proof = {
|
|
|
494
301
|
},
|
|
495
302
|
() => {
|
|
496
303
|
const result = tokenizeString('"\\uEeFg"');
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
304
|
+
assertEq(result, 'error');
|
|
305
|
+
},
|
|
306
|
+
() => {
|
|
307
|
+
const result = tokenizeString('0');
|
|
308
|
+
if (result !== '[{"bf":[0n,0],"kind":"number","value":"0"},{"kind":"eof"}]') {
|
|
309
|
+
throw result;
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
() => {
|
|
313
|
+
const result = tokenizeString('[0]');
|
|
314
|
+
if (result !== '[{"kind":"["},{"bf":[0n,0],"kind":"number","value":"0"},{"kind":"]"},{"kind":"eof"}]') {
|
|
315
|
+
throw result;
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
() => {
|
|
319
|
+
const result = tokenizeString('00');
|
|
320
|
+
assertEq(result, 'error');
|
|
321
|
+
},
|
|
322
|
+
() => {
|
|
323
|
+
const result = tokenizeString('0abc,');
|
|
324
|
+
assertEq(result, 'error');
|
|
325
|
+
},
|
|
326
|
+
() => {
|
|
327
|
+
const result = tokenizeString('123456789012345678901234567890');
|
|
328
|
+
if (result !== '[{"bf":[123456789012345678901234567890n,0],"kind":"number","value":"123456789012345678901234567890"},{"kind":"eof"}]') {
|
|
329
|
+
throw result;
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
() => {
|
|
333
|
+
const result = tokenizeString('{90}');
|
|
334
|
+
if (result !== '[{"kind":"{"},{"bf":[90n,0],"kind":"number","value":"90"},{"kind":"}"},{"kind":"eof"}]') {
|
|
335
|
+
throw result;
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
() => {
|
|
339
|
+
const result = tokenizeString('1 2');
|
|
340
|
+
if (result !== '[{"bf":[1n,0],"kind":"number","value":"1"},{"kind":"ws"},{"bf":[2n,0],"kind":"number","value":"2"},{"kind":"eof"}]') {
|
|
341
|
+
throw result;
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
() => {
|
|
345
|
+
const result = tokenizeString('0. 2');
|
|
346
|
+
assertEq(result, 'error');
|
|
347
|
+
},
|
|
348
|
+
() => {
|
|
349
|
+
const result = tokenizeString('10-0');
|
|
350
|
+
if (result !== '[{"bf":[10n,0],"kind":"number","value":"10"},{"kind":"-"},{"bf":[0n,0],"kind":"number","value":"0"},{"kind":"eof"}]') {
|
|
351
|
+
throw result;
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
() => {
|
|
355
|
+
const result = tokenizeString('9a:');
|
|
356
|
+
assertEq(result, 'error');
|
|
357
|
+
},
|
|
358
|
+
() => {
|
|
359
|
+
const result = tokenizeString('-10');
|
|
360
|
+
if (result !== '[{"kind":"-"},{"bf":[10n,0],"kind":"number","value":"10"},{"kind":"eof"}]') {
|
|
361
|
+
throw result;
|
|
362
|
+
}
|
|
363
|
+
},
|
|
364
|
+
() => {
|
|
365
|
+
const result = tokenizeString('-0');
|
|
366
|
+
if (result !== '[{"kind":"-"},{"bf":[0n,0],"kind":"number","value":"0"},{"kind":"eof"}]') {
|
|
367
|
+
throw result;
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
() => {
|
|
371
|
+
const result = tokenizeString('-00');
|
|
372
|
+
assertEq(result, 'error');
|
|
373
|
+
},
|
|
374
|
+
() => {
|
|
375
|
+
const result = tokenizeString('-.123');
|
|
376
|
+
if (result !== '[{"kind":"-"},{"kind":"."},{"bf":[123n,0],"kind":"number","value":"123"},{"kind":"eof"}]') {
|
|
377
|
+
throw result;
|
|
378
|
+
}
|
|
379
|
+
},
|
|
380
|
+
() => {
|
|
381
|
+
const result = tokenizeString('0.01');
|
|
382
|
+
if (result !== '[{"bf":[1n,-2],"kind":"number","value":"0.01"},{"kind":"eof"}]') {
|
|
383
|
+
throw result;
|
|
384
|
+
}
|
|
385
|
+
},
|
|
386
|
+
() => {
|
|
387
|
+
const result = tokenizeString('-0.9');
|
|
388
|
+
if (result !== '[{"kind":"-"},{"bf":[9n,-1],"kind":"number","value":"0.9"},{"kind":"eof"}]') {
|
|
389
|
+
throw result;
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
() => {
|
|
393
|
+
const result = tokenizeString('-0.');
|
|
394
|
+
assertEq(result, 'error');
|
|
395
|
+
},
|
|
396
|
+
() => {
|
|
397
|
+
const result = tokenizeString('-0.]');
|
|
398
|
+
assertEq(result, 'error');
|
|
399
|
+
},
|
|
400
|
+
() => {
|
|
401
|
+
const result = tokenizeString('12.34');
|
|
402
|
+
if (result !== '[{"bf":[1234n,-2],"kind":"number","value":"12.34"},{"kind":"eof"}]') {
|
|
403
|
+
throw result;
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
() => {
|
|
407
|
+
const result = tokenizeString('-12.00');
|
|
408
|
+
if (result !== '[{"kind":"-"},{"bf":[1200n,-2],"kind":"number","value":"12.00"},{"kind":"eof"}]') {
|
|
409
|
+
throw result;
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
() => {
|
|
413
|
+
const result = tokenizeString('-12.');
|
|
414
|
+
assertEq(result, 'error');
|
|
415
|
+
},
|
|
416
|
+
() => {
|
|
417
|
+
const result = tokenizeString('12.]');
|
|
418
|
+
assertEq(result, 'error');
|
|
419
|
+
},
|
|
420
|
+
() => {
|
|
421
|
+
const result = tokenizeString('0e1');
|
|
422
|
+
if (result !== '[{"bf":[0n,1],"kind":"number","value":"0e1"},{"kind":"eof"}]') {
|
|
423
|
+
throw result;
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
() => {
|
|
427
|
+
const result = tokenizeString('0e+2');
|
|
428
|
+
if (result !== '[{"bf":[0n,2],"kind":"number","value":"0e+2"},{"kind":"eof"}]') {
|
|
429
|
+
throw result;
|
|
430
|
+
}
|
|
431
|
+
},
|
|
432
|
+
() => {
|
|
433
|
+
const result = tokenizeString('0e-0');
|
|
434
|
+
if (result !== '[{"bf":[0n,0],"kind":"number","value":"0e-0"},{"kind":"eof"}]') {
|
|
435
|
+
throw result;
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
() => {
|
|
439
|
+
const result = tokenizeString('12e0000');
|
|
440
|
+
if (result !== '[{"bf":[12n,0],"kind":"number","value":"12e0000"},{"kind":"eof"}]') {
|
|
441
|
+
throw result;
|
|
442
|
+
}
|
|
443
|
+
},
|
|
444
|
+
() => {
|
|
445
|
+
const result = tokenizeString('-12e-0001');
|
|
446
|
+
if (result !== '[{"kind":"-"},{"bf":[12n,-1],"kind":"number","value":"12e-0001"},{"kind":"eof"}]') {
|
|
447
|
+
throw result;
|
|
448
|
+
}
|
|
449
|
+
},
|
|
450
|
+
() => {
|
|
451
|
+
const result = tokenizeString('-12.34e1234');
|
|
452
|
+
if (result !== '[{"kind":"-"},{"bf":[1234n,1232],"kind":"number","value":"12.34e1234"},{"kind":"eof"}]') {
|
|
453
|
+
throw result;
|
|
454
|
+
}
|
|
455
|
+
},
|
|
456
|
+
() => {
|
|
457
|
+
const result = tokenizeString('0e');
|
|
458
|
+
assertEq(result, 'error');
|
|
459
|
+
},
|
|
460
|
+
() => {
|
|
461
|
+
const result = tokenizeString('0e-');
|
|
462
|
+
assertEq(result, 'error');
|
|
463
|
+
},
|
|
621
464
|
() => {
|
|
622
465
|
const result = tokenizeString('ABCdef1234567890$_');
|
|
623
466
|
if (result !== '[{"kind":"id","value":"ABCdef1234567890$_"},{"kind":"eof"}]') {
|
|
@@ -630,50 +473,60 @@ export const proof = {
|
|
|
630
473
|
throw result;
|
|
631
474
|
}
|
|
632
475
|
},
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
476
|
+
() => {
|
|
477
|
+
const result = tokenizeString('123 _123');
|
|
478
|
+
if (result !== '[{"bf":[123n,0],"kind":"number","value":"123"},{"kind":"ws"},{"kind":"id","value":"_123"},{"kind":"eof"}]') {
|
|
479
|
+
throw result;
|
|
480
|
+
}
|
|
481
|
+
},
|
|
482
|
+
() => {
|
|
483
|
+
const result = tokenizeString('123 $123');
|
|
484
|
+
if (result !== '[{"bf":[123n,0],"kind":"number","value":"123"},{"kind":"ws"},{"kind":"id","value":"$123"},{"kind":"eof"}]') {
|
|
485
|
+
throw result;
|
|
486
|
+
}
|
|
487
|
+
},
|
|
488
|
+
() => {
|
|
489
|
+
const result = tokenizeString('123_123');
|
|
490
|
+
assertEq(result, 'error');
|
|
491
|
+
},
|
|
492
|
+
() => {
|
|
493
|
+
const result = tokenizeString('123$123');
|
|
494
|
+
assertEq(result, 'error');
|
|
495
|
+
},
|
|
496
|
+
() => {
|
|
497
|
+
const result = tokenizeString('1234567890n');
|
|
498
|
+
if (result !== '[{"kind":"bigint","value":1234567890n},{"kind":"eof"}]') {
|
|
499
|
+
throw result;
|
|
500
|
+
}
|
|
501
|
+
},
|
|
502
|
+
() => {
|
|
503
|
+
const result = tokenizeString('0n');
|
|
504
|
+
if (result !== '[{"kind":"bigint","value":0n},{"kind":"eof"}]') {
|
|
505
|
+
throw result;
|
|
506
|
+
}
|
|
507
|
+
},
|
|
508
|
+
() => {
|
|
509
|
+
const result = tokenizeString('[-1234567890n]');
|
|
510
|
+
if (result !== '[{"kind":"["},{"kind":"-"},{"kind":"bigint","value":1234567890n},{"kind":"]"},{"kind":"eof"}]') {
|
|
511
|
+
throw result;
|
|
512
|
+
}
|
|
513
|
+
},
|
|
514
|
+
() => {
|
|
515
|
+
const result = tokenizeString('123.456n');
|
|
516
|
+
assertEq(result, 'error');
|
|
517
|
+
},
|
|
518
|
+
() => {
|
|
519
|
+
const result = tokenizeString('123e456n');
|
|
520
|
+
assertEq(result, 'error');
|
|
521
|
+
},
|
|
522
|
+
() => {
|
|
523
|
+
const result = tokenizeString('1234567890na');
|
|
524
|
+
assertEq(result, 'error');
|
|
525
|
+
},
|
|
526
|
+
() => {
|
|
527
|
+
const result = tokenizeString('1234567890nn');
|
|
528
|
+
assertEq(result, 'error');
|
|
529
|
+
},
|
|
677
530
|
],
|
|
678
531
|
operators: [
|
|
679
532
|
() => {
|
|
@@ -694,10 +547,12 @@ export const proof = {
|
|
|
694
547
|
throw result;
|
|
695
548
|
}
|
|
696
549
|
},
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
550
|
+
() => {
|
|
551
|
+
const result = tokenizeString('1*2');
|
|
552
|
+
if (result !== '[{"bf":[1n,0],"kind":"number","value":"1"},{"kind":"*"},{"bf":[2n,0],"kind":"number","value":"2"},{"kind":"eof"}]') {
|
|
553
|
+
throw result;
|
|
554
|
+
}
|
|
555
|
+
},
|
|
701
556
|
() => {
|
|
702
557
|
const result = tokenizeString('( )');
|
|
703
558
|
if (result !== '[{"kind":"("},{"kind":"ws"},{"kind":")"},{"kind":"eof"}]') {
|
|
@@ -734,6 +589,14 @@ export const proof = {
|
|
|
734
589
|
throw result;
|
|
735
590
|
}
|
|
736
591
|
},
|
|
592
|
+
() => {
|
|
593
|
+
// '<<<' and '<<<=' are not JS operators; maximal munch tokenizes them
|
|
594
|
+
// as '<<' followed by '<' / '<=', matching the old tokenizer's behavior.
|
|
595
|
+
const result = tokenizeString('<<< <<<=');
|
|
596
|
+
if (result !== '[{"kind":"<<"},{"kind":"<"},{"kind":"ws"},{"kind":"<<"},{"kind":"<="},{"kind":"eof"}]') {
|
|
597
|
+
throw result;
|
|
598
|
+
}
|
|
599
|
+
},
|
|
737
600
|
() => {
|
|
738
601
|
const result = tokenizeString('&& || ! ??');
|
|
739
602
|
if (result !== '[{"kind":"&&"},{"kind":"ws"},{"kind":"||"},{"kind":"ws"},{"kind":"!"},{"kind":"ws"},{"kind":"??"},{"kind":"eof"}]') {
|
|
@@ -1113,37 +976,175 @@ export const proof = {
|
|
|
1113
976
|
}
|
|
1114
977
|
},
|
|
1115
978
|
],
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
979
|
+
comments: [
|
|
980
|
+
() => {
|
|
981
|
+
const result = tokenizeString('//singleline comment');
|
|
982
|
+
if (result !== '[{"kind":"//","value":"singleline comment"},{"kind":"eof"}]') {
|
|
983
|
+
throw result;
|
|
984
|
+
}
|
|
985
|
+
},
|
|
986
|
+
() => {
|
|
987
|
+
const result = tokenizeString('true//singleline comment\nfalse');
|
|
988
|
+
if (result !== '[{"kind":"true"},{"kind":"//","value":"singleline comment"},{"kind":"nl"},{"kind":"false"},{"kind":"eof"}]') {
|
|
989
|
+
throw result;
|
|
990
|
+
}
|
|
991
|
+
},
|
|
992
|
+
() => {
|
|
993
|
+
const result = tokenizeString('/* multiline comment */');
|
|
994
|
+
if (result !== '[{"kind":"/*","value":" multiline comment "},{"kind":"eof"}]') {
|
|
995
|
+
throw result;
|
|
996
|
+
}
|
|
997
|
+
},
|
|
998
|
+
() => {
|
|
999
|
+
const result = tokenizeString('/* multiline comment *');
|
|
1000
|
+
assertEq(result, 'error');
|
|
1001
|
+
},
|
|
1002
|
+
() => {
|
|
1003
|
+
const result = tokenizeString('/* multiline comment ');
|
|
1004
|
+
assertEq(result, 'error');
|
|
1005
|
+
},
|
|
1006
|
+
() => {
|
|
1007
|
+
const result = tokenizeString('/* multiline comment \n * **/');
|
|
1008
|
+
if (result !== '[{"kind":"/*","value":" multiline comment \\n * *"},{"kind":"nl"},{"kind":"eof"}]') {
|
|
1009
|
+
throw result;
|
|
1010
|
+
}
|
|
1011
|
+
},
|
|
1012
|
+
() => {
|
|
1013
|
+
const result = tokenizeString('/* multiline comment *\n * **/');
|
|
1014
|
+
if (result !== '[{"kind":"/*","value":" multiline comment *\\n * *"},{"kind":"nl"},{"kind":"eof"}]') {
|
|
1015
|
+
throw result;
|
|
1016
|
+
}
|
|
1017
|
+
},
|
|
1018
|
+
],
|
|
1019
|
+
metadata: [
|
|
1020
|
+
() => {
|
|
1021
|
+
const result = toArray(tokenizeJs(stringToList(''))('a.js'));
|
|
1022
|
+
assertEq(JSON.stringify(result), '[{"token":{"kind":"eof"},"metadata":{"path":"a.js","line":1,"column":1}}]');
|
|
1023
|
+
},
|
|
1024
|
+
() => {
|
|
1025
|
+
const result = toArray(tokenizeJs(stringToList('true'))('a.js'));
|
|
1026
|
+
assertEq(JSON.stringify(result), '[{"token":{"kind":"true"},"metadata":{"path":"a.js","line":1,"column":1}},{"token":{"kind":"eof"},"metadata":{"path":"a.js","line":1,"column":5}}]');
|
|
1027
|
+
},
|
|
1028
|
+
() => {
|
|
1029
|
+
const result = toArray(tokenizeJs(stringToList('true false'))('a.js'));
|
|
1030
|
+
assertEq(JSON.stringify(result), '[{"token":{"kind":"true"},"metadata":{"path":"a.js","line":1,"column":1}},{"token":{"kind":"ws"},"metadata":{"path":"a.js","line":1,"column":5}},{"token":{"kind":"false"},"metadata":{"path":"a.js","line":1,"column":6}},{"token":{"kind":"eof"},"metadata":{"path":"a.js","line":1,"column":11}}]');
|
|
1031
|
+
},
|
|
1032
|
+
() => {
|
|
1033
|
+
// a lone \n collapses into a single nl token, but line/column still advance
|
|
1034
|
+
// correctly for whatever comes after it
|
|
1035
|
+
const result = toArray(tokenizeJs(stringToList('a\nb'))('a.js'));
|
|
1036
|
+
assertEq(JSON.stringify(result), '[{"token":{"kind":"id","value":"a"},"metadata":{"path":"a.js","line":1,"column":1}},{"token":{"kind":"nl"},"metadata":{"path":"a.js","line":1,"column":2}},{"token":{"kind":"id","value":"b"},"metadata":{"path":"a.js","line":2,"column":1}},{"token":{"kind":"eof"},"metadata":{"path":"a.js","line":2,"column":2}}]');
|
|
1037
|
+
},
|
|
1038
|
+
() => {
|
|
1039
|
+
// two consecutive newlines still collapse into one nl token, but line still
|
|
1040
|
+
// advances by two for the token after them
|
|
1041
|
+
const result = toArray(tokenizeJs(stringToList('a\n\nb'))('a.js'));
|
|
1042
|
+
assertEq(JSON.stringify(result), '[{"token":{"kind":"id","value":"a"},"metadata":{"path":"a.js","line":1,"column":1}},{"token":{"kind":"nl"},"metadata":{"path":"a.js","line":1,"column":2}},{"token":{"kind":"id","value":"b"},"metadata":{"path":"a.js","line":3,"column":1}},{"token":{"kind":"eof"},"metadata":{"path":"a.js","line":3,"column":2}}]');
|
|
1043
|
+
},
|
|
1044
|
+
() => {
|
|
1045
|
+
// position after a multi-line block comment resumes on the comment's closing line
|
|
1046
|
+
const result = toArray(tokenizeJs(stringToList('/* c\n */ x'))('a.js'));
|
|
1047
|
+
assertEq(JSON.stringify(result), '[{"token":{"kind":"/*","value":" c\\n "},"metadata":{"path":"a.js","line":1,"column":1}},{"token":{"kind":"nl"},"metadata":{"path":"a.js","line":1,"column":1}},{"token":{"kind":"ws"},"metadata":{"path":"a.js","line":2,"column":4}},{"token":{"kind":"id","value":"x"},"metadata":{"path":"a.js","line":2,"column":5}},{"token":{"kind":"eof"},"metadata":{"path":"a.js","line":2,"column":6}}]');
|
|
1048
|
+
},
|
|
1049
|
+
() => {
|
|
1050
|
+
const result = toArray(tokenizeJs(stringToList('"unterminated'))('a.js'));
|
|
1051
|
+
assertEq(JSON.stringify(result), '[{"token":{"kind":"error","message":"invalid token"},"metadata":{"path":"a.js","line":1,"column":1}}]');
|
|
1052
|
+
},
|
|
1053
|
+
() => {
|
|
1054
|
+
// position points at the poisoning trailing char ('0'), not the start of input
|
|
1055
|
+
const result = toArray(tokenizeJs(stringToList('00'))('a.js'));
|
|
1056
|
+
assertEq(JSON.stringify(result), '[{"token":{"kind":"error","message":"invalid token"},"metadata":{"path":"a.js","line":1,"column":2}}]');
|
|
1057
|
+
},
|
|
1058
|
+
],
|
|
1059
|
+
// DJS-level: keyword remapping and '-'-folding on top of tokenizeJs. Doesn't re-test
|
|
1060
|
+
// JS-level token shapes already covered above/elsewhere in this file.
|
|
1061
|
+
djsTokenize: [
|
|
1062
|
+
() => {
|
|
1063
|
+
// keywords other than true/false/null/undefined become plain ids
|
|
1064
|
+
const result = toArray(tokenize(stringToList('break'))(''));
|
|
1065
|
+
assertEq(stringify(result), '[{"metadata":{"column":1,"line":1,"path":""},"token":{"kind":"id","value":"break"}},{"metadata":{"column":6,"line":1,"path":""},"token":{"kind":"eof"}}]');
|
|
1066
|
+
},
|
|
1067
|
+
() => {
|
|
1068
|
+
const result = toArray(tokenize(stringToList('-10'))(''));
|
|
1069
|
+
assertEq(stringify(result), '[{"metadata":{"column":2,"line":1,"path":""},"token":{"bf":[-10n,0],"kind":"number","value":"-10"}},{"metadata":{"column":4,"line":1,"path":""},"token":{"kind":"eof"}}]');
|
|
1070
|
+
},
|
|
1071
|
+
() => {
|
|
1072
|
+
const result = toArray(tokenize(stringToList('-0'))(''));
|
|
1073
|
+
assertEq(stringify(result), '[{"metadata":{"column":2,"line":1,"path":""},"token":{"bf":[0n,0],"kind":"number","value":"-0"}},{"metadata":{"column":3,"line":1,"path":""},"token":{"kind":"eof"}}]');
|
|
1074
|
+
},
|
|
1075
|
+
() => {
|
|
1076
|
+
const result = toArray(tokenize(stringToList('-1234567890n'))(''));
|
|
1077
|
+
assertEq(stringify(result), '[{"metadata":{"column":2,"line":1,"path":""},"token":{"kind":"bigint","value":-1234567890n}},{"metadata":{"column":13,"line":1,"path":""},"token":{"kind":"eof"}}]');
|
|
1078
|
+
},
|
|
1079
|
+
() => {
|
|
1080
|
+
// '-' followed by '-': one error, stays in minus-state waiting for what follows
|
|
1081
|
+
const result = toArray(tokenize(stringToList('--'))(''));
|
|
1082
|
+
assertEq(stringify(result), '[{"metadata":{"column":1,"line":1,"path":""},"token":{"kind":"error","message":"invalid token"}},{"metadata":{"column":3,"line":1,"path":""},"token":{"kind":"eof"}}]');
|
|
1083
|
+
},
|
|
1084
|
+
() => {
|
|
1085
|
+
const result = toArray(tokenize(stringToList('---'))(''));
|
|
1086
|
+
assertEq(stringify(result), '[{"metadata":{"column":1,"line":1,"path":""},"token":{"kind":"error","message":"invalid token"}},{"metadata":{"column":4,"line":1,"path":""},"token":{"kind":"error","message":"invalid token"}},{"metadata":{"column":4,"line":1,"path":""},"token":{"kind":"eof"}}]');
|
|
1087
|
+
},
|
|
1088
|
+
() => {
|
|
1089
|
+
// dangling '-' at eof
|
|
1090
|
+
const result = toArray(tokenize(stringToList('-'))(''));
|
|
1091
|
+
assertEq(stringify(result), '[{"metadata":{"column":2,"line":1,"path":""},"token":{"kind":"error","message":"invalid token"}},{"metadata":{"column":2,"line":1,"path":""},"token":{"kind":"eof"}}]');
|
|
1092
|
+
},
|
|
1093
|
+
() => {
|
|
1094
|
+
const result = toArray(tokenize(stringToList('[-1234567890n]'))(''));
|
|
1095
|
+
assertEq(stringify(result), '[{"metadata":{"column":1,"line":1,"path":""},"token":{"kind":"["}},{"metadata":{"column":3,"line":1,"path":""},"token":{"kind":"bigint","value":-1234567890n}},{"metadata":{"column":14,"line":1,"path":""},"token":{"kind":"]"}},{"metadata":{"column":15,"line":1,"path":""},"token":{"kind":"eof"}}]');
|
|
1096
|
+
},
|
|
1097
|
+
() => {
|
|
1098
|
+
// grammar-level tokenizer error position flows through the DJS wrapper unchanged
|
|
1099
|
+
const result = toArray(tokenize(stringToList('00'))(''));
|
|
1100
|
+
assertEq(stringify(result), '[{"metadata":{"column":2,"line":1,"path":""},"token":{"kind":"error","message":"invalid token"}}]');
|
|
1101
|
+
},
|
|
1102
|
+
],
|
|
1103
|
+
// Regression coverage for large inputs: both a file with many short tokens and a
|
|
1104
|
+
// single very long token used to overflow the JS call stack, because fjs/bnf/descent's
|
|
1105
|
+
// matcher recursed once per grammar step. It now runs on an explicit frame stack, so
|
|
1106
|
+
// the whole-file jsGrammar() match is safe at any input length.
|
|
1107
|
+
largeInputs: [
|
|
1108
|
+
() => {
|
|
1109
|
+
// many short whitespace tokens: the reported repro (`' '.repeat(5000)`)
|
|
1110
|
+
const result = tokenizeString(' '.repeat(5000));
|
|
1111
|
+
assertEq(result, '[{"kind":"ws"},{"kind":"eof"}]');
|
|
1112
|
+
},
|
|
1113
|
+
() => {
|
|
1114
|
+
// many distinct short tokens, well past the ~1000-1500 token crash threshold
|
|
1115
|
+
// the old whole-file recursive match hit for this shape
|
|
1116
|
+
const src = Array.from({ length: 3000 }, (_, i) => `a${i % 10}`).join(' ');
|
|
1117
|
+
const result = tokenizeString(src);
|
|
1118
|
+
assert(result !== 'error', result);
|
|
1119
|
+
const parsed = JSON.parse(result);
|
|
1120
|
+
// 3000 ids + 2999 separating ws + a trailing eof token
|
|
1121
|
+
assertEq(parsed.length, 3000 + 2999 + 1);
|
|
1122
|
+
},
|
|
1123
|
+
() => {
|
|
1124
|
+
// same many-short-tokens shape through the metadata-aware entry point
|
|
1125
|
+
const src = 'x '.repeat(3000);
|
|
1126
|
+
const result = toArray(tokenizeJs(stringToList(src))('a.js'));
|
|
1127
|
+
assertEq(result.length, 3000 * 2 + 1);
|
|
1128
|
+
},
|
|
1129
|
+
() => {
|
|
1130
|
+
// a single long token: a 5 KB string literal — overflows unless the descent
|
|
1131
|
+
// matcher itself is iterative
|
|
1132
|
+
const value = 'a'.repeat(5000);
|
|
1133
|
+
const result = tokenizeString(`"${value}"`);
|
|
1134
|
+
assertEq(result, `[{"kind":"string","value":"${value}"},{"kind":"eof"}]`);
|
|
1135
|
+
},
|
|
1136
|
+
() => {
|
|
1137
|
+
// a single long token via the hand-written recursive multilineContent rule:
|
|
1138
|
+
// a 20 KB block comment (the size the pre-grammar tokenizer handled)
|
|
1139
|
+
const value = 'x'.repeat(20000);
|
|
1140
|
+
const result = tokenizeString(`/*${value}*/`);
|
|
1141
|
+
assertEq(result, `[{"kind":"/*","value":"${value}"},{"kind":"eof"}]`);
|
|
1142
|
+
},
|
|
1143
|
+
() => {
|
|
1144
|
+
// a single long identifier (repeat0Plus(idChar) inside one token match)
|
|
1145
|
+
const value = 'x'.repeat(10000);
|
|
1146
|
+
const result = tokenizeString(value);
|
|
1147
|
+
assertEq(result, `[{"kind":"id","value":"${value}"},{"kind":"eof"}]`);
|
|
1148
|
+
},
|
|
1149
|
+
],
|
|
1149
1150
|
};
|