functionalscript 0.0.592 → 0.1.594
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/.github/workflows/ci.yml +3 -3
- package/README.md +1 -0
- package/com/cpp/{module.f.cjs → module.f.mjs} +22 -21
- package/com/cpp/{test.f.cjs → test.f.mjs} +2 -2
- package/com/cpp/testlib.f.mjs +9 -0
- package/com/cs/{module.f.cjs → module.f.mjs} +20 -19
- package/com/cs/{test.f.cjs → test.f.mjs} +2 -2
- package/com/cs/testlib.f.mjs +10 -0
- package/com/rust/{module.f.cjs → module.f.mjs} +37 -35
- package/com/rust/{test.f.cjs → test.f.mjs} +2 -2
- package/com/rust/testlib.f.mjs +10 -0
- package/com/test/{build.f.cjs → build.f.mjs} +6 -6
- package/com/test/{build.cjs → build.mjs} +16 -8
- package/com/types/{module.f.cjs → module.f.mjs} +9 -8
- package/com/types/{testlib.f.cjs → testlib.f.mjs} +2 -2
- package/commonjs/build/{module.f.cjs → module.f.mjs} +23 -23
- package/commonjs/build/{test.f.cjs → test.f.mjs} +13 -12
- package/commonjs/module/function/{module.f.cjs → module.f.mjs} +4 -4
- package/commonjs/module/{module.f.cjs → module.f.mjs} +3 -5
- package/commonjs/module.f.mjs +11 -0
- package/commonjs/{module.cjs → module.mjs} +8 -6
- package/commonjs/package/dependencies/{module.f.cjs → module.f.mjs} +5 -5
- package/commonjs/package/dependencies/{test.f.cjs → test.f.mjs} +2 -2
- package/commonjs/package/{module.f.cjs → module.f.mjs} +7 -6
- package/commonjs/package/{test.f.cjs → test.f.mjs} +2 -2
- package/commonjs/path/{module.f.cjs → module.f.mjs} +15 -14
- package/commonjs/path/{test.f.cjs → test.f.mjs} +16 -14
- package/commonjs/{test.cjs → test.mjs} +4 -4
- package/dev/{module.f.cjs → module.f.mjs} +1 -1
- package/dev/module.mjs +5 -3
- package/dev/test/{module.f.cjs → module.f.mjs} +21 -9
- package/dev/{test.f.cjs → test.f.mjs} +1 -1
- package/dev/test.mjs +1 -1
- package/djs/{module.f.cjs → module.f.mjs} +18 -15
- package/djs/parser/{module.f.cjs → module.f.mjs} +29 -28
- package/djs/parser/{test.f.cjs → test.f.mjs} +10 -8
- package/djs/{test.f.cjs → test.f.mjs} +7 -5
- package/djs/tokenizer/{module.f.cjs → module.f.mjs} +19 -18
- package/djs/tokenizer/{test.f.cjs → test.f.mjs} +9 -7
- package/fsc/{module.f.cjs → module.f.mjs} +17 -16
- package/fsc/{test.f.cjs → test.f.mjs} +6 -4
- package/fsm/{module.f.cjs → module.f.mjs} +28 -24
- package/fsm/{test.f.cjs → test.f.mjs} +13 -9
- package/html/{module.f.cjs → module.f.mjs} +16 -13
- package/html/{test.f.cjs → test.f.mjs} +5 -5
- package/index.f.mjs +45 -35
- package/issues/README.md +15 -0
- package/js/tokenizer/{module.f.cjs → module.f.mjs} +52 -51
- package/js/tokenizer/{test.f.cjs → test.f.mjs} +9 -7
- package/json/{module.f.cjs → module.f.mjs} +18 -17
- package/json/parser/{module.f.cjs → module.f.mjs} +27 -26
- package/json/parser/{test.f.cjs → test.f.mjs} +10 -8
- package/json/serializer/{module.f.cjs → module.f.mjs} +12 -12
- package/json/serializer/{test.f.cjs → test.f.mjs} +4 -3
- package/json/{test.f.cjs → test.f.mjs} +6 -4
- package/json/tokenizer/{module.f.cjs → module.f.mjs} +16 -15
- package/json/tokenizer/{test.f.cjs → test.f.mjs} +9 -7
- package/jsr.json +1 -1
- package/nodejs/version/main.mjs +5 -0
- package/nodejs/version/{module.f.cjs → module.f.mjs} +2 -2
- package/nodejs/version/{test.f.cjs → test.f.mjs} +5 -5
- package/package.json +3 -3
- package/prime_field/{module.f.cjs → module.f.mjs} +6 -5
- package/prime_field/{test.f.cjs → test.f.mjs} +3 -2
- package/secp/{module.f.cjs → module.f.mjs} +7 -6
- package/secp/{test.f.cjs → test.f.mjs} +6 -6
- package/sha2/{module.f.cjs → module.f.mjs} +5 -5
- package/sha2/{test.f.cjs → test.f.mjs} +7 -6
- package/text/ascii/{module.f.cjs → module.f.mjs} +3 -3
- package/text/ascii/test.f.mjs +14 -0
- package/text/{module.f.cjs → module.f.mjs} +6 -6
- package/text/sgr/{module.f.cjs → module.f.mjs} +1 -1
- package/text/{test.f.cjs → test.f.mjs} +5 -4
- package/text/utf16/{module.f.cjs → module.f.mjs} +16 -14
- package/text/utf16/{test.f.cjs → test.f.mjs} +7 -6
- package/text/utf8/{module.f.cjs → module.f.mjs} +11 -11
- package/text/utf8/{test.f.cjs → test.f.mjs} +6 -5
- package/tsconfig.json +2 -2
- package/types/array/{module.f.cjs → module.f.mjs} +2 -2
- package/types/array/{test.f.cjs → test.f.mjs} +5 -4
- package/types/bigfloat/{module.f.cjs → module.f.mjs} +3 -3
- package/types/bigfloat/{test.f.cjs → test.f.mjs} +3 -2
- package/types/bigint/{module.f.cjs → module.f.mjs} +8 -7
- package/types/bigint/{test.f.cjs → test.f.mjs} +3 -2
- package/types/btree/find/{module.f.cjs → module.f.mjs} +12 -12
- package/types/btree/find/{test.f.cjs → test.f.mjs} +11 -9
- package/types/btree/{module.f.cjs → module.f.mjs} +7 -12
- package/types/btree/remove/{module.f.cjs → module.f.mjs} +17 -16
- package/types/btree/remove/{test.f.cjs → test.f.mjs} +9 -7
- package/types/btree/set/{module.f.cjs → module.f.mjs} +9 -9
- package/types/btree/set/{test.f.cjs → test.f.mjs} +8 -6
- package/types/btree/{test.f.cjs → test.f.mjs} +23 -20
- package/types/btree/types/{module.f.cjs → module.f.mjs} +1 -1
- package/types/byte_set/{module.f.cjs → module.f.mjs} +8 -7
- package/types/byte_set/{test.f.cjs → test.f.mjs} +8 -7
- package/types/function/compare/{module.f.cjs → module.f.mjs} +2 -2
- package/types/function/compare/{test.f.cjs → test.f.mjs} +3 -2
- package/types/function/{module.f.cjs → module.f.mjs} +1 -5
- package/types/function/operator/{module.f.cjs → module.f.mjs} +1 -1
- package/types/function/{test.f.cjs → test.f.mjs} +4 -2
- package/types/list/{module.f.cjs → module.f.mjs} +12 -12
- package/types/list/{test.f.cjs → test.f.mjs} +13 -11
- package/types/map/{module.f.cjs → module.f.mjs} +21 -18
- package/types/map/{test.f.cjs → test.f.mjs} +5 -4
- package/types/nibble_set/{module.f.cjs → module.f.mjs} +1 -1
- package/types/nibble_set/{test.f.cjs → test.f.mjs} +4 -3
- package/types/nullable/{module.f.cjs → module.f.mjs} +1 -1
- package/types/nullable/{test.f.cjs → test.f.mjs} +2 -2
- package/types/number/module.f.mjs +26 -0
- package/types/number/{test.f.cjs → test.f.mjs} +3 -2
- package/types/object/{module.f.cjs → module.f.mjs} +6 -6
- package/types/object/{test.f.cjs → test.f.mjs} +2 -2
- package/types/range/{module.f.cjs → module.f.mjs} +1 -1
- package/types/range/{test.f.cjs → test.f.mjs} +2 -2
- package/types/range_map/{module.f.cjs → module.f.mjs} +16 -15
- package/types/range_map/{test.f.cjs → test.f.mjs} +35 -33
- package/types/result/{module.f.cjs → module.f.mjs} +1 -1
- package/types/result/{module.cjs → module.mjs} +3 -3
- package/types/sorted_list/{module.f.cjs → module.f.mjs} +11 -10
- package/types/sorted_list/{test.f.cjs → test.f.mjs} +14 -10
- package/types/sorted_set/{module.f.cjs → module.f.mjs} +8 -7
- package/types/sorted_set/{test.f.cjs → test.f.mjs} +14 -10
- package/types/string/{module.f.cjs → module.f.mjs} +8 -7
- package/types/string/{test.f.cjs → test.f.mjs} +5 -3
- package/types/string_set/{module.f.cjs → module.f.mjs} +15 -10
- package/types/string_set/{test.f.cjs → test.f.mjs} +2 -2
- package/com/cpp/testlib.f.cjs +0 -6
- package/com/cs/testlib.f.cjs +0 -6
- package/com/module.f.cjs +0 -6
- package/com/rust/testlib.f.cjs +0 -6
- package/commonjs/module.f.cjs +0 -20
- package/nodejs/module.f.cjs +0 -4
- package/nodejs/version/main.cjs +0 -6
- package/text/ascii/test.f.cjs +0 -12
- package/types/number/module.f.cjs +0 -24
- package/types/object/test.html +0 -9
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import list from '../../types/list/module.f.mjs'
|
|
2
2
|
const { fold } = list
|
|
3
|
-
|
|
4
|
-
const
|
|
3
|
+
import sgr from '../../text/sgr/module.f.mjs'
|
|
4
|
+
const { reset, fgGreen, fgRed, bold } = sgr
|
|
5
|
+
import * as Result from '../../types/result/module.f.mjs'
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @typedef {{
|
|
@@ -39,13 +40,13 @@ const result = require('../../types/result/module.f.cjs')
|
|
|
39
40
|
* readonly error: Log<T>,
|
|
40
41
|
* readonly measure: Measure<T>,
|
|
41
42
|
* readonly state: T,
|
|
42
|
-
* readonly tryCatch: <R>(f: () => R) =>
|
|
43
|
+
* readonly tryCatch: <R>(f: () => R) => Result.Result<R, unknown>,
|
|
43
44
|
* readonly env: (n: string) => string|undefined
|
|
44
45
|
* }} Input
|
|
45
46
|
*/
|
|
46
47
|
|
|
47
48
|
/** @type {(s: string) => boolean} */
|
|
48
|
-
const isTest = s => s.endsWith('test.f.cjs')
|
|
49
|
+
const isTest = s => s.endsWith('test.f.cjs') || s.endsWith('test.f.mjs')
|
|
49
50
|
|
|
50
51
|
/**
|
|
51
52
|
* @typedef {{
|
|
@@ -66,6 +67,17 @@ const addFail = delta => ts => ({ ...ts, time: ts.time + delta, fail: ts.fail +
|
|
|
66
67
|
* @typedef {readonly[TestState, T]} FullState
|
|
67
68
|
*/
|
|
68
69
|
|
|
70
|
+
/** @type {(a: number) => string} */
|
|
71
|
+
const timeFormat = a => {
|
|
72
|
+
const y = Math.round(a * 10_000).toString()
|
|
73
|
+
const yl = 5 - y.length
|
|
74
|
+
const x = '0'.repeat(yl > 0 ? yl : 0) + y
|
|
75
|
+
const s = x.length - 4
|
|
76
|
+
const b = x.substring(0, s)
|
|
77
|
+
const e = x.substring(s)
|
|
78
|
+
return `${b}.${e} ms`
|
|
79
|
+
}
|
|
80
|
+
|
|
69
81
|
/** @type {<T>(input: Input<T>) => readonly[number, T]} */
|
|
70
82
|
const main = input => {
|
|
71
83
|
let { moduleMap, log, error, measure, tryCatch, env, state } = input
|
|
@@ -88,12 +100,12 @@ const main = input => {
|
|
|
88
100
|
// https://github.com/OndraM/ci-detector/blob/main/src/Ci/GitHubActions.php
|
|
89
101
|
state = error(`::error file=${k},line=1,title=[3]['a']()::${r}`)(state)
|
|
90
102
|
} else {
|
|
91
|
-
state = error(`${i}() ${fgRed}error${reset}, ${delta}
|
|
103
|
+
state = error(`${i}() ${fgRed}error${reset}, ${timeFormat(delta)}`)(state)
|
|
92
104
|
state = error(`${fgRed}${r}${reset}`)(state)
|
|
93
105
|
}
|
|
94
106
|
} else {
|
|
95
107
|
ts = addPass(delta)(ts)
|
|
96
|
-
state = log(`${i}() ${fgGreen}ok${reset}, ${delta}
|
|
108
|
+
state = log(`${i}() ${fgGreen}ok${reset}, ${timeFormat(delta)}`)(state)
|
|
97
109
|
}
|
|
98
110
|
[ts, state] = next(r)([ts, state])
|
|
99
111
|
}
|
|
@@ -130,8 +142,8 @@ const main = input => {
|
|
|
130
142
|
[ts, state] = fold(f)([ts, state])(Object.entries(moduleMap))
|
|
131
143
|
const fgFail = ts.fail === 0 ? fgGreen : fgRed
|
|
132
144
|
state = log(`${bold}Number of tests: pass: ${fgGreen}${ts.pass}${reset}${bold}, fail: ${fgFail}${ts.fail}${reset}${bold}, total: ${ts.pass + ts.fail}${reset}`)(state)
|
|
133
|
-
state = log(`${bold}Time: ${ts.time}
|
|
145
|
+
state = log(`${bold}Time: ${timeFormat(ts.time)}${reset}`)(state);
|
|
134
146
|
return [ts.fail !== 0 ? 1 : 0, state]
|
|
135
147
|
}
|
|
136
148
|
|
|
137
|
-
|
|
149
|
+
export default main
|
package/dev/test.mjs
CHANGED
|
@@ -45,7 +45,7 @@ const main = async() => {
|
|
|
45
45
|
const moduleMap = await loadModuleMap()
|
|
46
46
|
|
|
47
47
|
/** @type {any} */
|
|
48
|
-
const f = moduleMap['./dev/test/module.f.
|
|
48
|
+
const f = moduleMap['./dev/test/module.f.mjs'].default
|
|
49
49
|
const r = f({
|
|
50
50
|
moduleMap,
|
|
51
51
|
log: anyLog(console.log),
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
const { flat, map
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
1
|
+
import list, * as List from '../types/list/module.f.mjs'
|
|
2
|
+
const { flat, map } = list
|
|
3
|
+
import string from '../types/string/module.f.mjs'
|
|
4
|
+
const { concat } = string
|
|
5
|
+
import object, * as O from '../types/object/module.f.mjs'
|
|
6
|
+
import f from '../types/function/module.f.mjs'
|
|
7
|
+
const { compose, fn } = f
|
|
6
8
|
const { entries } = Object
|
|
7
|
-
|
|
8
|
-
const {
|
|
9
|
+
import bi from '../types/bigint/module.f.mjs'
|
|
10
|
+
const { serialize: bigintSerialize } = bi
|
|
11
|
+
import j from '../json/serializer/module.f.mjs'
|
|
12
|
+
const { objectWrap, arrayWrap, stringSerialize, numberSerialize, nullSerialize, boolSerialize } = j
|
|
9
13
|
|
|
10
14
|
/**
|
|
11
15
|
* @typedef {{
|
|
@@ -19,28 +23,28 @@ const { objectWrap, arrayWrap, stringSerialize, numberSerialize, nullSerialize,
|
|
|
19
23
|
|
|
20
24
|
const colon = [':']
|
|
21
25
|
|
|
22
|
-
/** @typedef {
|
|
26
|
+
/** @typedef {O.Entry<Unknown>} Entry*/
|
|
23
27
|
|
|
24
|
-
/** @typedef {(
|
|
28
|
+
/** @typedef {(List.List<Entry>)} Entries */
|
|
25
29
|
|
|
26
30
|
/** @typedef {(entries: Entries) => Entries} MapEntries */
|
|
27
31
|
|
|
28
|
-
/** @type {(mapEntries: MapEntries) => (value: Unknown) =>
|
|
32
|
+
/** @type {(mapEntries: MapEntries) => (value: Unknown) => List.List<string>} */
|
|
29
33
|
const serialize = sort => {
|
|
30
|
-
/** @type {(kv: readonly[string, Unknown]) =>
|
|
34
|
+
/** @type {(kv: readonly[string, Unknown]) => List.List<string>} */
|
|
31
35
|
const propertySerialize = ([k, v]) => flat([
|
|
32
36
|
stringSerialize(k),
|
|
33
37
|
colon,
|
|
34
38
|
f(v)
|
|
35
39
|
])
|
|
36
40
|
const mapPropertySerialize = map(propertySerialize)
|
|
37
|
-
/** @type {(object: Object) =>
|
|
41
|
+
/** @type {(object: Object) => List.List<string>} */
|
|
38
42
|
const objectSerialize = fn(entries)
|
|
39
43
|
.then(sort)
|
|
40
44
|
.then(mapPropertySerialize)
|
|
41
45
|
.then(objectWrap)
|
|
42
46
|
.result
|
|
43
|
-
/** @type {(value: Unknown) =>
|
|
47
|
+
/** @type {(value: Unknown) => List.List<string>} */
|
|
44
48
|
const f = value => {
|
|
45
49
|
switch (typeof value) {
|
|
46
50
|
case 'boolean': { return boolSerialize(value) }
|
|
@@ -66,8 +70,7 @@ const serialize = sort => {
|
|
|
66
70
|
*/
|
|
67
71
|
const stringify = sort => compose(serialize(sort))(concat)
|
|
68
72
|
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
export default {
|
|
71
74
|
/** @readonly */
|
|
72
75
|
stringify,
|
|
73
76
|
/** @readonly */
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import result, * as Result from '../../types/result/module.f.mjs'
|
|
2
|
+
import list, * as List from '../../types/list/module.f.mjs'
|
|
3
3
|
const { fold, first, drop, toArray } = list
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import * as Operator from '../../types/function/operator/module.f.mjs'
|
|
5
|
+
import * as tokenizerT from '../tokenizer/module.f.mjs'
|
|
6
|
+
import map, * as Map from '../../types/map/module.f.mjs'
|
|
7
7
|
const { setReplace } = map
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
import * as Djs from '../module.f.mjs'
|
|
9
|
+
import o from '../../types/object/module.f.mjs'
|
|
10
|
+
const { fromMap } = o
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* @typedef {{
|
|
13
14
|
* readonly kind: 'object'
|
|
14
|
-
* readonly values:
|
|
15
|
+
* readonly values: Map.Map<Djs.Unknown>
|
|
15
16
|
* readonly key: string
|
|
16
17
|
* }} JsonObject
|
|
17
18
|
* */
|
|
@@ -19,7 +20,7 @@ const { fromMap } = require('../../types/object/module.f.cjs')
|
|
|
19
20
|
/**
|
|
20
21
|
* @typedef {{
|
|
21
22
|
* readonly kind: 'array'
|
|
22
|
-
* readonly values:
|
|
23
|
+
* readonly values: List.List<Djs.Unknown>
|
|
23
24
|
* }} JsonArray
|
|
24
25
|
* */
|
|
25
26
|
|
|
@@ -30,7 +31,7 @@ const { fromMap } = require('../../types/object/module.f.cjs')
|
|
|
30
31
|
* } JsonStackElement
|
|
31
32
|
*/
|
|
32
33
|
|
|
33
|
-
/** @typedef {
|
|
34
|
+
/** @typedef {List.List<JsonStackElement>} JsonStack */
|
|
34
35
|
|
|
35
36
|
/**
|
|
36
37
|
* @typedef {{
|
|
@@ -50,7 +51,7 @@ const { fromMap } = require('../../types/object/module.f.cjs')
|
|
|
50
51
|
/**
|
|
51
52
|
* @typedef {{
|
|
52
53
|
* readonly status: 'result'
|
|
53
|
-
* readonly value:
|
|
54
|
+
* readonly value: Djs.Unknown
|
|
54
55
|
* }} StateResult
|
|
55
56
|
*/
|
|
56
57
|
|
|
@@ -70,7 +71,7 @@ const { fromMap } = require('../../types/object/module.f.cjs')
|
|
|
70
71
|
* } DjsState
|
|
71
72
|
*/
|
|
72
73
|
|
|
73
|
-
/** @type {(token:
|
|
74
|
+
/** @type {(token: tokenizerT.DjsToken) => (state: StateModule) => DjsState}} */
|
|
74
75
|
const parseModuleOp = token => state => {
|
|
75
76
|
switch(state.stage)
|
|
76
77
|
{
|
|
@@ -101,10 +102,10 @@ const parseModuleOp = token => state => {
|
|
|
101
102
|
/** @type {(obj: JsonObject) => (key: string) => JsonObject} */
|
|
102
103
|
const addKeyToObject = obj => key => ({ kind: 'object', values: obj.values, key: key })
|
|
103
104
|
|
|
104
|
-
/** @type {(obj: JsonObject) => (value:
|
|
105
|
+
/** @type {(obj: JsonObject) => (value: Djs.Unknown) => JsonObject} */
|
|
105
106
|
const addValueToObject = obj => value => ({ kind: 'object', values: setReplace(obj.key)(value)(obj.values), key: '' })
|
|
106
107
|
|
|
107
|
-
/** @type {(array: JsonArray) => (value:
|
|
108
|
+
/** @type {(array: JsonArray) => (value: Djs.Unknown) => JsonArray} */
|
|
108
109
|
const addToArray = array => value => ({ kind: 'array', values: list.concat(array.values)([value]) })
|
|
109
110
|
|
|
110
111
|
/** @type {(state: StateParse) => (key: string) => DjsState} */
|
|
@@ -113,7 +114,7 @@ const pushKey = state => value => {
|
|
|
113
114
|
return { status: 'error', message: 'error' }
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
/** @type {(state: StateParse) => (value:
|
|
117
|
+
/** @type {(state: StateParse) => (value: Djs.Unknown) => DjsState} */
|
|
117
118
|
const pushValue = state => value => {
|
|
118
119
|
if (state.top === null) { return { status: 'result', value: value } }
|
|
119
120
|
if (state.top.kind === 'array') { return { status: '[v', top: addToArray(state.top)(value), stack: state.stack } }
|
|
@@ -148,7 +149,7 @@ const endObject = state => {
|
|
|
148
149
|
return pushValue(newState)(obj)
|
|
149
150
|
}
|
|
150
151
|
|
|
151
|
-
/** @type {(token:
|
|
152
|
+
/** @type {(token: tokenizerT.DjsToken) => Djs.Unknown} */
|
|
152
153
|
const tokenToValue = token => {
|
|
153
154
|
switch (token.kind) {
|
|
154
155
|
case 'null': return null
|
|
@@ -161,7 +162,7 @@ const tokenToValue = token => {
|
|
|
161
162
|
}
|
|
162
163
|
}
|
|
163
164
|
|
|
164
|
-
/** @type {(token:
|
|
165
|
+
/** @type {(token: tokenizerT.DjsToken) => boolean} */
|
|
165
166
|
const isValueToken = token => {
|
|
166
167
|
switch (token.kind) {
|
|
167
168
|
case 'null':
|
|
@@ -174,7 +175,7 @@ const isValueToken = token => {
|
|
|
174
175
|
}
|
|
175
176
|
}
|
|
176
177
|
|
|
177
|
-
/** @type {(token:
|
|
178
|
+
/** @type {(token: tokenizerT.DjsToken) => (state: StateParse) => DjsState}} */
|
|
178
179
|
const parseValueOp = token => state => {
|
|
179
180
|
if (isValueToken(token)) { return pushValue(state)(tokenToValue(token)) }
|
|
180
181
|
if (token.kind === '[') { return startArray(state) }
|
|
@@ -183,7 +184,7 @@ const parseValueOp = token => state => {
|
|
|
183
184
|
return { status: 'error', message: 'unexpected token' }
|
|
184
185
|
}
|
|
185
186
|
|
|
186
|
-
/** @type {(token:
|
|
187
|
+
/** @type {(token: tokenizerT.DjsToken) => (state: StateParse) => DjsState}} */
|
|
187
188
|
const parseArrayStartOp = token => state => {
|
|
188
189
|
if (isValueToken(token)) { return pushValue(state)(tokenToValue(token)) }
|
|
189
190
|
if (token.kind === '[') { return startArray(state) }
|
|
@@ -193,7 +194,7 @@ const parseArrayStartOp = token => state => {
|
|
|
193
194
|
return { status: 'error', message: 'unexpected token' }
|
|
194
195
|
}
|
|
195
196
|
|
|
196
|
-
/** @type {(token:
|
|
197
|
+
/** @type {(token: tokenizerT.DjsToken) => (state: StateParse) => DjsState}} */
|
|
197
198
|
const parseArrayValueOp = token => state => {
|
|
198
199
|
if (token.kind === ']') { return endArray(state) }
|
|
199
200
|
if (token.kind === ',') { return { status: '[,', top: state.top, stack: state.stack } }
|
|
@@ -201,7 +202,7 @@ const parseArrayValueOp = token => state => {
|
|
|
201
202
|
return { status: 'error', message: 'unexpected token' }
|
|
202
203
|
}
|
|
203
204
|
|
|
204
|
-
/** @type {(token:
|
|
205
|
+
/** @type {(token: tokenizerT.DjsToken) => (state: StateParse) => DjsState}} */
|
|
205
206
|
const parseObjectStartOp = token => state => {
|
|
206
207
|
if (token.kind === 'string') { return pushKey(state)(token.value) }
|
|
207
208
|
if (token.kind === '}') { return endObject(state) }
|
|
@@ -209,14 +210,14 @@ const parseObjectStartOp = token => state => {
|
|
|
209
210
|
return { status: 'error', message: 'unexpected token' }
|
|
210
211
|
}
|
|
211
212
|
|
|
212
|
-
/** @type {(token:
|
|
213
|
+
/** @type {(token: tokenizerT.DjsToken) => (state: StateParse) => DjsState}} */
|
|
213
214
|
const parseObjectKeyOp = token => state => {
|
|
214
215
|
if (token.kind === ':') { return { status: '{:', top: state.top, stack: state.stack } }
|
|
215
216
|
if (token.kind === 'ws') { return state }
|
|
216
217
|
return { status: 'error', message: 'unexpected token' }
|
|
217
218
|
}
|
|
218
219
|
|
|
219
|
-
/** @type {(token:
|
|
220
|
+
/** @type {(token: tokenizerT.DjsToken) => (state: StateParse) => DjsState}} */
|
|
220
221
|
const parseObjectColonOp = token => state => {
|
|
221
222
|
if (isValueToken(token)) { return pushValue(state)(tokenToValue(token)) }
|
|
222
223
|
if (token.kind === '[') { return startArray(state) }
|
|
@@ -225,7 +226,7 @@ const parseObjectColonOp = token => state => {
|
|
|
225
226
|
return { status: 'error', message: 'unexpected token' }
|
|
226
227
|
}
|
|
227
228
|
|
|
228
|
-
/** @type {(token:
|
|
229
|
+
/** @type {(token: tokenizerT.DjsToken) => (state: StateParse) => DjsState}} */
|
|
229
230
|
const parseObjectNextOp = token => state => {
|
|
230
231
|
if (token.kind === '}') { return endObject(state) }
|
|
231
232
|
if (token.kind === ',') { return { status: '{,', top: state.top, stack: state.stack } }
|
|
@@ -233,14 +234,14 @@ const parseObjectNextOp = token => state => {
|
|
|
233
234
|
return { status: 'error', message: 'unexpected token' }
|
|
234
235
|
}
|
|
235
236
|
|
|
236
|
-
/** @type {(token:
|
|
237
|
+
/** @type {(token: tokenizerT.DjsToken) => (state: StateParse) => DjsState}} */
|
|
237
238
|
const parseObjectCommaOp = token => state => {
|
|
238
239
|
if (token.kind === 'string') { return pushKey(state)(token.value) }
|
|
239
240
|
if (token.kind === 'ws') { return state }
|
|
240
241
|
return { status: 'error', message: 'unexpected token' }
|
|
241
242
|
}
|
|
242
243
|
|
|
243
|
-
/** @type {
|
|
244
|
+
/** @type {Operator.Fold<tokenizerT.DjsToken, DjsState>} */
|
|
244
245
|
const foldOp = token => state => {
|
|
245
246
|
switch (state.status) {
|
|
246
247
|
case 'module': return parseModuleOp(token)(state)
|
|
@@ -258,7 +259,7 @@ const foldOp = token => state => {
|
|
|
258
259
|
}
|
|
259
260
|
}
|
|
260
261
|
|
|
261
|
-
/** @type {(tokenList:
|
|
262
|
+
/** @type {(tokenList: List.List<tokenizerT.DjsToken>) => Result.Result<Djs.Unknown, string>} */
|
|
262
263
|
const parse = tokenList => {
|
|
263
264
|
const state = fold(foldOp)({ status: 'module', stage: 'module' })(tokenList)
|
|
264
265
|
switch (state.status) {
|
|
@@ -268,7 +269,7 @@ const parse = tokenList => {
|
|
|
268
269
|
}
|
|
269
270
|
}
|
|
270
271
|
|
|
271
|
-
|
|
272
|
+
export default {
|
|
272
273
|
/** @readonly */
|
|
273
274
|
parse
|
|
274
275
|
}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import parser from './module.f.mjs'
|
|
2
|
+
import tokenizer, * as tokenizerT from '../tokenizer/module.f.mjs'
|
|
3
|
+
import list from '../../types/list/module.f.mjs'
|
|
4
|
+
const { toArray } = list
|
|
5
|
+
import djs from '../module.f.mjs'
|
|
6
|
+
import o from '../../types/object/module.f.mjs'
|
|
7
|
+
const { sort } = o
|
|
8
|
+
import encoding from '../../text/utf16/module.f.mjs'
|
|
7
9
|
|
|
8
|
-
/** @type {(s: string) => readonly
|
|
10
|
+
/** @type {(s: string) => readonly tokenizerT.DjsToken[]} */
|
|
9
11
|
const tokenizeString = s => toArray(tokenizer.tokenize(encoding.stringToList(s)))
|
|
10
12
|
|
|
11
13
|
const stringify = djs.stringify(sort)
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
export default {
|
|
14
16
|
valid: [
|
|
15
17
|
() => {
|
|
16
18
|
const tokenList = tokenizeString('module.exports=null')
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
|
|
1
|
+
import json from '../json/module.f.mjs'
|
|
2
|
+
import list from '../types/object/module.f.mjs'
|
|
3
|
+
const { sort } = list
|
|
4
|
+
import f from '../types/function/module.f.mjs'
|
|
5
|
+
const { identity } = f
|
|
6
|
+
import djs from './module.f.mjs'
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
export default {
|
|
7
9
|
stringify: [
|
|
8
10
|
{
|
|
9
11
|
sort: () => {
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import operator, * as Operator from '../../types/function/operator/module.f.mjs'
|
|
2
|
+
import list, * as List from '../../types/list/module.f.mjs'
|
|
3
3
|
const { empty, flat, stateScan } = list
|
|
4
|
-
|
|
5
|
-
const
|
|
4
|
+
import bf from '../../types/bigfloat/module.f.mjs'
|
|
5
|
+
const { multiply } = bf
|
|
6
|
+
import jsTokenizer, * as jsTokenizerT from '../../js/tokenizer/module.f.mjs'
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @typedef {|
|
|
9
10
|
* {readonly kind: 'true' | 'false' | 'null'} |
|
|
10
11
|
* {readonly kind: '{' | '}' | ':' | ',' | '[' | ']' | '.' | '=' } |
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
12
|
+
* jsTokenizerT.StringToken |
|
|
13
|
+
* jsTokenizerT.NumberToken |
|
|
14
|
+
* jsTokenizerT.ErrorToken |
|
|
15
|
+
* jsTokenizerT.IdToken |
|
|
16
|
+
* jsTokenizerT.BigIntToken |
|
|
17
|
+
* jsTokenizerT.WhitespaceToken
|
|
17
18
|
* } DjsToken
|
|
18
19
|
*/
|
|
19
20
|
|
|
@@ -25,11 +26,11 @@ const jsTokenizer = require('../../js/tokenizer/module.f.cjs')
|
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* @typedef {|
|
|
28
|
-
*
|
|
29
|
+
* jsTokenizerT.JsToken | null
|
|
29
30
|
* } ScanInput
|
|
30
31
|
*/
|
|
31
32
|
|
|
32
|
-
/** @type {(input:
|
|
33
|
+
/** @type {(input: jsTokenizerT.JsToken) => List.List<DjsToken>} */
|
|
33
34
|
const mapToken = input =>
|
|
34
35
|
{
|
|
35
36
|
switch(input.kind)
|
|
@@ -55,7 +56,7 @@ const mapToken = input =>
|
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
/** @type {(input: ScanInput) => readonly [
|
|
59
|
+
/** @type {(input: ScanInput) => readonly [List.List<DjsToken>, ScanState]} */
|
|
59
60
|
const parseDefaultState = input =>
|
|
60
61
|
{
|
|
61
62
|
if (input === null) return [empty, { kind: 'def'}]
|
|
@@ -66,7 +67,7 @@ const parseDefaultState = input =>
|
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
/** @type {(input: ScanInput) => readonly [
|
|
70
|
+
/** @type {(input: ScanInput) => readonly [List.List<DjsToken>, ScanState]} */
|
|
70
71
|
const parseMinusState = input =>
|
|
71
72
|
{
|
|
72
73
|
if (input === null) return [[{ kind: 'error', message: 'invalid token' }], { kind: 'def'}]
|
|
@@ -79,7 +80,7 @@ const parseMinusState = input =>
|
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
/** @type {
|
|
83
|
+
/** @type {Operator.StateScan<ScanInput, ScanState, List.List<DjsToken>>} */
|
|
83
84
|
const scanToken = state => input => {
|
|
84
85
|
switch(state.kind)
|
|
85
86
|
{
|
|
@@ -88,15 +89,15 @@ const scanToken = state => input => {
|
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
/** @type {(input:
|
|
92
|
+
/** @type {(input: List.List<number>) => List.List<DjsToken>} */
|
|
92
93
|
const tokenize = input =>
|
|
93
94
|
{
|
|
94
|
-
/** @type {
|
|
95
|
+
/** @type {List.List<ScanInput>} */
|
|
95
96
|
const jsTokens = jsTokenizer.tokenize(input)
|
|
96
97
|
return flat(stateScan(scanToken)({ kind: 'def' })(list.concat(jsTokens)([null])))
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
|
|
100
|
+
export default {
|
|
100
101
|
/** @readonly */
|
|
101
102
|
tokenize
|
|
102
103
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import tokenizer, * as tokenizerT from './module.f.mjs'
|
|
2
|
+
import list from '../../types/list/module.f.mjs'
|
|
3
|
+
const { toArray, countdown } = list
|
|
4
|
+
import djs from '../module.f.mjs'
|
|
5
|
+
import o from '../../types/object/module.f.mjs'
|
|
6
|
+
const { sort } = o
|
|
7
|
+
import encoding from '../../text/utf16/module.f.mjs'
|
|
6
8
|
|
|
7
|
-
/** @type {(s: string) => readonly
|
|
9
|
+
/** @type {(s: string) => readonly tokenizerT.DjsToken[]} */
|
|
8
10
|
const tokenizeString = s => toArray(tokenizer.tokenize(encoding.stringToList(s)))
|
|
9
11
|
|
|
10
12
|
const stringify = djs.stringify(sort)
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
export default {
|
|
13
15
|
djs: [
|
|
14
16
|
() => {
|
|
15
17
|
const result = tokenizeString('')
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import operator from '../types/function/operator/module.f.mjs'
|
|
2
|
+
import range_map, * as RM from '../types/range_map/module.f.mjs'
|
|
3
3
|
const { merge: rangeMapMerge, fromRange, get } = range_map
|
|
4
|
-
|
|
5
|
-
const {
|
|
4
|
+
import list, * as List from '../types/list/module.f.mjs'
|
|
5
|
+
const { reduce: listReduce } = list
|
|
6
|
+
import ascii from '../text/ascii/module.f.mjs'
|
|
7
|
+
const { range: asciiRange } = ascii
|
|
6
8
|
const { fromCharCode } = String
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
9
|
+
import f from '../types/function/module.f.mjs'
|
|
10
|
+
const { fn } = f
|
|
11
|
+
import _range, * as Range from '../types/range/module.f.mjs'
|
|
10
12
|
const { one } = _range
|
|
11
13
|
const { toArray, map } = list
|
|
12
14
|
|
|
@@ -21,7 +23,7 @@ const { toArray, map } = list
|
|
|
21
23
|
|
|
22
24
|
/**
|
|
23
25
|
* @template T
|
|
24
|
-
* @typedef {
|
|
26
|
+
* @typedef {RM.RangeMapArray<CreateToResult<T>>} State
|
|
25
27
|
*/
|
|
26
28
|
|
|
27
29
|
/** @type {ToResult} */
|
|
@@ -40,10 +42,10 @@ const union = a => b => {
|
|
|
40
42
|
/** @type {readonly never[]} */
|
|
41
43
|
const empty = []
|
|
42
44
|
|
|
43
|
-
/** @type {<T>(a:
|
|
45
|
+
/** @type {<T>(a: List.List<State<T>>) => State<T>} */
|
|
44
46
|
const reduce = a => {
|
|
45
|
-
/** @typedef {typeof a extends
|
|
46
|
-
/** @type {
|
|
47
|
+
/** @typedef {typeof a extends List.List<State<infer T>> ? T : never} T */
|
|
48
|
+
/** @type {RM.RangeMerge<CreateToResult<T>>} */
|
|
47
49
|
const merge = rangeMapMerge({
|
|
48
50
|
union,
|
|
49
51
|
equal: operator.strictEqual,
|
|
@@ -51,7 +53,6 @@ const reduce = a => {
|
|
|
51
53
|
return toArray(listReduce(merge)(empty)(a))
|
|
52
54
|
}
|
|
53
55
|
|
|
54
|
-
|
|
55
56
|
const codePointRange = fromRange(def)
|
|
56
57
|
|
|
57
58
|
const range = fn(asciiRange).then(codePointRange).result
|
|
@@ -59,16 +60,16 @@ const range = fn(asciiRange).then(codePointRange).result
|
|
|
59
60
|
/** @type {(l: readonly string[]) => <T>(f: CreateToResult<T>) => State<T>} */
|
|
60
61
|
const rangeSet = l => f => {
|
|
61
62
|
/** @typedef {typeof f extends CreateToResult<infer T> ? T : never} T */
|
|
62
|
-
/** @type {(a:
|
|
63
|
+
/** @type {(a: Range.Range) => (f: CreateToResult<T>) => State<T>} */
|
|
63
64
|
const codePointRange = fromRange(def)
|
|
64
65
|
/** @type {(r: string) => State<T>} */
|
|
65
66
|
const g = r => codePointRange(asciiRange(r))(f)
|
|
66
67
|
return reduce(map(g)(l))
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
/** @type {<T>(a:
|
|
70
|
+
/** @type {<T>(a: List.List<State<T>>) => CreateToResult<T>} */
|
|
70
71
|
const create = a => {
|
|
71
|
-
/** @typedef {typeof a extends
|
|
72
|
+
/** @typedef {typeof a extends List.List<State<infer T>> ? T : never} T */
|
|
72
73
|
const i = reduce(a)
|
|
73
74
|
/** @type {(v: number) => (i: State<T>) => (v: T) => ToResult} */
|
|
74
75
|
const x = get(def)
|
|
@@ -114,7 +115,7 @@ const init = create([
|
|
|
114
115
|
range('~')(() => () => [['~'], unexpectedSymbol]),
|
|
115
116
|
])(void 0)
|
|
116
117
|
|
|
117
|
-
|
|
118
|
+
export default {
|
|
118
119
|
/** @readonly */
|
|
119
120
|
terminal,
|
|
120
121
|
/** @readonly */
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {
|
|
1
|
+
import _ from './module.f.mjs'
|
|
2
|
+
import ascii from '../text/ascii/module.f.mjs'
|
|
3
|
+
const { one } = ascii
|
|
4
|
+
import j from '../json/module.f.mjs'
|
|
5
|
+
const { stringify } = j
|
|
4
6
|
const s = stringify(i => i)
|
|
5
7
|
|
|
6
8
|
/** @type {(v: string) => string} */
|
|
@@ -9,7 +11,7 @@ const f = v => {
|
|
|
9
11
|
return s(_.init(n)[0])
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
export default {
|
|
13
15
|
a: () => {
|
|
14
16
|
const x = f('1')
|
|
15
17
|
if (x != '["1"]') { throw x }
|