functionalscript 0.0.536 → 0.0.538

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/README.md CHANGED
@@ -22,19 +22,18 @@ Learn more about
22
22
  In FunctionalScript:
23
23
 
24
24
  - Any module is a valid JavaScript module. No additional build steps are required.
25
- - Code should not have [side-effects](https://en.wikipedia.org/wiki/Side_effect_(computer_science)). Any JavaScript statement, expression, or function which has a side effect is not allowed in FunctionalScript. There are no exceptions to this rule, such as `unsafe` code, which can be found in Rust, C#, and other languages.
26
- - A module can't depend on a non FunctionalScript module.
25
+ - Code should not have [side-effects](https://en.wikipedia.org/wiki/Side_effect_(computer_science)). Any JavaScript statement, expression, or function that has a side effect is not allowed in FunctionalScript. There are no exceptions to this rule, such as `unsafe` code, which can be found in Rust, C#, and other languages.
26
+ - A module can depend only on another FunctionalScript module.
27
27
  - It also has no standard library. Only a safe subset of standard JavaScript API can be used without referencing other modules.
28
28
 
29
29
  ## Applications
30
30
 
31
- FunctionalScript code can be used
32
-
31
+ FunctionalScript code can be used:
33
32
  - in any JavaScript/TypeScript application,
34
33
  - as a JSON with expressions,
35
34
  - as a query language.
36
35
 
37
36
  ## Sponsors
38
37
 
39
- - [KirillOsenkov](https://github.com/KirillOsenkov)
40
- - [antkmsft](https://github.com/antkmsft)
38
+ - [KirillOsenkov](https://github.com/KirillOsenkov),
39
+ - [antkmsft](https://github.com/antkmsft).
@@ -32,6 +32,13 @@ const { fromMap } = require('../../types/object/module.f.cjs')
32
32
 
33
33
  /** @typedef {list.List<JsonStackElement>} JsonStack */
34
34
 
35
+ /**
36
+ * @typedef {{
37
+ * readonly status: 'module'
38
+ * readonly stage: 'module' | '.' | 'exports' | '='
39
+ * }} StateModule
40
+ */
41
+
35
42
  /**
36
43
  * @typedef {{
37
44
  * readonly status: '' | '[' | '[v' | '[,' | '{' | '{k' | '{:' | '{v' | '{,'
@@ -56,12 +63,41 @@ const { fromMap } = require('../../types/object/module.f.cjs')
56
63
 
57
64
  /**
58
65
  * @typedef {|
66
+ * StateModule |
59
67
  * StateParse |
60
68
  * StateResult |
61
69
  * StateError
62
70
  * } FjsonState
63
71
  */
64
72
 
73
+ /** @type {(token: tokenizer.FjsonToken) => (state: StateModule) => FjsonState}} */
74
+ const parseModuleOp = token => state => {
75
+ switch(state.stage)
76
+ {
77
+ case 'module':
78
+ {
79
+ if (token.kind === 'id' && token.value === 'module') return { status: 'module', stage: '.' }
80
+ break;
81
+ }
82
+ case '.':
83
+ {
84
+ if (token.kind === '.') return { status: 'module', stage: 'exports' }
85
+ break;
86
+ }
87
+ case 'exports':
88
+ {
89
+ if (token.kind === 'id' && token.value === 'exports') return { status: 'module', stage: '=' }
90
+ break;
91
+ }
92
+ case '=':
93
+ {
94
+ if (token.kind === '=') return { status: '', top: null, stack: null }
95
+ if (token.kind === 'ws') return state
96
+ }
97
+ }
98
+ return { status: 'error', message: 'unexpected token' }
99
+ }
100
+
65
101
  /** @type {(obj: JsonObject) => (key: string) => JsonObject} */
66
102
  const addKeyToObject = obj => key => ({ kind: 'object', values: obj.values, key: key })
67
103
 
@@ -143,6 +179,7 @@ const parseValueOp = token => state => {
143
179
  if (isValueToken(token)) { return pushValue(state)(tokenToValue(token)) }
144
180
  if (token.kind === '[') { return startArray(state) }
145
181
  if (token.kind === '{') { return startObject(state) }
182
+ if (token.kind === 'ws') { return state }
146
183
  return { status: 'error', message: 'unexpected token' }
147
184
  }
148
185
 
@@ -152,6 +189,7 @@ const parseArrayStartOp = token => state => {
152
189
  if (token.kind === '[') { return startArray(state) }
153
190
  if (token.kind === ']') { return endArray(state) }
154
191
  if (token.kind === '{') { return startObject(state) }
192
+ if (token.kind === 'ws') { return state }
155
193
  return { status: 'error', message: 'unexpected token' }
156
194
  }
157
195
 
@@ -159,6 +197,7 @@ const parseArrayStartOp = token => state => {
159
197
  const parseArrayValueOp = token => state => {
160
198
  if (token.kind === ']') { return endArray(state) }
161
199
  if (token.kind === ',') { return { status: '[,', top: state.top, stack: state.stack } }
200
+ if (token.kind === 'ws') { return state }
162
201
  return { status: 'error', message: 'unexpected token' }
163
202
  }
164
203
 
@@ -166,12 +205,14 @@ const parseArrayValueOp = token => state => {
166
205
  const parseObjectStartOp = token => state => {
167
206
  if (token.kind === 'string') { return pushKey(state)(token.value) }
168
207
  if (token.kind === '}') { return endObject(state) }
208
+ if (token.kind === 'ws') { return state }
169
209
  return { status: 'error', message: 'unexpected token' }
170
210
  }
171
211
 
172
212
  /** @type {(token: tokenizer.FjsonToken) => (state: StateParse) => FjsonState}} */
173
213
  const parseObjectKeyOp = token => state => {
174
214
  if (token.kind === ':') { return { status: '{:', top: state.top, stack: state.stack } }
215
+ if (token.kind === 'ws') { return state }
175
216
  return { status: 'error', message: 'unexpected token' }
176
217
  }
177
218
 
@@ -180,6 +221,7 @@ const parseObjectColonOp = token => state => {
180
221
  if (isValueToken(token)) { return pushValue(state)(tokenToValue(token)) }
181
222
  if (token.kind === '[') { return startArray(state) }
182
223
  if (token.kind === '{') { return startObject(state) }
224
+ if (token.kind === 'ws') { return state }
183
225
  return { status: 'error', message: 'unexpected token' }
184
226
  }
185
227
 
@@ -187,18 +229,21 @@ const parseObjectColonOp = token => state => {
187
229
  const parseObjectNextOp = token => state => {
188
230
  if (token.kind === '}') { return endObject(state) }
189
231
  if (token.kind === ',') { return { status: '{,', top: state.top, stack: state.stack } }
232
+ if (token.kind === 'ws') { return state }
190
233
  return { status: 'error', message: 'unexpected token' }
191
234
  }
192
235
 
193
236
  /** @type {(token: tokenizer.FjsonToken) => (state: StateParse) => FjsonState}} */
194
237
  const parseObjectCommaOp = token => state => {
195
238
  if (token.kind === 'string') { return pushKey(state)(token.value) }
239
+ if (token.kind === 'ws') { return state }
196
240
  return { status: 'error', message: 'unexpected token' }
197
241
  }
198
242
 
199
243
  /** @type {operator.Fold<tokenizer.FjsonToken, FjsonState>} */
200
244
  const foldOp = token => state => {
201
245
  switch (state.status) {
246
+ case 'module': return parseModuleOp(token)(state)
202
247
  case 'result': return { status: 'error', message: 'unexpected token' }
203
248
  case 'error': return { status: 'error', message: state.message }
204
249
  case '': return parseValueOp(token)(state)
@@ -215,7 +260,7 @@ const foldOp = token => state => {
215
260
 
216
261
  /** @type {(tokenList: list.List<tokenizer.FjsonToken>) => result.Result<fjson.Unknown, string>} */
217
262
  const parse = tokenList => {
218
- const state = fold(foldOp)({ status: '', top: null, stack: null })(tokenList)
263
+ const state = fold(foldOp)({ status: 'module', stage: 'module' })(tokenList)
219
264
  switch (state.status) {
220
265
  case 'result': return result.ok(state.value)
221
266
  case 'error': return result.error(state.message)
@@ -13,97 +13,97 @@ const stringify = fjson.stringify(sort)
13
13
  module.exports = {
14
14
  valid: [
15
15
  () => {
16
- const tokenList = tokenizeString('null')
16
+ const tokenList = tokenizeString('module.exports=null')
17
17
  const obj = parser.parse(tokenList)
18
18
  const result = stringify(obj)
19
19
  if (result !== '["ok",null]') { throw result }
20
20
  },
21
21
  () => {
22
- const tokenList = tokenizeString('true')
22
+ const tokenList = tokenizeString('module.exports=true')
23
23
  const obj = parser.parse(tokenList)
24
24
  const result = stringify(obj)
25
25
  if (result !== '["ok",true]') { throw result }
26
26
  },
27
27
  () => {
28
- const tokenList = tokenizeString('false')
28
+ const tokenList = tokenizeString('module.exports=false')
29
29
  const obj = parser.parse(tokenList)
30
30
  const result = stringify(obj)
31
31
  if (result !== '["ok",false]') { throw result }
32
32
  },
33
33
  () => {
34
- const tokenList = tokenizeString('0.1')
34
+ const tokenList = tokenizeString('module.exports=0.1')
35
35
  const obj = parser.parse(tokenList)
36
36
  const result = stringify(obj)
37
37
  if (result !== '["ok",0.1]') { throw result }
38
38
  },
39
39
  () => {
40
- const tokenList = tokenizeString('1.1e+2')
40
+ const tokenList = tokenizeString('module.exports=1.1e+2')
41
41
  const obj = parser.parse(tokenList)
42
42
  const result = stringify(obj)
43
43
  if (result !== '["ok",110]') { throw result }
44
44
  },
45
45
  () => {
46
- const tokenList = tokenizeString('"abc"')
46
+ const tokenList = tokenizeString('module.exports="abc"')
47
47
  const obj = parser.parse(tokenList)
48
48
  const result = stringify(obj)
49
49
  if (result !== '["ok","abc"]') { throw result }
50
50
  },
51
51
  () => {
52
- const tokenList = tokenizeString('[]')
52
+ const tokenList = tokenizeString('module.exports=[]')
53
53
  const obj = parser.parse(tokenList)
54
54
  const result = stringify(obj)
55
55
  if (result !== '["ok",[]]') { throw result }
56
56
  },
57
57
  () => {
58
- const tokenList = tokenizeString('[1]')
58
+ const tokenList = tokenizeString('module.exports=[1]')
59
59
  const obj = parser.parse(tokenList)
60
60
  const result = stringify(obj)
61
61
  if (result !== '["ok",[1]]') { throw result }
62
62
  },
63
63
  () => {
64
- const tokenList = tokenizeString('[[]]')
64
+ const tokenList = tokenizeString('module.exports=[[]]')
65
65
  const obj = parser.parse(tokenList)
66
66
  const result = stringify(obj)
67
67
  if (result !== '["ok",[[]]]') { throw result }
68
68
  },
69
69
  () => {
70
- const tokenList = tokenizeString('[0,[1,[2,[]]],3]')
70
+ const tokenList = tokenizeString('module.exports=[0,[1,[2,[]]],3]')
71
71
  const obj = parser.parse(tokenList)
72
72
  const result = stringify(obj)
73
73
  if (result !== '["ok",[0,[1,[2,[]]],3]]') { throw result }
74
74
  },
75
75
  () => {
76
- const tokenList = tokenizeString('{}')
76
+ const tokenList = tokenizeString('module.exports={}')
77
77
  const obj = parser.parse(tokenList)
78
78
  const result = stringify(obj)
79
79
  if (result !== '["ok",{}]') { throw result }
80
80
  },
81
81
  () => {
82
- const tokenList = tokenizeString('[{}]')
82
+ const tokenList = tokenizeString('module.exports=[{}]')
83
83
  const obj = parser.parse(tokenList)
84
84
  const result = stringify(obj)
85
85
  if (result !== '["ok",[{}]]') { throw result }
86
86
  },
87
87
  () => {
88
- const tokenList = tokenizeString('{"a":true,"b":false,"c":null}')
88
+ const tokenList = tokenizeString('module.exports={"a":true,"b":false,"c":null}')
89
89
  const obj = parser.parse(tokenList)
90
90
  const result = stringify(obj)
91
91
  if (result !== '["ok",{"a":true,"b":false,"c":null}]') { throw result }
92
92
  },
93
93
  () => {
94
- const tokenList = tokenizeString('{"a":{"b":{"c":["d"]}}}')
94
+ const tokenList = tokenizeString('module.exports={"a":{"b":{"c":["d"]}}}')
95
95
  const obj = parser.parse(tokenList)
96
96
  const result = stringify(obj)
97
97
  if (result !== '["ok",{"a":{"b":{"c":["d"]}}}]') { throw result }
98
98
  },
99
99
  () => {
100
- const tokenList = tokenizeString('1234567890n')
100
+ const tokenList = tokenizeString('module.exports=1234567890n')
101
101
  const obj = parser.parse(tokenList)
102
102
  const result = stringify(obj)
103
103
  if (result !== '["ok",1234567890n]') { throw result }
104
104
  },
105
105
  () => {
106
- const tokenList = tokenizeString('[1234567890n]')
106
+ const tokenList = tokenizeString('module.exports=[1234567890n]')
107
107
  const obj = parser.parse(tokenList)
108
108
  const result = stringify(obj)
109
109
  if (result !== '["ok",[1234567890n]]') { throw result }
@@ -111,145 +111,181 @@ module.exports = {
111
111
  ],
112
112
  invalid: [
113
113
  () => {
114
- const tokenList = tokenizeString('')
114
+ const tokenList = tokenizeString('module.exports=')
115
115
  const obj = parser.parse(tokenList)
116
116
  const result = stringify(obj)
117
117
  if (result !== '["error","unexpected end"]') { throw result }
118
118
  },
119
119
  () => {
120
- const tokenList = tokenizeString('"123')
120
+ const tokenList = tokenizeString('module.exports="123')
121
121
  const obj = parser.parse(tokenList)
122
122
  const result = stringify(obj)
123
123
  if (result !== '["error","unexpected token"]') { throw result }
124
124
  },
125
125
  () => {
126
- const tokenList = tokenizeString('[,]')
126
+ const tokenList = tokenizeString('module.exports=[,]')
127
127
  const obj = parser.parse(tokenList)
128
128
  const result = stringify(obj)
129
129
  if (result !== '["error","unexpected token"]') { throw result }
130
130
  },
131
131
  () => {
132
- const tokenList = tokenizeString('[1 2]')
132
+ const tokenList = tokenizeString('module.exports=[1 2]')
133
133
  const obj = parser.parse(tokenList)
134
134
  const result = stringify(obj)
135
135
  if (result !== '["error","unexpected token"]') { throw result }
136
136
  },
137
137
  () => {
138
- const tokenList = tokenizeString('[1,,2]')
138
+ const tokenList = tokenizeString('module.exports=[1,,2]')
139
139
  const obj = parser.parse(tokenList)
140
140
  const result = stringify(obj)
141
141
  if (result !== '["error","unexpected token"]') { throw result }
142
142
  },
143
143
  () => {
144
- const tokenList = tokenizeString('[]]')
144
+ const tokenList = tokenizeString('module.exports=[]]')
145
145
  const obj = parser.parse(tokenList)
146
146
  const result = stringify(obj)
147
147
  if (result !== '["error","unexpected token"]') { throw result }
148
148
  },
149
149
  () => {
150
- const tokenList = tokenizeString('["a"')
150
+ const tokenList = tokenizeString('module.exports=["a"')
151
151
  const obj = parser.parse(tokenList)
152
152
  const result = stringify(obj)
153
153
  if (result !== '["error","unexpected end"]') { throw result }
154
154
  },
155
155
  () => {
156
- const tokenList = tokenizeString('[1,]')
156
+ const tokenList = tokenizeString('module.exports=[1,]')
157
157
  const obj = parser.parse(tokenList)
158
158
  const result = stringify(obj)
159
159
  if (result !== '["error","unexpected token"]') { throw result }
160
160
  },
161
161
  () => {
162
- const tokenList = tokenizeString('[,1]')
162
+ const tokenList = tokenizeString('module.exports=[,1]')
163
163
  const obj = parser.parse(tokenList)
164
164
  const result = stringify(obj)
165
165
  if (result !== '["error","unexpected token"]') { throw result }
166
166
  },
167
167
  () => {
168
- const tokenList = tokenizeString('[:]')
168
+ const tokenList = tokenizeString('module.exports=[:]')
169
169
  const obj = parser.parse(tokenList)
170
170
  const result = stringify(obj)
171
171
  if (result !== '["error","unexpected token"]') { throw result }
172
172
  },
173
173
  () => {
174
- const tokenList = tokenizeString(']')
174
+ const tokenList = tokenizeString('module.exports=]')
175
175
  const obj = parser.parse(tokenList)
176
176
  const result = stringify(obj)
177
177
  if (result !== '["error","unexpected token"]') { throw result }
178
178
  },
179
179
  () => {
180
- const tokenList = tokenizeString('{,}')
180
+ const tokenList = tokenizeString('module.exports={,}')
181
181
  const obj = parser.parse(tokenList)
182
182
  const result = stringify(obj)
183
183
  if (result !== '["error","unexpected token"]') { throw result }
184
184
  },
185
185
  () => {
186
- const tokenList = tokenizeString('{1:2}')
186
+ const tokenList = tokenizeString('module.exports={1:2}')
187
187
  const obj = parser.parse(tokenList)
188
188
  const result = stringify(obj)
189
189
  if (result !== '["error","unexpected token"]') { throw result }
190
190
  },
191
191
  () => {
192
- const tokenList = tokenizeString('{"1"2}')
192
+ const tokenList = tokenizeString('module.exports={"1"2}')
193
193
  const obj = parser.parse(tokenList)
194
194
  const result = stringify(obj)
195
195
  if (result !== '["error","unexpected token"]') { throw result }
196
196
  },
197
197
  () => {
198
- const tokenList = tokenizeString('{"1"::2}')
198
+ const tokenList = tokenizeString('module.exports={"1"::2}')
199
199
  const obj = parser.parse(tokenList)
200
200
  const result = stringify(obj)
201
201
  if (result !== '["error","unexpected token"]') { throw result }
202
202
  },
203
203
  () => {
204
- const tokenList = tokenizeString('{"1":2,,"3":4')
204
+ const tokenList = tokenizeString('module.exports={"1":2,,"3":4')
205
205
  const obj = parser.parse(tokenList)
206
206
  const result = stringify(obj)
207
207
  if (result !== '["error","unexpected token"]') { throw result }
208
208
  },
209
209
  () => {
210
- const tokenList = tokenizeString('{}}')
210
+ const tokenList = tokenizeString('module.exports={}}')
211
211
  const obj = parser.parse(tokenList)
212
212
  const result = stringify(obj)
213
213
  if (result !== '["error","unexpected token"]') { throw result }
214
214
  },
215
215
  () => {
216
- const tokenList = tokenizeString('{"1":2')
216
+ const tokenList = tokenizeString('module.exports={"1":2')
217
217
  const obj = parser.parse(tokenList)
218
218
  const result = stringify(obj)
219
219
  if (result !== '["error","unexpected end"]') { throw result }
220
220
  },
221
221
  () => {
222
- const tokenList = tokenizeString('{"1":2,}')
222
+ const tokenList = tokenizeString('module.exports={"1":2,}')
223
+ const obj = parser.parse(tokenList)
224
+ const result = stringify(obj)
225
+ if (result !== '["error","unexpected token"]') { throw result }
226
+ },
227
+ () => {
228
+ const tokenList = tokenizeString('module.exports={,"1":2}')
229
+ const obj = parser.parse(tokenList)
230
+ const result = stringify(obj)
231
+ if (result !== '["error","unexpected token"]') { throw result }
232
+ },
233
+ () => {
234
+ const tokenList = tokenizeString('module.exports=}')
223
235
  const obj = parser.parse(tokenList)
224
236
  const result = stringify(obj)
225
237
  if (result !== '["error","unexpected token"]') { throw result }
226
238
  },
227
239
  () => {
228
- const tokenList = tokenizeString('{,"1":2}')
240
+ const tokenList = tokenizeString('module.exports=[{]}')
229
241
  const obj = parser.parse(tokenList)
230
242
  const result = stringify(obj)
231
243
  if (result !== '["error","unexpected token"]') { throw result }
232
244
  },
233
245
  () => {
234
- const tokenList = tokenizeString('}')
246
+ const tokenList = tokenizeString('module.exports={[}]')
235
247
  const obj = parser.parse(tokenList)
236
248
  const result = stringify(obj)
237
249
  if (result !== '["error","unexpected token"]') { throw result }
238
250
  },
239
251
  () => {
240
- const tokenList = tokenizeString('[{]}')
252
+ const tokenList = tokenizeString('module.exports=10-5')
241
253
  const obj = parser.parse(tokenList)
242
254
  const result = stringify(obj)
243
255
  if (result !== '["error","unexpected token"]') { throw result }
244
256
  },
257
+ ],
258
+ validWhiteSpaces:[
259
+ () => {
260
+ const tokenList = tokenizeString('module.exports=[ 0 , 1 , 2 ]')
261
+ const obj = parser.parse(tokenList)
262
+ const result = stringify(obj)
263
+ if (result !== '["ok",[0,1,2]]') { throw result }
264
+ },
265
+ () => {
266
+ const tokenList = tokenizeString('module.exports={ "a" : 0 , "b" : 1 }')
267
+ const obj = parser.parse(tokenList)
268
+ const result = stringify(obj)
269
+ if (result !== '["ok",{"a":0,"b":1}]') { throw result }
270
+ },
271
+ ],
272
+ validModule:[
273
+ () => {
274
+ const tokenList = tokenizeString('module.exports = null')
275
+ const obj = parser.parse(tokenList)
276
+ const result = stringify(obj)
277
+ if (result !== '["ok",null]') { throw result }
278
+ },
279
+ ],
280
+ invalidModule:[
245
281
  () => {
246
- const tokenList = tokenizeString('{[}]')
282
+ const tokenList = tokenizeString('null')
247
283
  const obj = parser.parse(tokenList)
248
284
  const result = stringify(obj)
249
285
  if (result !== '["error","unexpected token"]') { throw result }
250
286
  },
251
287
  () => {
252
- const tokenList = tokenizeString('10-5')
288
+ const tokenList = tokenizeString('module=null')
253
289
  const obj = parser.parse(tokenList)
254
290
  const result = stringify(obj)
255
291
  if (result !== '["error","unexpected token"]') { throw result }
@@ -7,12 +7,13 @@ const jsTokenizer = require('../../js/tokenizer/module.f.cjs')
7
7
  /**
8
8
  * @typedef {|
9
9
  * {readonly kind: 'true' | 'false' | 'null'} |
10
- * {readonly kind: '{' | '}' | ':' | ',' | '[' | ']' } |
10
+ * {readonly kind: '{' | '}' | ':' | ',' | '[' | ']' | '.' | '=' } |
11
11
  * jsTokenizer.StringToken |
12
12
  * jsTokenizer.NumberToken |
13
13
  * jsTokenizer.ErrorToken |
14
14
  * jsTokenizer.IdToken |
15
- * jsTokenizer.BigIntToken
15
+ * jsTokenizer.BigIntToken |
16
+ * jsTokenizer.WhitespaceToken
16
17
  * } FjsonToken
17
18
  */
18
19
 
@@ -41,13 +42,15 @@ const mapToken = input =>
41
42
  case ',':
42
43
  case '[':
43
44
  case ']':
45
+ case '.':
46
+ case '=':
44
47
  case 'true':
45
48
  case 'false':
46
49
  case 'null':
47
50
  case 'string':
48
51
  case 'number':
52
+ case 'ws':
49
53
  case 'error': return [input]
50
- case 'ws': return empty
51
54
  default: return jsTokenizer.isKeywordToken(input) ? [{ kind: 'id', value: input.kind }] : [{ kind: 'error', message: 'invalid token' }]
52
55
  }
53
56
  }
@@ -45,7 +45,7 @@ module.exports = {
45
45
  },
46
46
  () => {
47
47
  const result = stringify(tokenizeString('{ \t\n\r}'))
48
- if (result !== '[{"kind":"{"},{"kind":"}"}]') { throw result }
48
+ if (result !== '[{"kind":"{"},{"kind":"ws"},{"kind":"}"}]') { throw result }
49
49
  },
50
50
  () => {
51
51
  const result = stringify(tokenizeString('""'))
@@ -61,7 +61,7 @@ module.exports = {
61
61
  },
62
62
  () => {
63
63
  const result = stringify(tokenizeString('"value1" "value2"'))
64
- if (result !== '[{"kind":"string","value":"value1"},{"kind":"string","value":"value2"}]') { throw result }
64
+ if (result !== '[{"kind":"string","value":"value1"},{"kind":"ws"},{"kind":"string","value":"value2"}]') { throw result }
65
65
  },
66
66
  () => {
67
67
  const result = stringify(tokenizeString('"'))
@@ -129,11 +129,11 @@ module.exports = {
129
129
  },
130
130
  () => {
131
131
  const result = stringify(tokenizeString('1 2'))
132
- if (result !== '[{"bf":[1n,0],"kind":"number","value":"1"},{"bf":[2n,0],"kind":"number","value":"2"}]') { throw result }
132
+ if (result !== '[{"bf":[1n,0],"kind":"number","value":"1"},{"kind":"ws"},{"bf":[2n,0],"kind":"number","value":"2"}]') { throw result }
133
133
  },
134
134
  () => {
135
135
  const result = stringify(tokenizeString('0. 2'))
136
- if (result !== '[{"kind":"error","message":"invalid number"},{"bf":[2n,0],"kind":"number","value":"2"}]') { throw result }
136
+ if (result !== '[{"kind":"error","message":"invalid number"},{"kind":"ws"},{"bf":[2n,0],"kind":"number","value":"2"}]') { throw result }
137
137
  },
138
138
  () => {
139
139
  const result = stringify(tokenizeString('10-0'))
@@ -169,7 +169,7 @@ module.exports = {
169
169
  },
170
170
  () => {
171
171
  const result = stringify(tokenizeString('-.123'))
172
- if (result !== '[{"kind":"error","message":"invalid token"},{"kind":"error","message":"invalid token"},{"bf":[123n,0],"kind":"number","value":"123"}]') { throw result }
172
+ if (result !== '[{"kind":"error","message":"invalid token"},{"kind":"."},{"bf":[123n,0],"kind":"number","value":"123"}]') { throw result }
173
173
  },
174
174
  () => {
175
175
  const result = stringify(tokenizeString('0.01'))
@@ -245,11 +245,11 @@ module.exports = {
245
245
  },
246
246
  () => {
247
247
  const result = stringify(tokenizeString('123 _123'))
248
- if (result !== '[{"bf":[123n,0],"kind":"number","value":"123"},{"kind":"id","value":"_123"}]') { throw result }
248
+ if (result !== '[{"bf":[123n,0],"kind":"number","value":"123"},{"kind":"ws"},{"kind":"id","value":"_123"}]') { throw result }
249
249
  },
250
250
  () => {
251
251
  const result = stringify(tokenizeString('123 $123'))
252
- if (result !== '[{"bf":[123n,0],"kind":"number","value":"123"},{"kind":"id","value":"$123"}]') { throw result }
252
+ if (result !== '[{"bf":[123n,0],"kind":"number","value":"123"},{"kind":"ws"},{"kind":"id","value":"$123"}]') { throw result }
253
253
  },
254
254
  () => {
255
255
  const result = stringify(tokenizeString('123_123'))
@@ -121,15 +121,16 @@ const {
121
121
  /**
122
122
  * @typedef {|
123
123
  * {readonly kind: '{' | '}' | ':' | ',' | '[' | ']' } |
124
+ * {readonly kind: '.' | '=' } |
124
125
  * {readonly kind: '(' | ')' } |
125
126
  * {readonly kind: '==' | '!=' | '===' | '!==' | '>' | '>=' | '<' | '<=' } |
126
127
  * {readonly kind: '+' | '-' | '*' | '/' | '%' | '++' | '--' | '**' } |
127
- * {readonly kind: '=' | '+=' | '-=' | '*=' | '/=' | '%=' | '**='} |
128
+ * {readonly kind: '+=' | '-=' | '*=' | '/=' | '%=' | '**='} |
128
129
  * {readonly kind: '&' | '|' | '^' | '~' | '<<' | '>>' | '>>>' } |
129
130
  * {readonly kind: '&=' | '|=' | '^=' | '<<=' | '>>=' | '>>>='} |
130
131
  * {readonly kind: '&&' | '||' | '!' | '??' } |
131
132
  * {readonly kind: '&&=' | '||=' | '??=' } |
132
- * {readonly kind: '?' | '?.' | '.' | '=>'}
133
+ * {readonly kind: '?' | '?.' | '=>'}
133
134
  * } OperatorToken
134
135
  */
135
136
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.536",
3
+ "version": "0.0.538",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "module.f.cjs",
6
6
  "scripts": {