functionalscript 0.0.539 → 0.0.541
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/{fjson → djs}/README.md +30 -30
- package/{fjson → djs}/parser/module.f.cjs +26 -26
- package/{fjson → djs}/parser/test.f.cjs +3 -3
- package/{fjson → djs}/test.f.cjs +10 -10
- package/{fjson → djs}/tokenizer/module.f.cjs +6 -6
- package/{fjson → djs}/tokenizer/test.f.cjs +4 -4
- package/js/tokenizer/test.f.cjs +3 -3
- package/json/tokenizer/test.f.cjs +2 -2
- package/package.json +1 -1
- package/sha2/module.f.cjs +4 -1
- /package/{fjson → djs}/module.f.cjs +0 -0
package/{fjson → djs}/README.md
RENAMED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
- additional types: bigint
|
|
4
|
-
|
|
5
|
-
## Rules
|
|
6
|
-
|
|
7
|
-
- can serialize/deserialize without reading source code
|
|
8
|
-
- no function serialization/deserialization
|
|
9
|
-
|
|
10
|
-
## Next steps
|
|
11
|
-
|
|
12
|
-
- [ ] rename `fjson` to `djs` (data javascript), File extensions: `.d.cjs`, `.d.mjs`, `.d.js`.
|
|
13
|
-
- [x] use JS tokenizer
|
|
14
|
-
- [x] identifiers `{a:5}`
|
|
15
|
-
- [x] big int
|
|
16
|
-
- [ ] `module.exports = ...`
|
|
17
|
-
- [ ] constants `const a = [3];module.exports = { a: a, b: a }`. Serialization `const _0=[3];module.exports={a:_0,b:_0}`
|
|
18
|
-
- [ ] import `const a = require('c.d.cjs');module.exports = { a: a, b: a}`
|
|
19
|
-
- [ ] ES6 import `import a from 'c.d.mjs';export default { a: a, b: a}`
|
|
20
|
-
- [ ] short form `const a = 5;module.exports = { a }`
|
|
21
|
-
|
|
22
|
-
Optional, for fun, syntax sugar:
|
|
23
|
-
|
|
24
|
-
- [ ] comments. Ignore them. Not an error.
|
|
25
|
-
- [ ] double/single quote strings
|
|
26
|
-
|
|
27
|
-
## Decidable Language
|
|
28
|
-
|
|
29
|
-
- [ ] using operator and functions `const a = 2+2+Math.abs(5); module.exports = { a: a };`
|
|
30
|
-
- [ ] decidable functions `const f = a => b => a + b; module.exports = f(1)(2)`?
|
|
1
|
+
# DJS, Data JS or DataScript
|
|
2
|
+
|
|
3
|
+
- additional types: bigint
|
|
4
|
+
|
|
5
|
+
## Rules
|
|
6
|
+
|
|
7
|
+
- can serialize/deserialize without reading source code
|
|
8
|
+
- no function serialization/deserialization
|
|
9
|
+
|
|
10
|
+
## Next steps
|
|
11
|
+
|
|
12
|
+
- [ ] rename `fjson` to `djs` (data javascript), File extensions: `.d.cjs`, `.d.mjs`, `.d.js`.
|
|
13
|
+
- [x] use JS tokenizer
|
|
14
|
+
- [x] identifiers `{a:5}`
|
|
15
|
+
- [x] big int
|
|
16
|
+
- [ ] `module.exports = ...`
|
|
17
|
+
- [ ] constants `const a = [3];module.exports = { a: a, b: a }`. Serialization `const _0=[3];module.exports={a:_0,b:_0}`
|
|
18
|
+
- [ ] import `const a = require('c.d.cjs');module.exports = { a: a, b: a}`
|
|
19
|
+
- [ ] ES6 import `import a from 'c.d.mjs';export default { a: a, b: a}`
|
|
20
|
+
- [ ] short form `const a = 5;module.exports = { a }`
|
|
21
|
+
|
|
22
|
+
Optional, for fun, syntax sugar:
|
|
23
|
+
|
|
24
|
+
- [ ] comments. Ignore them. Not an error.
|
|
25
|
+
- [ ] double/single quote strings
|
|
26
|
+
|
|
27
|
+
## Decidable Language
|
|
28
|
+
|
|
29
|
+
- [ ] using operator and functions `const a = 2+2+Math.abs(5); module.exports = { a: a };`
|
|
30
|
+
- [ ] decidable functions `const f = a => b => a + b; module.exports = f(1)(2)`?
|
|
@@ -5,13 +5,13 @@ const operator = require('../../types/function/operator/module.f.cjs')
|
|
|
5
5
|
const tokenizer = require('../tokenizer/module.f.cjs')
|
|
6
6
|
const map = require('../../types/map/module.f.cjs')
|
|
7
7
|
const { setReplace } = map
|
|
8
|
-
const
|
|
8
|
+
const djs = require('../module.f.cjs')
|
|
9
9
|
const { fromMap } = require('../../types/object/module.f.cjs')
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @typedef {{
|
|
13
13
|
* readonly kind: 'object'
|
|
14
|
-
* readonly values: map.Map<
|
|
14
|
+
* readonly values: map.Map<djs.Unknown>
|
|
15
15
|
* readonly key: string
|
|
16
16
|
* }} JsonObject
|
|
17
17
|
* */
|
|
@@ -19,7 +19,7 @@ const { fromMap } = require('../../types/object/module.f.cjs')
|
|
|
19
19
|
/**
|
|
20
20
|
* @typedef {{
|
|
21
21
|
* readonly kind: 'array'
|
|
22
|
-
* readonly values: list.List<
|
|
22
|
+
* readonly values: list.List<djs.Unknown>
|
|
23
23
|
* }} JsonArray
|
|
24
24
|
* */
|
|
25
25
|
|
|
@@ -50,7 +50,7 @@ const { fromMap } = require('../../types/object/module.f.cjs')
|
|
|
50
50
|
/**
|
|
51
51
|
* @typedef {{
|
|
52
52
|
* readonly status: 'result'
|
|
53
|
-
* readonly value:
|
|
53
|
+
* readonly value: djs.Unknown
|
|
54
54
|
* }} StateResult
|
|
55
55
|
*/
|
|
56
56
|
|
|
@@ -67,10 +67,10 @@ const { fromMap } = require('../../types/object/module.f.cjs')
|
|
|
67
67
|
* StateParse |
|
|
68
68
|
* StateResult |
|
|
69
69
|
* StateError
|
|
70
|
-
* }
|
|
70
|
+
* } DjsState
|
|
71
71
|
*/
|
|
72
72
|
|
|
73
|
-
/** @type {(token: tokenizer.
|
|
73
|
+
/** @type {(token: tokenizer.DjsToken) => (state: StateModule) => DjsState}} */
|
|
74
74
|
const parseModuleOp = token => state => {
|
|
75
75
|
switch(state.stage)
|
|
76
76
|
{
|
|
@@ -101,32 +101,32 @@ const parseModuleOp = token => state => {
|
|
|
101
101
|
/** @type {(obj: JsonObject) => (key: string) => JsonObject} */
|
|
102
102
|
const addKeyToObject = obj => key => ({ kind: 'object', values: obj.values, key: key })
|
|
103
103
|
|
|
104
|
-
/** @type {(obj: JsonObject) => (value:
|
|
104
|
+
/** @type {(obj: JsonObject) => (value: djs.Unknown) => JsonObject} */
|
|
105
105
|
const addValueToObject = obj => value => ({ kind: 'object', values: setReplace(obj.key)(value)(obj.values), key: '' })
|
|
106
106
|
|
|
107
|
-
/** @type {(array: JsonArray) => (value:
|
|
107
|
+
/** @type {(array: JsonArray) => (value: djs.Unknown) => JsonArray} */
|
|
108
108
|
const addToArray = array => value => ({ kind: 'array', values: list.concat(array.values)([value]) })
|
|
109
109
|
|
|
110
|
-
/** @type {(state: StateParse) => (key: string) =>
|
|
110
|
+
/** @type {(state: StateParse) => (key: string) => DjsState} */
|
|
111
111
|
const pushKey = state => value => {
|
|
112
112
|
if (state.top?.kind === 'object') { return { status: '{k', top: addKeyToObject(state.top)(value), stack: state.stack } }
|
|
113
113
|
return { status: 'error', message: 'error' }
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
/** @type {(state: StateParse) => (value:
|
|
116
|
+
/** @type {(state: StateParse) => (value: djs.Unknown) => DjsState} */
|
|
117
117
|
const pushValue = state => value => {
|
|
118
118
|
if (state.top === null) { return { status: 'result', value: value } }
|
|
119
119
|
if (state.top.kind === 'array') { return { status: '[v', top: addToArray(state.top)(value), stack: state.stack } }
|
|
120
120
|
return { status: '{v', top: addValueToObject(state.top)(value), stack: state.stack }
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
/** @type {(state: StateParse) =>
|
|
123
|
+
/** @type {(state: StateParse) => DjsState} */
|
|
124
124
|
const startArray = state => {
|
|
125
125
|
const newStack = state.top === null ? null : { first: state.top, tail: state.stack }
|
|
126
126
|
return { status: '[', top: { kind: 'array', values: null }, stack: newStack }
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
/** @type {(state: StateParse) =>
|
|
129
|
+
/** @type {(state: StateParse) => DjsState} */
|
|
130
130
|
const endArray = state => {
|
|
131
131
|
const array = state.top !== null ? toArray(state.top.values) : null
|
|
132
132
|
/** @type {StateParse} */
|
|
@@ -134,13 +134,13 @@ const endArray = state => {
|
|
|
134
134
|
return pushValue(newState)(array)
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
/** @type {(state: StateParse) =>
|
|
137
|
+
/** @type {(state: StateParse) => DjsState} */
|
|
138
138
|
const startObject = state => {
|
|
139
139
|
const newStack = state.top === null ? null : { first: state.top, tail: state.stack }
|
|
140
140
|
return { status: '{', top: { kind: 'object', values: null, key: '' }, stack: newStack }
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
/** @type {(state: StateParse) =>
|
|
143
|
+
/** @type {(state: StateParse) => DjsState} */
|
|
144
144
|
const endObject = state => {
|
|
145
145
|
const obj = state.top?.kind === 'object' ? fromMap(state.top.values) : null
|
|
146
146
|
/** @type {StateParse} */
|
|
@@ -148,7 +148,7 @@ const endObject = state => {
|
|
|
148
148
|
return pushValue(newState)(obj)
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
/** @type {(token: tokenizer.
|
|
151
|
+
/** @type {(token: tokenizer.DjsToken) => djs.Unknown} */
|
|
152
152
|
const tokenToValue = token => {
|
|
153
153
|
switch (token.kind) {
|
|
154
154
|
case 'null': return null
|
|
@@ -161,7 +161,7 @@ const tokenToValue = token => {
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
/** @type {(token: tokenizer.
|
|
164
|
+
/** @type {(token: tokenizer.DjsToken) => boolean} */
|
|
165
165
|
const isValueToken = token => {
|
|
166
166
|
switch (token.kind) {
|
|
167
167
|
case 'null':
|
|
@@ -174,7 +174,7 @@ const isValueToken = token => {
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
/** @type {(token: tokenizer.
|
|
177
|
+
/** @type {(token: tokenizer.DjsToken) => (state: StateParse) => DjsState}} */
|
|
178
178
|
const parseValueOp = token => state => {
|
|
179
179
|
if (isValueToken(token)) { return pushValue(state)(tokenToValue(token)) }
|
|
180
180
|
if (token.kind === '[') { return startArray(state) }
|
|
@@ -183,7 +183,7 @@ const parseValueOp = token => state => {
|
|
|
183
183
|
return { status: 'error', message: 'unexpected token' }
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
/** @type {(token: tokenizer.
|
|
186
|
+
/** @type {(token: tokenizer.DjsToken) => (state: StateParse) => DjsState}} */
|
|
187
187
|
const parseArrayStartOp = token => state => {
|
|
188
188
|
if (isValueToken(token)) { return pushValue(state)(tokenToValue(token)) }
|
|
189
189
|
if (token.kind === '[') { return startArray(state) }
|
|
@@ -193,7 +193,7 @@ const parseArrayStartOp = token => state => {
|
|
|
193
193
|
return { status: 'error', message: 'unexpected token' }
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
/** @type {(token: tokenizer.
|
|
196
|
+
/** @type {(token: tokenizer.DjsToken) => (state: StateParse) => DjsState}} */
|
|
197
197
|
const parseArrayValueOp = token => state => {
|
|
198
198
|
if (token.kind === ']') { return endArray(state) }
|
|
199
199
|
if (token.kind === ',') { return { status: '[,', top: state.top, stack: state.stack } }
|
|
@@ -201,7 +201,7 @@ const parseArrayValueOp = token => state => {
|
|
|
201
201
|
return { status: 'error', message: 'unexpected token' }
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
/** @type {(token: tokenizer.
|
|
204
|
+
/** @type {(token: tokenizer.DjsToken) => (state: StateParse) => DjsState}} */
|
|
205
205
|
const parseObjectStartOp = token => state => {
|
|
206
206
|
if (token.kind === 'string') { return pushKey(state)(token.value) }
|
|
207
207
|
if (token.kind === '}') { return endObject(state) }
|
|
@@ -209,14 +209,14 @@ const parseObjectStartOp = token => state => {
|
|
|
209
209
|
return { status: 'error', message: 'unexpected token' }
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
/** @type {(token: tokenizer.
|
|
212
|
+
/** @type {(token: tokenizer.DjsToken) => (state: StateParse) => DjsState}} */
|
|
213
213
|
const parseObjectKeyOp = token => state => {
|
|
214
214
|
if (token.kind === ':') { return { status: '{:', top: state.top, stack: state.stack } }
|
|
215
215
|
if (token.kind === 'ws') { return state }
|
|
216
216
|
return { status: 'error', message: 'unexpected token' }
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
/** @type {(token: tokenizer.
|
|
219
|
+
/** @type {(token: tokenizer.DjsToken) => (state: StateParse) => DjsState}} */
|
|
220
220
|
const parseObjectColonOp = token => state => {
|
|
221
221
|
if (isValueToken(token)) { return pushValue(state)(tokenToValue(token)) }
|
|
222
222
|
if (token.kind === '[') { return startArray(state) }
|
|
@@ -225,7 +225,7 @@ const parseObjectColonOp = token => state => {
|
|
|
225
225
|
return { status: 'error', message: 'unexpected token' }
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
/** @type {(token: tokenizer.
|
|
228
|
+
/** @type {(token: tokenizer.DjsToken) => (state: StateParse) => DjsState}} */
|
|
229
229
|
const parseObjectNextOp = token => state => {
|
|
230
230
|
if (token.kind === '}') { return endObject(state) }
|
|
231
231
|
if (token.kind === ',') { return { status: '{,', top: state.top, stack: state.stack } }
|
|
@@ -233,14 +233,14 @@ const parseObjectNextOp = token => state => {
|
|
|
233
233
|
return { status: 'error', message: 'unexpected token' }
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
/** @type {(token: tokenizer.
|
|
236
|
+
/** @type {(token: tokenizer.DjsToken) => (state: StateParse) => DjsState}} */
|
|
237
237
|
const parseObjectCommaOp = token => state => {
|
|
238
238
|
if (token.kind === 'string') { return pushKey(state)(token.value) }
|
|
239
239
|
if (token.kind === 'ws') { return state }
|
|
240
240
|
return { status: 'error', message: 'unexpected token' }
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
/** @type {operator.Fold<tokenizer.
|
|
243
|
+
/** @type {operator.Fold<tokenizer.DjsToken, DjsState>} */
|
|
244
244
|
const foldOp = token => state => {
|
|
245
245
|
switch (state.status) {
|
|
246
246
|
case 'module': return parseModuleOp(token)(state)
|
|
@@ -258,7 +258,7 @@ const foldOp = token => state => {
|
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
/** @type {(tokenList: list.List<tokenizer.
|
|
261
|
+
/** @type {(tokenList: list.List<tokenizer.DjsToken>) => result.Result<djs.Unknown, string>} */
|
|
262
262
|
const parse = tokenList => {
|
|
263
263
|
const state = fold(foldOp)({ status: 'module', stage: 'module' })(tokenList)
|
|
264
264
|
switch (state.status) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
const parser = require('./module.f.cjs')
|
|
2
2
|
const tokenizer = require('../tokenizer/module.f.cjs')
|
|
3
3
|
const { toArray } = require('../../types/list/module.f.cjs')
|
|
4
|
-
const
|
|
4
|
+
const djs = require('../module.f.cjs')
|
|
5
5
|
const { sort } = require('../../types/object/module.f.cjs')
|
|
6
6
|
const encoding = require('../../text/utf16/module.f.cjs');
|
|
7
7
|
|
|
8
|
-
/** @type {(s: string) => readonly tokenizer.
|
|
8
|
+
/** @type {(s: string) => readonly tokenizer.DjsToken[]} */
|
|
9
9
|
const tokenizeString = s => toArray(tokenizer.tokenize(encoding.stringToList(s)))
|
|
10
10
|
|
|
11
|
-
const stringify =
|
|
11
|
+
const stringify = djs.stringify(sort)
|
|
12
12
|
|
|
13
13
|
module.exports = {
|
|
14
14
|
valid: [
|
package/{fjson → djs}/test.f.cjs
RENAMED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
const json = require('../json/module.f.cjs')
|
|
2
2
|
const { sort } = require('../types/object/module.f.cjs')
|
|
3
3
|
const { identity } = require('../types/function/module.f.cjs')
|
|
4
|
-
const
|
|
4
|
+
const djs= require('./module.f.cjs')
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
7
|
stringify: [
|
|
8
8
|
{
|
|
9
9
|
sort: () => {
|
|
10
10
|
const r = json.setProperty("Hello")(['a'])({})
|
|
11
|
-
const x =
|
|
11
|
+
const x = djs.stringify(sort)(r)
|
|
12
12
|
if (x !== '{"a":"Hello"}') { throw x }
|
|
13
13
|
},
|
|
14
14
|
identity: () => {
|
|
15
|
-
const x =
|
|
15
|
+
const x = djs.stringify(identity)(json.setProperty("Hello")(['a'])({}))
|
|
16
16
|
if (x !== '{"a":"Hello"}') { throw x }
|
|
17
17
|
},
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
sort: () => {
|
|
21
|
-
const x =
|
|
21
|
+
const x = djs.stringify(sort)(json.setProperty("Hello")(['a'])({ c: [], b: 12 }))
|
|
22
22
|
if (x !== '{"a":"Hello","b":12,"c":[]}') { throw x }
|
|
23
23
|
},
|
|
24
24
|
identity: () => {
|
|
25
|
-
const x =
|
|
25
|
+
const x = djs.stringify(identity)(json.setProperty("Hello")(['a'])({ c: [], b: 12 }))
|
|
26
26
|
if (x !== '{"c":[],"b":12,"a":"Hello"}') { throw x }
|
|
27
27
|
},
|
|
28
28
|
},
|
|
@@ -30,34 +30,34 @@ module.exports = {
|
|
|
30
30
|
sort: () => {
|
|
31
31
|
const _0 = { a: { y: [24] }, c: [], b: 12 }
|
|
32
32
|
const _1 = json.setProperty("Hello")(['a', 'x'])(_0)
|
|
33
|
-
const _2 =
|
|
33
|
+
const _2 = djs.stringify(sort)(_1)
|
|
34
34
|
if (_2 !== '{"a":{"x":"Hello","y":[24]},"b":12,"c":[]}') { throw _2 }
|
|
35
35
|
},
|
|
36
36
|
identity: () => {
|
|
37
37
|
const _0 = { a: { y: [24] }, c: [], b: 12 }
|
|
38
38
|
const _1 = json.setProperty("Hello")(['a', 'x'])(_0)
|
|
39
|
-
const _2 =
|
|
39
|
+
const _2 = djs.stringify(identity)(_1)
|
|
40
40
|
if (_2 !== '{"a":{"y":[24],"x":"Hello"},"c":[],"b":12}') { throw _2 }
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
stringify: () => {
|
|
45
45
|
const bi = 1234567890n
|
|
46
|
-
const result =
|
|
46
|
+
const result = djs.stringify(sort)(bi)
|
|
47
47
|
if (result !== '1234567890n') { throw result }
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
stringify: () => {
|
|
52
52
|
const arr = [0n, 1, 2n]
|
|
53
|
-
const result =
|
|
53
|
+
const result = djs.stringify(sort)(arr)
|
|
54
54
|
if (result !== '[0n,1,2n]') { throw result }
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
stringify: () => {
|
|
59
59
|
const obj = {"a": 0n, "b": 1, "c": 2n}
|
|
60
|
-
const result =
|
|
60
|
+
const result = djs.stringify(sort)(obj)
|
|
61
61
|
if (result !== '{"a":0n,"b":1,"c":2n}') { throw result }
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -14,7 +14,7 @@ const jsTokenizer = require('../../js/tokenizer/module.f.cjs')
|
|
|
14
14
|
* jsTokenizer.IdToken |
|
|
15
15
|
* jsTokenizer.BigIntToken |
|
|
16
16
|
* jsTokenizer.WhitespaceToken
|
|
17
|
-
* }
|
|
17
|
+
* } DjsToken
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -29,7 +29,7 @@ const jsTokenizer = require('../../js/tokenizer/module.f.cjs')
|
|
|
29
29
|
* } ScanInput
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
|
-
/** @type {(input: jsTokenizer.JsToken) => list.List<
|
|
32
|
+
/** @type {(input: jsTokenizer.JsToken) => list.List<DjsToken>} */
|
|
33
33
|
const mapToken = input =>
|
|
34
34
|
{
|
|
35
35
|
switch(input.kind)
|
|
@@ -55,7 +55,7 @@ const mapToken = input =>
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
/** @type {(input: ScanInput) => readonly [list.List<
|
|
58
|
+
/** @type {(input: ScanInput) => readonly [list.List<DjsToken>, ScanState]} */
|
|
59
59
|
const parseDefaultState = input =>
|
|
60
60
|
{
|
|
61
61
|
if (input === null) return [empty, { kind: 'def'}]
|
|
@@ -66,7 +66,7 @@ const parseDefaultState = input =>
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
/** @type {(input: ScanInput) => readonly [list.List<
|
|
69
|
+
/** @type {(input: ScanInput) => readonly [list.List<DjsToken>, ScanState]} */
|
|
70
70
|
const parseMinusState = input =>
|
|
71
71
|
{
|
|
72
72
|
if (input === null) return [[{ kind: 'error', message: 'invalid token' }], { kind: 'def'}]
|
|
@@ -79,7 +79,7 @@ const parseMinusState = input =>
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
/** @type {operator.StateScan<ScanInput, ScanState, list.List<
|
|
82
|
+
/** @type {operator.StateScan<ScanInput, ScanState, list.List<DjsToken>>} */
|
|
83
83
|
const scanToken = state => input => {
|
|
84
84
|
switch(state.kind)
|
|
85
85
|
{
|
|
@@ -88,7 +88,7 @@ const scanToken = state => input => {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
/** @type {(input: list.List<number>) => list.List<
|
|
91
|
+
/** @type {(input: list.List<number>) => list.List<DjsToken>} */
|
|
92
92
|
const tokenize = input =>
|
|
93
93
|
{
|
|
94
94
|
/** @type {list.List<ScanInput>} */
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
const tokenizer = require('./module.f.cjs')
|
|
2
2
|
const { toArray, countdown } = require('../../types/list/module.f.cjs')
|
|
3
|
-
const
|
|
3
|
+
const djs = require('../../djs/module.f.cjs')
|
|
4
4
|
const { sort } = require('../../types/object/module.f.cjs')
|
|
5
5
|
const encoding = require('../../text/utf16/module.f.cjs');
|
|
6
6
|
|
|
7
|
-
/** @type {(s: string) => readonly tokenizer.
|
|
7
|
+
/** @type {(s: string) => readonly tokenizer.DjsToken[]} */
|
|
8
8
|
const tokenizeString = s => toArray(tokenizer.tokenize(encoding.stringToList(s)))
|
|
9
9
|
|
|
10
|
-
const stringify =
|
|
10
|
+
const stringify = djs.stringify(sort)
|
|
11
11
|
|
|
12
12
|
module.exports = {
|
|
13
|
-
|
|
13
|
+
djs: [
|
|
14
14
|
() => {
|
|
15
15
|
const result = tokenizeString('')
|
|
16
16
|
if (result.length !== 0) { throw result }
|
package/js/tokenizer/test.f.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
const tokenizer = require('./module.f.cjs')
|
|
2
2
|
const { toArray, countdown } = require('../../types/list/module.f.cjs')
|
|
3
|
-
const
|
|
3
|
+
const djs = require('../../djs/module.f.cjs')
|
|
4
4
|
const { sort } = require('../../types/object/module.f.cjs')
|
|
5
5
|
const encoding = require('../../text/utf16/module.f.cjs');
|
|
6
6
|
|
|
7
7
|
/** @type {(s: string) => readonly tokenizer.JsToken[]} */
|
|
8
8
|
const tokenizeString = s => toArray(tokenizer.tokenize(encoding.stringToList(s)))
|
|
9
9
|
|
|
10
|
-
const stringify =
|
|
10
|
+
const stringify = djs.stringify(sort)
|
|
11
11
|
|
|
12
12
|
module.exports = {
|
|
13
|
-
|
|
13
|
+
djs: [
|
|
14
14
|
() => {
|
|
15
15
|
const result = tokenizeString('')
|
|
16
16
|
if (result.length !== 0) { throw result }
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const tokenizer = require('./module.f.cjs')
|
|
2
2
|
const { toArray, countdown } = require('../../types/list/module.f.cjs')
|
|
3
|
-
const
|
|
3
|
+
const djs = require('../../djs/module.f.cjs')
|
|
4
4
|
const { sort } = require('../../types/object/module.f.cjs')
|
|
5
5
|
const encoding = require('../../text/utf16/module.f.cjs');
|
|
6
6
|
|
|
7
7
|
/** @type {(s: string) => readonly tokenizer.JsonToken[]} */
|
|
8
8
|
const tokenizeString = s => toArray(tokenizer.tokenize(encoding.stringToList(s)))
|
|
9
9
|
|
|
10
|
-
const stringify =
|
|
10
|
+
const stringify = djs.stringify(sort)
|
|
11
11
|
|
|
12
12
|
module.exports = {
|
|
13
13
|
json: [
|
package/package.json
CHANGED
package/sha2/module.f.cjs
CHANGED
|
@@ -129,7 +129,8 @@ const compress = ([a0, b0, c0, d0, e0, f0, g0, h0]) => data => {
|
|
|
129
129
|
let g = g0
|
|
130
130
|
let h = h0
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
let i = 0;
|
|
133
|
+
while (true) {
|
|
133
134
|
const ki = k[i]
|
|
134
135
|
for (let j = 0; j < 16; ++j) {
|
|
135
136
|
const t1 = h + bigSigma1(e) + ch(e)(f)(g) + ki[j] + w[j]
|
|
@@ -143,6 +144,8 @@ const compress = ([a0, b0, c0, d0, e0, f0, g0, h0]) => data => {
|
|
|
143
144
|
b = a
|
|
144
145
|
a = (t1 + t2) | 0
|
|
145
146
|
}
|
|
147
|
+
if (i === 3) { break }
|
|
148
|
+
++i;
|
|
146
149
|
w = nextW(w)
|
|
147
150
|
}
|
|
148
151
|
|
|
File without changes
|