functionalscript 0.0.407 → 0.0.408
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 +158 -0
- package/package.json +1 -1
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
|
+
```
|