functionalscript 0.0.428 → 0.0.429
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/commonjs/build/module.f.cjs +1 -1
- package/fsm/README.md +4 -0
- package/fsm/module.f.cjs +28 -0
- package/package.json +1 -1
- package/types/byte_set/module.f.cjs +57 -0
- package/types/{byteSet → byte_set}/test.f.cjs +0 -0
- package/types/module.f.cjs +3 -1
- package/types/{nibbleSet → nibble_set}/module.f.cjs +0 -0
- package/types/{nibbleSet → nibble_set}/test.f.cjs +0 -0
- package/types/{stringset → string_set}/module.f.cjs +0 -0
- package/types/{stringset → string_set}/test.f.cjs +0 -0
- package/types/byteSet/module.f.cjs +0 -30
|
@@ -8,7 +8,7 @@ const object = require('../../types/object/module.f.cjs')
|
|
|
8
8
|
const { fromMap } = object
|
|
9
9
|
const path = require('../path/module.f.cjs')
|
|
10
10
|
const { parseAndFind } = path
|
|
11
|
-
const stringSet = require('../../types/
|
|
11
|
+
const stringSet = require('../../types/string_set/module.f.cjs')
|
|
12
12
|
const { set: setSet, contains: setContains } = stringSet
|
|
13
13
|
|
|
14
14
|
/**
|
package/fsm/README.md
ADDED
package/fsm/module.f.cjs
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const { todo } = require('../dev/module.f.cjs')
|
|
2
|
+
const list = require('../types/list/module.f.cjs')
|
|
3
|
+
const byteSet = require('../types/byte_set/module.f.cjs')
|
|
4
|
+
|
|
5
|
+
/** @typedef {readonly[string, byteSet.ByteSet, string]} Rule */
|
|
6
|
+
|
|
7
|
+
/** @typedef {list.List<Rule>} Grammar */
|
|
8
|
+
|
|
9
|
+
/** @typedef {readonly string[]} ByteMap */
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {{
|
|
13
|
+
* readonly[state in string]: ByteMap
|
|
14
|
+
* }} Dfa
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** @type {(faId: string) => string} */
|
|
18
|
+
const escape = faId => todo()
|
|
19
|
+
|
|
20
|
+
/** @type {(grammar: Grammar) => Dfa} */
|
|
21
|
+
const dfa = grammar => todo()
|
|
22
|
+
|
|
23
|
+
module.exports = {
|
|
24
|
+
/** @readonly */
|
|
25
|
+
escape,
|
|
26
|
+
/** @readonly */
|
|
27
|
+
dfa,
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const { fn } = require('../function/module.f.cjs')
|
|
2
|
+
|
|
3
|
+
/** @typedef {bigint} ByteSet */
|
|
4
|
+
/** @typedef {number} Byte */
|
|
5
|
+
|
|
6
|
+
/** @type {(n: Byte) => (s: ByteSet) => boolean} */
|
|
7
|
+
const has = n => s => ((s >> BigInt(n)) & 1n) === 1n
|
|
8
|
+
|
|
9
|
+
// create a set
|
|
10
|
+
|
|
11
|
+
const empty = 0n
|
|
12
|
+
|
|
13
|
+
/** @type {(n: Byte) => ByteSet} */
|
|
14
|
+
const one = n => 1n << BigInt(n)
|
|
15
|
+
|
|
16
|
+
/** @type {(r: readonly[Byte, Byte]) => ByteSet} */
|
|
17
|
+
const range = ([b, e]) => one(e - b + 1) - 1n << BigInt(b)
|
|
18
|
+
|
|
19
|
+
// set operations
|
|
20
|
+
|
|
21
|
+
/** @type {(a: ByteSet) => (b: ByteSet) => ByteSet} */
|
|
22
|
+
const union = a => b => a | b
|
|
23
|
+
|
|
24
|
+
/** @type {(a: ByteSet) => (b: ByteSet) => ByteSet} */
|
|
25
|
+
const intersect = a => b => a & b
|
|
26
|
+
|
|
27
|
+
/** @type {(a: ByteSet) => (b: ByteSet) => ByteSet} */
|
|
28
|
+
const difference = a => b => intersect(a)(complement(b))
|
|
29
|
+
|
|
30
|
+
/** @type {(n: ByteSet) => ByteSet} */
|
|
31
|
+
const complement = n => ~n
|
|
32
|
+
|
|
33
|
+
// additional operations
|
|
34
|
+
|
|
35
|
+
const set = fn(one).then(union).result
|
|
36
|
+
|
|
37
|
+
const setRange = fn(range).then(union).result
|
|
38
|
+
|
|
39
|
+
/** @type {(n: Byte) => (s: ByteSet) => ByteSet} */
|
|
40
|
+
const unset = n => s => difference(s)(one(n))
|
|
41
|
+
|
|
42
|
+
module.exports = {
|
|
43
|
+
/** @readonly */
|
|
44
|
+
empty,
|
|
45
|
+
/** @readonly */
|
|
46
|
+
has,
|
|
47
|
+
/** @readonly */
|
|
48
|
+
set,
|
|
49
|
+
/** @readonly */
|
|
50
|
+
unset,
|
|
51
|
+
/** @readonly */
|
|
52
|
+
union,
|
|
53
|
+
/** @readonly */
|
|
54
|
+
setRange,
|
|
55
|
+
/** @readonly */
|
|
56
|
+
range,
|
|
57
|
+
}
|
|
File without changes
|
package/types/module.f.cjs
CHANGED
|
@@ -10,13 +10,15 @@ module.exports = {
|
|
|
10
10
|
/** @readonly */
|
|
11
11
|
map: require('./map/module.f.cjs'),
|
|
12
12
|
/** @readonly */
|
|
13
|
+
nibbleSet: require('./nibble_set/module.f.cjs'),
|
|
14
|
+
/** @readonly */
|
|
13
15
|
object: require('./object/module.f.cjs'),
|
|
14
16
|
/** @readonly */
|
|
15
17
|
range: require('./range/module.f.cjs'),
|
|
16
18
|
/** @readonly */
|
|
17
19
|
result: require('./result/module.f.cjs'),
|
|
18
20
|
/** @readonly */
|
|
19
|
-
|
|
21
|
+
stringSet: require('./string_set/module.f.cjs'),
|
|
20
22
|
/** @readonly */
|
|
21
23
|
bigint: require('./bigint/module.f.cjs'),
|
|
22
24
|
/** @readonly */
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/** @typedef {bigint} byteSet */
|
|
2
|
-
/** @typedef {number} byte */
|
|
3
|
-
|
|
4
|
-
/** @type {(n: byte) => (s: byteSet) => boolean} */
|
|
5
|
-
const has = n => s => ((s >> BigInt(n)) & 1n) === 1n
|
|
6
|
-
|
|
7
|
-
/** @type {(n: byte) => (s: byteSet) => byteSet} */
|
|
8
|
-
const set = n => s => s | (1n << BigInt(n))
|
|
9
|
-
|
|
10
|
-
/** @type {(n: byte) => (s: byteSet) => byteSet} */
|
|
11
|
-
const unset = n => s => s & ~(1n << BigInt(n))
|
|
12
|
-
|
|
13
|
-
/** @type {(r: readonly[number, number]) => (s: byteSet) => byteSet} */
|
|
14
|
-
const setRange = ([b, e]) => s => s | ((1n << BigInt(e - b + 1)) - 1n << BigInt(b))
|
|
15
|
-
|
|
16
|
-
// how to define FA???
|
|
17
|
-
// const stateA = [init, set] ????
|
|
18
|
-
|
|
19
|
-
module.exports = {
|
|
20
|
-
/** @readonly */
|
|
21
|
-
empty: 0n,
|
|
22
|
-
/** @readonly */
|
|
23
|
-
has,
|
|
24
|
-
/** @readonly */
|
|
25
|
-
set,
|
|
26
|
-
/** @readonly */
|
|
27
|
-
unset,
|
|
28
|
-
/** @readonly */
|
|
29
|
-
setRange
|
|
30
|
-
}
|