functionalscript 0.45.0 → 0.46.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/fjs/asn.1/module.f.mjs +8 -1
- package/fjs/asn.1/proof.f.d.mts +10 -0
- package/fjs/asn.1/proof.f.mjs +16 -0
- package/fjs/basen/base128/module.f.mjs +22 -5
- 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 -3
- package/fjs/bnf/data/types.d.ts +20 -2
- package/fjs/bnf/descent/module.f.d.mts +28 -14
- package/fjs/bnf/descent/module.f.mjs +122 -77
- package/fjs/bnf/descent/proof.f.d.mts +2 -0
- package/fjs/bnf/descent/proof.f.mjs +117 -31
- package/fjs/bnf/descent/types.d.ts +12 -14
- package/fjs/bnf/ll1/module.f.d.mts +64 -22
- package/fjs/bnf/ll1/module.f.mjs +214 -154
- package/fjs/bnf/ll1/proof.f.d.mts +15 -2
- package/fjs/bnf/ll1/proof.f.mjs +323 -149
- package/fjs/bnf/ll1/types.d.ts +16 -24
- 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/testlib.f.d.mts +31 -0
- package/fjs/bnf/testlib.f.mjs +80 -0
- 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 +1 -3
- package/fjs/cas/cli/proof.f.mjs +44 -33
- package/fjs/cas/evo/module.f.d.mts +64 -18
- package/fjs/cas/evo/module.f.mjs +148 -70
- package/fjs/cas/evo/proof.f.d.mts +10 -1
- package/fjs/cas/evo/proof.f.mjs +305 -223
- package/fjs/cas/evo/types.d.ts +45 -9
- package/fjs/cas/module.f.d.mts +18 -32
- package/fjs/cas/module.f.mjs +129 -128
- 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/config/module.f.d.mts +2 -2
- package/fjs/ci/config/module.f.mjs +2 -2
- 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.mjs +2 -2
- package/fjs/ci/proof.f.mjs +9 -5
- package/fjs/cli/module.f.d.mts +4 -6
- package/fjs/cli/module.f.mjs +4 -8
- package/fjs/cli/proof.f.mjs +17 -16
- package/fjs/cli/types.d.ts +2 -3
- package/fjs/common/monoid/types.d.ts +1 -1
- package/fjs/crypto/hmac/module.f.mjs +2 -2
- package/fjs/crypto/sha2/module.f.mjs +3 -1
- package/fjs/crypto/sha2/proof.f.d.mts +1 -0
- package/fjs/crypto/sha2/proof.f.mjs +24 -0
- package/fjs/crypto/sha2/types.d.ts +11 -0
- package/fjs/crypto/sign/module.f.mjs +2 -2
- package/fjs/dev/module.f.d.mts +13 -4
- package/fjs/dev/module.f.mjs +56 -27
- package/fjs/dev/update/module.f.d.mts +9 -4
- package/fjs/dev/update/module.f.mjs +14 -10
- package/fjs/dev/update/proof.f.d.mts +1 -3
- package/fjs/dev/update/proof.f.mjs +10 -5
- 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 +13 -3
- package/fjs/djs/parser/module.f.mjs +117 -16
- package/fjs/djs/parser/proof.f.d.mts +5 -1
- package/fjs/djs/parser/proof.f.mjs +274 -12
- package/fjs/djs/parser/types.d.ts +7 -1
- package/fjs/djs/proof.f.d.mts +18 -2
- package/fjs/djs/proof.f.mjs +187 -12
- package/fjs/djs/serializer/module.f.d.mts +25 -8
- package/fjs/djs/serializer/module.f.mjs +61 -15
- 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 +99 -60
- package/fjs/djs/tokenizer/proof.f.d.mts +1 -1
- package/fjs/djs/tokenizer/proof.f.mjs +74 -67
- package/fjs/djs/transpiler/module.f.d.mts +12 -7
- package/fjs/djs/transpiler/module.f.mjs +82 -56
- package/fjs/djs/transpiler/types.d.ts +7 -3
- package/fjs/djs/types.d.ts +7 -1
- package/fjs/effects/list/module.f.d.mts +14 -11
- package/fjs/effects/list/module.f.mjs +13 -11
- package/fjs/effects/list/types.d.ts +27 -7
- package/fjs/effects/memory/module.f.d.mts +2 -1
- package/fjs/effects/memory/module.f.mjs +3 -4
- package/fjs/effects/memory/proof.f.mjs +13 -7
- package/fjs/effects/memory/types.d.ts +4 -3
- package/fjs/effects/mock/module.f.d.mts +20 -4
- package/fjs/effects/mock/module.f.mjs +37 -5
- package/fjs/effects/mock/types.d.ts +10 -1
- package/fjs/effects/module.d.mts +4 -2
- package/fjs/effects/module.f.d.mts +466 -280
- package/fjs/effects/module.f.mjs +537 -299
- package/fjs/effects/module.mjs +2 -1
- package/fjs/effects/node/memory/module.d.mts +4 -2
- package/fjs/effects/node/memory/module.mjs +6 -3
- package/fjs/effects/node/memory/proof.mjs +10 -4
- package/fjs/effects/node/module.d.mts +4 -3
- package/fjs/effects/node/module.f.d.mts +168 -33
- package/fjs/effects/node/module.f.mjs +256 -52
- package/fjs/effects/node/module.mjs +57 -34
- 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 +18 -4
- package/fjs/effects/node/virtual/module.f.mjs +110 -68
- package/fjs/effects/node/virtual/proof.f.d.mts +28 -2
- package/fjs/effects/node/virtual/proof.f.mjs +190 -9
- package/fjs/effects/proof.f.d.mts +69 -37
- package/fjs/effects/proof.f.mjs +410 -130
- package/fjs/effects/types.d.ts +161 -33
- package/fjs/emergent_testing/module.f.d.mts +19 -12
- package/fjs/emergent_testing/module.f.mjs +93 -33
- package/fjs/emergent_testing/proof.f.d.mts +21 -7
- package/fjs/emergent_testing/proof.f.mjs +166 -32
- package/fjs/emergent_testing/types.d.ts +22 -4
- package/fjs/fsm/module.f.d.mts +14 -4
- package/fjs/fsm/module.f.mjs +54 -37
- package/fjs/fsm/proof.f.d.mts +2 -0
- package/fjs/fsm/proof.f.mjs +83 -114
- package/fjs/js/keywords/module.f.d.mts +52 -0
- package/fjs/js/keywords/module.f.mjs +72 -0
- package/fjs/js/keywords/proof.f.d.mts +3 -0
- package/fjs/js/keywords/proof.f.mjs +13 -0
- package/fjs/js/tokenizer/module.f.d.mts +26 -6
- package/fjs/js/tokenizer/module.f.mjs +145 -159
- 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 +4 -4
- package/fjs/mcp/module.f.mjs +6 -6
- package/fjs/mcp/proof.f.d.mts +5 -3
- package/fjs/mcp/proof.f.mjs +112 -46
- package/fjs/media/html/module.f.mjs +1 -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 +114 -70
- 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 +33 -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.mjs +9 -9
- package/fjs/media/json/schema/module.f.mjs +3 -13
- package/fjs/media/json/schema/proof.f.d.mts +0 -1
- package/fjs/media/json/schema/proof.f.mjs +1 -2
- package/fjs/media/json/serializer/module.f.d.mts +32 -1
- package/fjs/media/json/serializer/module.f.mjs +64 -2
- package/fjs/media/json/tokenizer/module.f.mjs +7 -3
- 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/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 +78 -7
- package/fjs/media/revision/module.f.mjs +119 -12
- package/fjs/media/revision/proof.f.d.mts +10 -0
- package/fjs/media/revision/proof.f.mjs +88 -0
- package/fjs/media/revision/types.d.ts +34 -5
- package/fjs/media/type/module.f.d.mts +33 -15
- package/fjs/media/type/module.f.mjs +35 -29
- package/fjs/media/type/proof.f.d.mts +2 -1
- package/fjs/media/type/proof.f.mjs +30 -10
- package/fjs/module.f.mjs +29 -8
- 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/proof.f.d.mts +3 -3
- package/fjs/proof.f.mjs +36 -10
- package/fjs/protocol/json_rpc/module.f.d.mts +2 -2
- package/fjs/protocol/json_rpc/module.f.mjs +3 -3
- package/fjs/protocol/json_rpc/proof.f.mjs +4 -4
- 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 +13 -4
- package/fjs/protocol/mcp/proof.f.mjs +193 -61
- package/fjs/protocol/mcp/stdio/module.f.d.mts +15 -7
- package/fjs/protocol/mcp/stdio/module.f.mjs +38 -25
- package/fjs/protocol/mcp/stdio/proof.f.d.mts +4 -2
- package/fjs/protocol/mcp/stdio/proof.f.mjs +45 -12
- package/fjs/protocol/mcp/stdio/types.d.ts +1 -1
- package/fjs/protocol/mcp/types.d.ts +17 -6
- package/fjs/sul/id/module.f.d.mts +0 -1
- package/fjs/sul/id/module.f.mjs +2 -3
- package/fjs/sul/level/hash/module.f.mjs +2 -1
- package/fjs/sul/level/hash/proof.f.mjs +2 -2
- package/fjs/sul/module.f.mjs +18 -13
- package/fjs/text/code_point/module.f.d.mts +8 -0
- package/fjs/text/code_point/module.f.mjs +8 -1
- package/fjs/text/code_point/proof.f.d.mts +1 -0
- package/fjs/text/code_point/proof.f.mjs +11 -0
- package/fjs/text/sgr/module.f.d.mts +4 -6
- package/fjs/text/sgr/module.f.mjs +6 -7
- package/fjs/text/utf16/module.f.mjs +7 -2
- package/fjs/text/utf16/proof.f.mjs +3 -3
- package/fjs/text/utf8/module.f.mjs +4 -2
- package/fjs/types/array/module.f.mjs +14 -2
- package/fjs/types/bit_vec/module.f.d.mts +0 -2
- package/fjs/types/bit_vec/module.f.mjs +46 -32
- package/fjs/types/bit_vec/proof.f.mjs +2 -2
- package/fjs/types/btree/remove/module.f.mjs +1 -1
- package/fjs/types/btree/set/module.f.mjs +9 -11
- package/fjs/types/btree/set/proof.f.mjs +12 -0
- package/fjs/types/byte_set/module.f.d.mts +11 -4
- package/fjs/types/byte_set/module.f.mjs +14 -6
- package/fjs/types/byte_set/proof.f.mjs +7 -7
- package/fjs/types/function/compare/module.f.mjs +10 -3
- package/fjs/types/list/module.f.d.mts +1 -1
- package/fjs/types/list/module.f.mjs +1 -1
- package/fjs/types/nullable/module.f.d.mts +18 -4
- package/fjs/types/nullable/module.f.mjs +21 -4
- package/fjs/types/nullable/proof.f.d.mts +4 -0
- package/fjs/types/nullable/proof.f.mjs +15 -0
- package/fjs/types/object/module.f.d.mts +12 -2
- package/fjs/types/object/module.f.mjs +11 -1
- package/fjs/types/patricia_trie/module.f.mjs +26 -11
- package/fjs/types/result/module.f.d.mts +3 -3
- package/fjs/types/result/module.f.mjs +3 -3
- package/fjs/types/rtti/common/module.f.d.mts +25 -28
- package/fjs/types/rtti/common/module.f.mjs +36 -32
- package/fjs/types/rtti/common/proof.f.mjs +5 -5
- package/fjs/types/rtti/data/module.f.d.mts +14 -0
- package/fjs/types/rtti/data/module.f.mjs +25 -2
- package/fjs/types/rtti/data/proof.f.d.mts +1 -0
- package/fjs/types/rtti/data/proof.f.mjs +25 -2
- package/fjs/types/rtti/parse/module.f.d.mts +24 -14
- package/fjs/types/rtti/parse/module.f.mjs +37 -28
- package/fjs/types/rtti/parse/proof.f.d.mts +3 -2
- package/fjs/types/rtti/parse/proof.f.mjs +33 -14
- package/fjs/types/rtti/proof.f.mjs +3 -1
- package/fjs/types/rtti/ts/module.f.mjs +13 -17
- package/fjs/types/rtti/ts/types.d.ts +14 -1
- package/fjs/types/rtti/validate/module.f.d.mts +81 -19
- package/fjs/types/rtti/validate/module.f.mjs +107 -61
- package/fjs/types/rtti/validate/proof.f.d.mts +13 -10
- package/fjs/types/rtti/validate/proof.f.mjs +186 -197
- package/fjs/types/sorted_set/module.f.d.mts +18 -0
- package/fjs/types/sorted_set/module.f.mjs +22 -0
- package/fjs/types/sorted_set/proof.f.d.mts +1 -0
- package/fjs/types/sorted_set/proof.f.mjs +16 -1
- package/fjs/types/uint8array/module.f.d.mts +1 -1
- package/fjs/types/uint8array/module.f.mjs +1 -1
- package/fjs/website/module.f.d.mts +3 -3
- package/fjs/website/module.f.mjs +4 -7
- package/fjs/website/proof.f.mjs +2 -1
- package/package.json +2 -2
- package/fjs/dev/package_json/module.f.d.mts +0 -39
- package/fjs/dev/package_json/module.f.mjs +0 -40
- package/fjs/dev/package_json/proof.f.d.mts +0 -6
- package/fjs/dev/package_json/proof.f.mjs +0 -32
- package/fjs/effects/eff/module.f.d.mts +0 -20
- package/fjs/effects/eff/module.f.mjs +0 -70
- package/fjs/effects/eff/proof.f.d.mts +0 -15
- package/fjs/effects/eff/proof.f.mjs +0 -69
- package/fjs/effects/eff/types.d.ts +0 -71
- package/fjs/types/rtti/validate/types.d.ts +0 -6
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @import { Unknown } from '../types.ts'
|
|
3
2
|
*/
|
|
4
3
|
|
|
5
|
-
import {
|
|
4
|
+
import { isRepeat, toData } from '../../bnf/data/module.f.mjs'
|
|
6
5
|
import { stringToCodePointList, stringToList } from '../../text/utf16/module.f.mjs'
|
|
7
6
|
import { toArray } from '../../types/list/module.f.mjs'
|
|
8
|
-
import { jsGrammar, tokenizeString, descentParserCpOnly, tokenizeJs, tokenize } from './module.f.mjs'
|
|
7
|
+
import { jsGrammar, jsMatcher, tokenizeString, descentParserCpOnly, tokenizeJs, tokenize } from './module.f.mjs'
|
|
9
8
|
import { assert, assertEq } from '../../asserts/module.f.mjs'
|
|
10
9
|
import { stringifyAsTree } from '../serializer/module.f.mjs'
|
|
11
10
|
import { sort } from '../../types/object/module.f.mjs'
|
|
@@ -25,13 +24,21 @@ const errorAt = s => {
|
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
export const proof = {
|
|
27
|
+
// The whole-file grammar is one repetition of a token, and `toData` records
|
|
28
|
+
// that rather than leaving it as the right-recursive variant `repeat0Plus`
|
|
29
|
+
// builds — which is why the tokenizer reads its entry name from `jsMatcher`
|
|
30
|
+
// instead of naming a rule: the rules that encoded the repetition are gone.
|
|
31
|
+
jsGrammar: () => {
|
|
32
|
+
const [ruleSet, entry] = toData(jsGrammar())
|
|
33
|
+
assert(isRepeat(ruleSet[entry]), JSON.stringify([ruleSet[entry], entry]))
|
|
34
|
+
},
|
|
28
35
|
isValid: [() => {
|
|
29
|
-
const m =
|
|
36
|
+
const [m, entry] = jsMatcher()
|
|
30
37
|
|
|
31
38
|
/** @type {(s: string, expected: boolean) => void} */
|
|
32
39
|
const expect = (s, expected) => {
|
|
33
40
|
const cp = toArray(stringToCodePointList(s))
|
|
34
|
-
const mr = descentParserCpOnly(m,
|
|
41
|
+
const mr = descentParserCpOnly(m, entry, cp)
|
|
35
42
|
const success = mr.success && mr.idx === cp.length
|
|
36
43
|
assertEq(success, expected, JSON.stringify([s, mr]))
|
|
37
44
|
}
|
|
@@ -67,121 +74,121 @@ export const proof = {
|
|
|
67
74
|
],
|
|
68
75
|
tokenizer: [
|
|
69
76
|
() => {
|
|
70
|
-
const m =
|
|
77
|
+
const [m, entry] = jsMatcher()
|
|
71
78
|
const cp = toArray(stringToCodePointList('tr'))
|
|
72
|
-
const mr = descentParserCpOnly(m,
|
|
79
|
+
const mr = descentParserCpOnly(m, entry, cp)
|
|
73
80
|
const seq = mr.ast.sequence[0]
|
|
74
81
|
assert(!(seq instanceof Array), JSON.stringify(mr))
|
|
75
82
|
assertEq(seq.tag, 'id', JSON.stringify(mr))
|
|
76
83
|
},
|
|
77
84
|
() => {
|
|
78
|
-
const m =
|
|
85
|
+
const [m, entry] = jsMatcher()
|
|
79
86
|
const cp = toArray(stringToCodePointList('"tr"'))
|
|
80
|
-
const mr = descentParserCpOnly(m,
|
|
87
|
+
const mr = descentParserCpOnly(m, entry, cp)
|
|
81
88
|
const seq = mr.ast.sequence[0]
|
|
82
89
|
assert(!(seq instanceof Array), JSON.stringify(mr))
|
|
83
90
|
assertEq(seq.tag, 'string', JSON.stringify(mr))
|
|
84
91
|
},
|
|
85
92
|
() => {
|
|
86
|
-
const m =
|
|
93
|
+
const [m, entry] = jsMatcher()
|
|
87
94
|
const cp = toArray(stringToCodePointList('56.7e+5'))
|
|
88
|
-
const mr = descentParserCpOnly(m,
|
|
95
|
+
const mr = descentParserCpOnly(m, entry, cp)
|
|
89
96
|
const seq = mr.ast.sequence[0]
|
|
90
97
|
assert(!(seq instanceof Array), JSON.stringify(mr))
|
|
91
98
|
assertEq(seq.tag, 'number', JSON.stringify(mr))
|
|
92
99
|
},
|
|
93
100
|
() => {
|
|
94
|
-
const m =
|
|
101
|
+
const [m, entry] = jsMatcher()
|
|
95
102
|
const cp = toArray(stringToCodePointList('56n'))
|
|
96
|
-
const mr = descentParserCpOnly(m,
|
|
103
|
+
const mr = descentParserCpOnly(m, entry, cp)
|
|
97
104
|
const seq = mr.ast.sequence[0]
|
|
98
105
|
assert(!(seq instanceof Array), JSON.stringify(mr))
|
|
99
106
|
assertEq(seq.tag, 'number', JSON.stringify(mr))
|
|
100
107
|
},
|
|
101
108
|
() => {
|
|
102
|
-
const m =
|
|
109
|
+
const [m, entry] = jsMatcher()
|
|
103
110
|
const cp = toArray(stringToCodePointList('*'))
|
|
104
|
-
const mr = descentParserCpOnly(m,
|
|
111
|
+
const mr = descentParserCpOnly(m, entry, cp)
|
|
105
112
|
const seq = mr.ast.sequence[0]
|
|
106
113
|
assert(!(seq instanceof Array), JSON.stringify(mr))
|
|
107
114
|
assertEq(seq.tag, '*', JSON.stringify(mr))
|
|
108
115
|
},
|
|
109
116
|
() => {
|
|
110
|
-
const m =
|
|
117
|
+
const [m, entry] = jsMatcher()
|
|
111
118
|
const cp = toArray(stringToCodePointList('**'))
|
|
112
|
-
const mr = descentParserCpOnly(m,
|
|
119
|
+
const mr = descentParserCpOnly(m, entry, cp)
|
|
113
120
|
const seq = mr.ast.sequence[0]
|
|
114
121
|
assert(!(seq instanceof Array), JSON.stringify(mr))
|
|
115
122
|
assertEq(seq.tag, '**', JSON.stringify(mr))
|
|
116
123
|
},
|
|
117
124
|
() => {
|
|
118
|
-
const m =
|
|
125
|
+
const [m, entry] = jsMatcher()
|
|
119
126
|
const cp = toArray(stringToCodePointList('=>'))
|
|
120
|
-
const mr = descentParserCpOnly(m,
|
|
127
|
+
const mr = descentParserCpOnly(m, entry, cp)
|
|
121
128
|
const seq = mr.ast.sequence[0]
|
|
122
129
|
assert(!(seq instanceof Array), JSON.stringify(mr))
|
|
123
130
|
assertEq(seq.tag, '=>', JSON.stringify(mr))
|
|
124
131
|
},
|
|
125
132
|
() => {
|
|
126
|
-
const m =
|
|
133
|
+
const [m, entry] = jsMatcher()
|
|
127
134
|
const cp = toArray(stringToCodePointList('=='))
|
|
128
|
-
const mr = descentParserCpOnly(m,
|
|
135
|
+
const mr = descentParserCpOnly(m, entry, cp)
|
|
129
136
|
const seq = mr.ast.sequence[0]
|
|
130
137
|
assert(!(seq instanceof Array), JSON.stringify(mr))
|
|
131
138
|
assert(!(seq.tag !== '=='), JSON.stringify(mr))
|
|
132
139
|
},
|
|
133
140
|
() => {
|
|
134
|
-
const m =
|
|
141
|
+
const [m, entry] = jsMatcher()
|
|
135
142
|
const cp = toArray(stringToCodePointList('==='))
|
|
136
|
-
const mr = descentParserCpOnly(m,
|
|
143
|
+
const mr = descentParserCpOnly(m, entry, cp)
|
|
137
144
|
const seq = mr.ast.sequence[0]
|
|
138
145
|
assert(!(seq instanceof Array), JSON.stringify(mr))
|
|
139
146
|
assert(!(seq.tag !== '==='), JSON.stringify(mr))
|
|
140
147
|
},
|
|
141
148
|
() => {
|
|
142
|
-
const m =
|
|
149
|
+
const [m, entry] = jsMatcher()
|
|
143
150
|
const cp = toArray(stringToCodePointList('='))
|
|
144
|
-
const mr = descentParserCpOnly(m,
|
|
151
|
+
const mr = descentParserCpOnly(m, entry, cp)
|
|
145
152
|
const seq = mr.ast.sequence[0]
|
|
146
153
|
assert(!(seq instanceof Array), JSON.stringify(mr))
|
|
147
154
|
assertEq(seq.tag, '=', JSON.stringify(mr))
|
|
148
155
|
},
|
|
149
156
|
() => {
|
|
150
|
-
const m =
|
|
157
|
+
const [m, entry] = jsMatcher()
|
|
151
158
|
const cp = toArray(stringToCodePointList(' '))
|
|
152
|
-
const mr = descentParserCpOnly(m,
|
|
159
|
+
const mr = descentParserCpOnly(m, entry, cp)
|
|
153
160
|
const seq = mr.ast.sequence[0]
|
|
154
161
|
assert(!(seq instanceof Array), JSON.stringify(mr))
|
|
155
162
|
assertEq(seq.tag, ' ', JSON.stringify(mr))
|
|
156
163
|
},
|
|
157
164
|
() => {
|
|
158
|
-
const m =
|
|
165
|
+
const [m, entry] = jsMatcher()
|
|
159
166
|
const cp = toArray(stringToCodePointList('\n'))
|
|
160
|
-
const mr = descentParserCpOnly(m,
|
|
167
|
+
const mr = descentParserCpOnly(m, entry, cp)
|
|
161
168
|
const seq = mr.ast.sequence[0]
|
|
162
169
|
assert(!(seq instanceof Array), JSON.stringify(mr))
|
|
163
170
|
assertEq(seq.tag, '\n', JSON.stringify(mr))
|
|
164
171
|
},
|
|
165
172
|
() => {
|
|
166
|
-
const m =
|
|
173
|
+
const [m, entry] = jsMatcher()
|
|
167
174
|
const cp = toArray(stringToCodePointList('/\n'))
|
|
168
|
-
const mr = descentParserCpOnly(m,
|
|
175
|
+
const mr = descentParserCpOnly(m, entry, cp)
|
|
169
176
|
const seq = mr.ast.sequence[0]
|
|
170
177
|
assert(!(seq instanceof Array), JSON.stringify(mr))
|
|
171
178
|
assertEq(seq.tag, '/', JSON.stringify(mr))
|
|
172
179
|
},
|
|
173
180
|
() => {
|
|
174
|
-
const m =
|
|
181
|
+
const [m, entry] = jsMatcher()
|
|
175
182
|
const cp = toArray(stringToCodePointList('//\n'))
|
|
176
|
-
const mr = descentParserCpOnly(m,
|
|
183
|
+
const mr = descentParserCpOnly(m, entry, cp)
|
|
177
184
|
const seq = mr.ast.sequence[0]
|
|
178
185
|
assert(!(seq instanceof Array), JSON.stringify(mr))
|
|
179
186
|
assertEq(seq.tag, 'comment', JSON.stringify(mr))
|
|
180
187
|
},
|
|
181
188
|
() => {
|
|
182
|
-
const m =
|
|
189
|
+
const [m, entry] = jsMatcher()
|
|
183
190
|
const cp = toArray(stringToCodePointList('/*1*/'))
|
|
184
|
-
const mr = descentParserCpOnly(m,
|
|
191
|
+
const mr = descentParserCpOnly(m, entry, cp)
|
|
185
192
|
const seq = mr.ast.sequence[0]
|
|
186
193
|
assert(!(seq instanceof Array), JSON.stringify(mr))
|
|
187
194
|
assertEq(seq.tag, 'comment', JSON.stringify(mr))
|
|
@@ -290,11 +297,11 @@ export const proof = {
|
|
|
290
297
|
},
|
|
291
298
|
() => {
|
|
292
299
|
const result = tokenizeString('0')
|
|
293
|
-
if (result !== '[{"
|
|
300
|
+
if (result !== '[{"kind":"number","value":"0"},{"kind":"eof"}]') { throw result }
|
|
294
301
|
},
|
|
295
302
|
() => {
|
|
296
303
|
const result = tokenizeString('[0]')
|
|
297
|
-
if (result !== '[{"kind":"["},{"
|
|
304
|
+
if (result !== '[{"kind":"["},{"kind":"number","value":"0"},{"kind":"]"},{"kind":"eof"}]') { throw result }
|
|
298
305
|
},
|
|
299
306
|
() => {
|
|
300
307
|
const result = tokenizeString('00')
|
|
@@ -306,15 +313,15 @@ export const proof = {
|
|
|
306
313
|
},
|
|
307
314
|
() => {
|
|
308
315
|
const result = tokenizeString('123456789012345678901234567890')
|
|
309
|
-
if (result !== '[{"
|
|
316
|
+
if (result !== '[{"kind":"number","value":"123456789012345678901234567890"},{"kind":"eof"}]') { throw result }
|
|
310
317
|
},
|
|
311
318
|
() => {
|
|
312
319
|
const result = tokenizeString('{90}')
|
|
313
|
-
if (result !== '[{"kind":"{"},{"
|
|
320
|
+
if (result !== '[{"kind":"{"},{"kind":"number","value":"90"},{"kind":"}"},{"kind":"eof"}]') { throw result }
|
|
314
321
|
},
|
|
315
322
|
() => {
|
|
316
323
|
const result = tokenizeString('1 2')
|
|
317
|
-
if (result !== '[{"
|
|
324
|
+
if (result !== '[{"kind":"number","value":"1"},{"kind":"ws"},{"kind":"number","value":"2"},{"kind":"eof"}]') { throw result }
|
|
318
325
|
},
|
|
319
326
|
() => {
|
|
320
327
|
const result = tokenizeString('0. 2')
|
|
@@ -322,7 +329,7 @@ export const proof = {
|
|
|
322
329
|
},
|
|
323
330
|
() => {
|
|
324
331
|
const result = tokenizeString('10-0')
|
|
325
|
-
if (result !== '[{"
|
|
332
|
+
if (result !== '[{"kind":"number","value":"10"},{"kind":"-"},{"kind":"number","value":"0"},{"kind":"eof"}]') { throw result }
|
|
326
333
|
},
|
|
327
334
|
() => {
|
|
328
335
|
const result = tokenizeString('9a:')
|
|
@@ -330,11 +337,11 @@ export const proof = {
|
|
|
330
337
|
},
|
|
331
338
|
() => {
|
|
332
339
|
const result = tokenizeString('-10')
|
|
333
|
-
if (result !== '[{"kind":"-"},{"
|
|
340
|
+
if (result !== '[{"kind":"-"},{"kind":"number","value":"10"},{"kind":"eof"}]') { throw result }
|
|
334
341
|
},
|
|
335
342
|
() => {
|
|
336
343
|
const result = tokenizeString('-0')
|
|
337
|
-
if (result !== '[{"kind":"-"},{"
|
|
344
|
+
if (result !== '[{"kind":"-"},{"kind":"number","value":"0"},{"kind":"eof"}]') { throw result }
|
|
338
345
|
},
|
|
339
346
|
() => {
|
|
340
347
|
const result = tokenizeString('-00')
|
|
@@ -342,15 +349,15 @@ export const proof = {
|
|
|
342
349
|
},
|
|
343
350
|
() => {
|
|
344
351
|
const result = tokenizeString('-.123')
|
|
345
|
-
if (result !== '[{"kind":"-"},{"kind":"."},{"
|
|
352
|
+
if (result !== '[{"kind":"-"},{"kind":"."},{"kind":"number","value":"123"},{"kind":"eof"}]') { throw result }
|
|
346
353
|
},
|
|
347
354
|
() => {
|
|
348
355
|
const result = tokenizeString('0.01')
|
|
349
|
-
if (result !== '[{"
|
|
356
|
+
if (result !== '[{"kind":"number","value":"0.01"},{"kind":"eof"}]') { throw result }
|
|
350
357
|
},
|
|
351
358
|
() => {
|
|
352
359
|
const result = tokenizeString('-0.9')
|
|
353
|
-
if (result !== '[{"kind":"-"},{"
|
|
360
|
+
if (result !== '[{"kind":"-"},{"kind":"number","value":"0.9"},{"kind":"eof"}]') { throw result }
|
|
354
361
|
},
|
|
355
362
|
() => {
|
|
356
363
|
const result = tokenizeString('-0.')
|
|
@@ -362,11 +369,11 @@ export const proof = {
|
|
|
362
369
|
},
|
|
363
370
|
() => {
|
|
364
371
|
const result = tokenizeString('12.34')
|
|
365
|
-
if (result !== '[{"
|
|
372
|
+
if (result !== '[{"kind":"number","value":"12.34"},{"kind":"eof"}]') { throw result }
|
|
366
373
|
},
|
|
367
374
|
() => {
|
|
368
375
|
const result = tokenizeString('-12.00')
|
|
369
|
-
if (result !== '[{"kind":"-"},{"
|
|
376
|
+
if (result !== '[{"kind":"-"},{"kind":"number","value":"12.00"},{"kind":"eof"}]') { throw result }
|
|
370
377
|
},
|
|
371
378
|
() => {
|
|
372
379
|
const result = tokenizeString('-12.')
|
|
@@ -378,27 +385,27 @@ export const proof = {
|
|
|
378
385
|
},
|
|
379
386
|
() => {
|
|
380
387
|
const result = tokenizeString('0e1')
|
|
381
|
-
if (result !== '[{"
|
|
388
|
+
if (result !== '[{"kind":"number","value":"0e1"},{"kind":"eof"}]') { throw result }
|
|
382
389
|
},
|
|
383
390
|
() => {
|
|
384
391
|
const result = tokenizeString('0e+2')
|
|
385
|
-
if (result !== '[{"
|
|
392
|
+
if (result !== '[{"kind":"number","value":"0e+2"},{"kind":"eof"}]') { throw result }
|
|
386
393
|
},
|
|
387
394
|
() => {
|
|
388
395
|
const result = tokenizeString('0e-0')
|
|
389
|
-
if (result !== '[{"
|
|
396
|
+
if (result !== '[{"kind":"number","value":"0e-0"},{"kind":"eof"}]') { throw result }
|
|
390
397
|
},
|
|
391
398
|
() => {
|
|
392
399
|
const result = tokenizeString('12e0000')
|
|
393
|
-
if (result !== '[{"
|
|
400
|
+
if (result !== '[{"kind":"number","value":"12e0000"},{"kind":"eof"}]') { throw result }
|
|
394
401
|
},
|
|
395
402
|
() => {
|
|
396
403
|
const result = tokenizeString('-12e-0001')
|
|
397
|
-
if (result !== '[{"kind":"-"},{"
|
|
404
|
+
if (result !== '[{"kind":"-"},{"kind":"number","value":"12e-0001"},{"kind":"eof"}]') { throw result }
|
|
398
405
|
},
|
|
399
406
|
() => {
|
|
400
407
|
const result = tokenizeString('-12.34e1234')
|
|
401
|
-
if (result !== '[{"kind":"-"},{"
|
|
408
|
+
if (result !== '[{"kind":"-"},{"kind":"number","value":"12.34e1234"},{"kind":"eof"}]') { throw result }
|
|
402
409
|
},
|
|
403
410
|
() => {
|
|
404
411
|
const result = tokenizeString('0e')
|
|
@@ -418,11 +425,11 @@ export const proof = {
|
|
|
418
425
|
},
|
|
419
426
|
() => {
|
|
420
427
|
const result = tokenizeString('123 _123')
|
|
421
|
-
if (result !== '[{"
|
|
428
|
+
if (result !== '[{"kind":"number","value":"123"},{"kind":"ws"},{"kind":"id","value":"_123"},{"kind":"eof"}]') { throw result }
|
|
422
429
|
},
|
|
423
430
|
() => {
|
|
424
431
|
const result = tokenizeString('123 $123')
|
|
425
|
-
if (result !== '[{"
|
|
432
|
+
if (result !== '[{"kind":"number","value":"123"},{"kind":"ws"},{"kind":"id","value":"$123"},{"kind":"eof"}]') { throw result }
|
|
426
433
|
},
|
|
427
434
|
() => {
|
|
428
435
|
const result = tokenizeString('123_123')
|
|
@@ -477,7 +484,7 @@ export const proof = {
|
|
|
477
484
|
},
|
|
478
485
|
() => {
|
|
479
486
|
const result = tokenizeString('1*2')
|
|
480
|
-
if (result !== '[{"
|
|
487
|
+
if (result !== '[{"kind":"number","value":"1"},{"kind":"*"},{"kind":"number","value":"2"},{"kind":"eof"}]') { throw result }
|
|
481
488
|
},
|
|
482
489
|
() => {
|
|
483
490
|
const result = tokenizeString('( )')
|
|
@@ -886,19 +893,19 @@ export const proof = {
|
|
|
886
893
|
() => {
|
|
887
894
|
// keywords other than true/false/null/undefined become plain ids
|
|
888
895
|
const result = toArray(tokenize(stringToList('break'))(''))
|
|
889
|
-
assertEq(stringify(
|
|
896
|
+
assertEq(stringify(result), '[{"metadata":{"column":1,"line":1,"path":""},"token":{"kind":"id","value":"break"}},{"metadata":{"column":6,"line":1,"path":""},"token":{"kind":"eof"}}]')
|
|
890
897
|
},
|
|
891
898
|
() => {
|
|
892
899
|
const result = toArray(tokenize(stringToList('-10'))(''))
|
|
893
|
-
assertEq(stringify(
|
|
900
|
+
assertEq(stringify(result), '[{"metadata":{"column":2,"line":1,"path":""},"token":{"kind":"number","value":"-10"}},{"metadata":{"column":4,"line":1,"path":""},"token":{"kind":"eof"}}]')
|
|
894
901
|
},
|
|
895
902
|
() => {
|
|
896
903
|
const result = toArray(tokenize(stringToList('-0'))(''))
|
|
897
|
-
assertEq(stringify(
|
|
904
|
+
assertEq(stringify(result), '[{"metadata":{"column":2,"line":1,"path":""},"token":{"kind":"number","value":"-0"}},{"metadata":{"column":3,"line":1,"path":""},"token":{"kind":"eof"}}]')
|
|
898
905
|
},
|
|
899
906
|
() => {
|
|
900
907
|
const result = toArray(tokenize(stringToList('-1234567890n'))(''))
|
|
901
|
-
assertEq(stringify(
|
|
908
|
+
assertEq(stringify(result), '[{"metadata":{"column":2,"line":1,"path":""},"token":{"kind":"bigint","value":-1234567890n}},{"metadata":{"column":13,"line":1,"path":""},"token":{"kind":"eof"}}]')
|
|
902
909
|
},
|
|
903
910
|
() => {
|
|
904
911
|
// `js/tokenizer` merges '--' into one decrement-operator token, so
|
|
@@ -906,31 +913,31 @@ export const proof = {
|
|
|
906
913
|
// it's one error straight from the default state's unknown-token
|
|
907
914
|
// fallback, mapping the whole '--' token to a single error.
|
|
908
915
|
const result = toArray(tokenize(stringToList('--'))(''))
|
|
909
|
-
assertEq(stringify(
|
|
916
|
+
assertEq(stringify(result), '[{"metadata":{"column":1,"line":1,"path":""},"token":{"kind":"error","message":"invalid token"}},{"metadata":{"column":3,"line":1,"path":""},"token":{"kind":"eof"}}]')
|
|
910
917
|
},
|
|
911
918
|
() => {
|
|
912
919
|
const result = toArray(tokenize(stringToList('---'))(''))
|
|
913
|
-
assertEq(stringify(
|
|
920
|
+
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"}}]')
|
|
914
921
|
},
|
|
915
922
|
() => {
|
|
916
923
|
// dangling '-' at eof
|
|
917
924
|
const result = toArray(tokenize(stringToList('-'))(''))
|
|
918
|
-
assertEq(stringify(
|
|
925
|
+
assertEq(stringify(result), '[{"metadata":{"column":2,"line":1,"path":""},"token":{"kind":"error","message":"invalid token"}},{"metadata":{"column":2,"line":1,"path":""},"token":{"kind":"eof"}}]')
|
|
919
926
|
},
|
|
920
927
|
() => {
|
|
921
928
|
// '-' followed by neither a number/bigint nor eof: one error for
|
|
922
929
|
// the dangling '-', then the following token maps through normally.
|
|
923
930
|
const result = toArray(tokenize(stringToList('-{'))(''))
|
|
924
|
-
assertEq(stringify(
|
|
931
|
+
assertEq(stringify(result), '[{"metadata":{"column":2,"line":1,"path":""},"token":{"kind":"error","message":"invalid token"}},{"metadata":{"column":2,"line":1,"path":""},"token":{"kind":"{"}},{"metadata":{"column":3,"line":1,"path":""},"token":{"kind":"eof"}}]')
|
|
925
932
|
},
|
|
926
933
|
() => {
|
|
927
934
|
const result = toArray(tokenize(stringToList('[-1234567890n]'))(''))
|
|
928
|
-
assertEq(stringify(
|
|
935
|
+
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"}}]')
|
|
929
936
|
},
|
|
930
937
|
() => {
|
|
931
938
|
// grammar-level tokenizer error position flows through the DJS wrapper unchanged
|
|
932
939
|
const result = toArray(tokenize(stringToList('00'))(''))
|
|
933
|
-
assertEq(stringify(
|
|
940
|
+
assertEq(stringify(result), '[{"metadata":{"column":2,"line":1,"path":""},"token":{"kind":"error","message":"invalid token"}}]')
|
|
934
941
|
},
|
|
935
942
|
],
|
|
936
943
|
// Regression coverage for large inputs: both a file with many short tokens and a
|
|
@@ -7,25 +7,30 @@
|
|
|
7
7
|
* @import { Result } from '../../types/result/types.ts'
|
|
8
8
|
* @import { ParseError } from '../parser/types.ts'
|
|
9
9
|
* @import { AstModule } from '../ast/types.ts'
|
|
10
|
+
* @import { Operation } from '../../effects/types.ts'
|
|
11
|
+
* @import { IoChannel } from '../../effects/node/types.ts'
|
|
10
12
|
* @import { Effect } from '../../effects/types.ts'
|
|
11
13
|
* @import { ReadFile } from '../../effects/node/types.ts'
|
|
12
14
|
* @import { ParseContext } from './types.ts'
|
|
13
15
|
*/
|
|
14
16
|
import type { Unknown } from '../types.ts';
|
|
15
|
-
import type { Result } from '../../types/result/types.ts';
|
|
16
17
|
import type { ParseError } from '../parser/types.ts';
|
|
17
18
|
import type { Effect } from '../../effects/types.ts';
|
|
18
19
|
import type { ReadFile } from '../../effects/node/types.ts';
|
|
19
20
|
/**
|
|
20
|
-
* Transpiles
|
|
21
|
+
* Transpiles the file at `path` into a single `Unknown` value.
|
|
21
22
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
23
|
+
* The extension names its language: a `.json` file is a JSON document, read by
|
|
24
|
+
* `fjs/media/json`, and anything else is a FunctionalScript module, whose
|
|
25
|
+
* imports are resolved recursively — each of them a module too, whatever it is
|
|
26
|
+
* called ([spec: the `__proto__` key](../../../spec/README.md#the-__proto__-key)).
|
|
25
27
|
*
|
|
26
|
-
*
|
|
28
|
+
* Returns `['ok', value]` on success, or `['error', ParseError]` on a parse
|
|
29
|
+
* failure, a missing file, or a circular dependency.
|
|
30
|
+
*
|
|
31
|
+
* @type {(path: string) => Effect<ReadFile, Unknown, ParseError>}
|
|
27
32
|
*/
|
|
28
|
-
export declare const transpile: (path: string) => Effect<ReadFile,
|
|
33
|
+
export declare const transpile: (path: string) => Effect<ReadFile, Unknown, ParseError>;
|
|
29
34
|
export declare const proof: {
|
|
30
35
|
throw: {
|
|
31
36
|
mapDjsUnresolvedImport: () => Unknown;
|