functionalscript 0.0.406 → 0.0.409

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/doc/fa.md ADDED
@@ -0,0 +1,158 @@
1
+ # FA
2
+
3
+ F ::= A 'hello'
4
+ F ::= A 'help'
5
+
6
+ ## Classic FA
7
+
8
+ S0 ::= A 'h'
9
+ S1 ::= S0 'e'
10
+ S2 ::= S1 'l'
11
+ S3 ::= S2 'l'
12
+ F ::= S3 'o'
13
+
14
+ X0 ::= A 'h'
15
+ X1 ::= X0 'e'
16
+ X2 ::= X1 'l'
17
+ F ::= X2 'p'
18
+
19
+ ## DFA
20
+
21
+ {S0,X0} = A 'h'
22
+ {S1,X1} ::= {S0,X0} 'e'
23
+ {S2,X2} ::= {S1,X1} 'l'
24
+ S3 ::= {S2,X2} 'l'
25
+ F ::= {S2,X2} 'p'
26
+ F ::= S3 'o'
27
+
28
+ P0 = A 'h'
29
+ P1 ::= P0 'e'
30
+ P2 ::= P1 'l'
31
+ S3 ::= P2 'l'
32
+ F ::= P2 'p'
33
+ F ::= S3 'o'
34
+
35
+ ## Tokenizer FA
36
+
37
+ T ::= I 'true' // T0, T1, T2
38
+ F ::= I 'false' // F0, F2, F2, F3
39
+ N ::= I 'null' // N0, N1, N2
40
+ Id ::= I letter
41
+ Id ::= Id letter
42
+ Id ::= Id digit
43
+
44
+ ## Tokenizer DFA
45
+
46
+ {T0,Id} = I 't'
47
+ {T1,Id} = {T0,Id} 'r'
48
+ Id = {T0,Id} letter(except 'r')
49
+ Id = {T0,Id} digit
50
+
51
+ {a..b}{c..d}{e..f}
52
+
53
+ ```js
54
+ const t0 = [[init, one('t')]]
55
+ const t1 = [[t0, one('r')]]
56
+ const t2 = [[t1, one('u')]]
57
+ const t = [[t2, one('e')]]
58
+
59
+ const id = [
60
+ [init, letter]
61
+ [() => id, letter]
62
+ [() => id, digit]
63
+ ]
64
+
65
+ const dfa = ([t, f, n, id]) => ?
66
+ ```
67
+
68
+ ## Set
69
+
70
+ ```js
71
+ const letter = byteSet(['_', '$', ['a', 'z'], ['A', 'Z']])
72
+ ```
73
+
74
+ Letters and digits
75
+
76
+ | | |
77
+ |------|------------|
78
+ |`$` |`0x24` |
79
+ |`0..9`|`0x30..0x39`|
80
+ |`A..Z`|`0x41..0x5A`|
81
+ |`_` |`0x5F` |
82
+ |`a..z`|`0x61..0x7A`|
83
+
84
+ ## Bit set
85
+
86
+ For a byte, it is an array of 8 uint32, bigint (0..2^256-1), or string of 16 characters.
87
+
88
+ ### 16 bit set.
89
+
90
+ It can use an intermediate state.
91
+
92
+ | | | |
93
+ |---|-------|--------|
94
+ |`2`|`4` |`$` |
95
+ |`3`|`..9` |`0..9` |
96
+ |`4`|`1..` |`A..O` |
97
+ |`5`|`..A,F`|`P..Z,_`|
98
+ |`6`|`1..` |`a..o` |
99
+ |`7`|`..A` |`p..z` |
100
+
101
+ ```js
102
+ const init = [
103
+ _, _, i2, _,
104
+ i4, i5, i4, i7,
105
+ _, _, _, _,
106
+ _, _, _, _]
107
+
108
+ const i2 = [
109
+ _, _, _, _,
110
+ id, _, _, _,
111
+ _, _, _, _,
112
+ _, _, _, _]
113
+
114
+ const i3 = [
115
+ id, id, id, id,
116
+ id, id, id, id,
117
+ id, id, _, _,
118
+ _, _, _, _]
119
+
120
+ const i4 = [
121
+ _, id, id, id,
122
+ id, id, id, id,
123
+ id, id, id, id,
124
+ id, id, id, id]
125
+
126
+ const i5 = [
127
+ id, id, id, id,
128
+ id, id, id, id,
129
+ id, id, id, _,
130
+ _, _, _, id]
131
+
132
+ const i6 = [
133
+ id, id, id, id,
134
+ id, id, id, id,
135
+ id, id, id, _,
136
+ _, _, _, _]
137
+ ```
138
+
139
+ ```js
140
+ const init =
141
+ 000_000_001_000
142
+ 010_011_100_101
143
+ 000_000_000_000
144
+ 000_000_000_000
145
+
146
+ const i = [
147
+ // 1
148
+ 0000_1000_0000_0000,
149
+ // 2
150
+ 1111_1111_1100_0000,
151
+ // 3
152
+ 0111_1111_1111_1111,
153
+ // 4
154
+ 1111_1111_1110_0001,
155
+ // 5
156
+ 1111_1111_1110_0000,
157
+ ]
158
+ ```
package/doc/vm.md CHANGED
@@ -133,7 +133,7 @@ struct Object {
133
133
 
134
134
  struct Array {
135
135
  length: u32,
136
- array: [Value; self.lenght],
136
+ array: [Value; self.length],
137
137
  }
138
138
  ```
139
139
 
package/html/module.f.cjs CHANGED
@@ -3,7 +3,7 @@ const { map, flatMap, flat, concat: listConcat } = list
3
3
  const { concat: stringConcat } = require('../types/string/module.f.cjs')
4
4
  const object = require('../types/object/module.f.cjs')
5
5
  const { compose } = require('../types/function/module.f.cjs')
6
- const encoding = require('../text/encoding/utf16/module.f.cjs');
6
+ const encoding = require('../text/utf16/module.f.cjs');
7
7
  const { stringToList } = encoding
8
8
 
9
9
  const { fromCharCode } = String
@@ -2,7 +2,7 @@ const tokenizer = require('./module.f.cjs')
2
2
  const list = require('../../types/list/module.f.cjs')
3
3
  const json = require('../module.f.cjs')
4
4
  const { sort } = require('../../types/object/module.f.cjs')
5
- const encoding = require('../../text/encoding/utf16/module.f.cjs');
5
+ const encoding = require('../../text/utf16/module.f.cjs');
6
6
 
7
7
  /** @type {(s: string) => readonly tokenizer.JsonToken[]} */
8
8
  const tokenizeString = s => list.toArray(tokenizer.tokenize(encoding.stringToList(s)))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.406",
3
+ "version": "0.0.409",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "module.f.cjs",
6
6
  "scripts": {
package/test.f.cjs CHANGED
@@ -22,8 +22,8 @@ require('./commonjs/build/test.f.cjs')
22
22
  require('./types/range/test.f.cjs')
23
23
  require('./html/test.f.cjs')
24
24
  require('./text/test.f.cjs')
25
- require('./text/encoding/utf8/test.f.cjs')
26
- require('./text/encoding/utf16/test.f.cjs')
25
+ require('./text/utf8/test.f.cjs')
26
+ require('./text/utf16/test.f.cjs')
27
27
  require('./com/cs/test.f.cjs')
28
28
  require('./com/cpp/test.f.cjs')
29
29
  require('./nodejs/version/test.f.cjs')
File without changes
@@ -1,8 +1,8 @@
1
- const list = require('../../../types/list/module.f.cjs')
2
- const operator = require('../../../types/function/operator/module.f.cjs')
3
- const array = require('../../../types/array/module.f.cjs')
4
- const { contains } = require('../../../types/range/module.f.cjs')
5
- const { compose } = require('../../../types/function/module.f.cjs')
1
+ const list = require('../../types/list/module.f.cjs')
2
+ const operator = require('../../types/function/operator/module.f.cjs')
3
+ const array = require('../../types/array/module.f.cjs')
4
+ const { contains } = require('../../types/range/module.f.cjs')
5
+ const { compose } = require('../../types/function/module.f.cjs')
6
6
  const { map, flat, stateScan, concat, reduce, flatMap } = list
7
7
 
8
8
  /** @typedef {u16|undefined} WordOrEof */
@@ -1,7 +1,7 @@
1
1
  const encoding = require('./module.f.cjs')
2
- const json = require('../../../json/module.f.cjs')
3
- const { sort } = require('../../../types/object/module.f.cjs')
4
- const { list } = require('../../../types/module.f.cjs')
2
+ const json = require('../../json/module.f.cjs')
3
+ const { sort } = require('../../types/object/module.f.cjs')
4
+ const { list } = require('../../types/module.f.cjs')
5
5
 
6
6
  /** @type {(a: readonly json.Unknown[]) => string} */
7
7
  const stringify = a => json.stringify(sort)(a)
@@ -1,6 +1,6 @@
1
- const list = require('../../../types/list/module.f.cjs')
2
- const operator = require('../../../types/function/operator/module.f.cjs')
3
- const array = require('../../../types/array/module.f.cjs')
1
+ const list = require('../../types/list/module.f.cjs')
2
+ const operator = require('../../types/function/operator/module.f.cjs')
3
+ const array = require('../../types/array/module.f.cjs')
4
4
  const { flatMap } = list
5
5
 
6
6
  /** @typedef {u8|undefined} ByteOrEof */
@@ -1,7 +1,7 @@
1
1
  const encoding = require('./module.f.cjs')
2
- const json = require('../../../json/module.f.cjs')
3
- const { sort } = require('../../../types/object/module.f.cjs')
4
- const { list } = require('../../../types/module.f.cjs')
2
+ const json = require('../../json/module.f.cjs')
3
+ const { sort } = require('../../types/object/module.f.cjs')
4
+ const { list } = require('../../types/module.f.cjs')
5
5
 
6
6
  /** @type {(a: readonly json.Unknown[]) => string} */
7
7
  const stringify = a => json.stringify(sort)(a)