functionalscript 0.0.497 → 0.0.498
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/fsc/module.f.cjs +41 -37
- package/fsc/test.f.cjs +1 -1
- package/json/tokenizer/module.f.cjs +16 -9
- package/package.json +2 -2
package/fsc/module.f.cjs
CHANGED
|
@@ -12,7 +12,7 @@ const { toArray, map } = list
|
|
|
12
12
|
|
|
13
13
|
/** @typedef {readonly[readonly string[], ToResult]} Result */
|
|
14
14
|
|
|
15
|
-
/** @typedef {(
|
|
15
|
+
/** @typedef {(codePoint: number) => Result} ToResult */
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @template T
|
|
@@ -25,10 +25,10 @@ const { toArray, map } = list
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
/** @type {ToResult} */
|
|
28
|
-
const
|
|
28
|
+
const unexpectedSymbol = codePoint => [[`unexpected symbol ${codePoint}`], unexpectedSymbol]
|
|
29
29
|
|
|
30
|
-
/** @type {<T>(
|
|
31
|
-
const def = () =>
|
|
30
|
+
/** @type {<T>(state: T) => ToResult} */
|
|
31
|
+
const def = () => unexpectedSymbol
|
|
32
32
|
|
|
33
33
|
/** @type {<T>(a: CreateToResult<T>) => (b: CreateToResult<T>) => CreateToResult<T>} */
|
|
34
34
|
const union = a => b => {
|
|
@@ -77,42 +77,46 @@ const create = a => {
|
|
|
77
77
|
|
|
78
78
|
const terminal = -1
|
|
79
79
|
|
|
80
|
+
/** @type {() => ToResult} */
|
|
81
|
+
const toInit = () => () => [[], init]
|
|
82
|
+
|
|
80
83
|
const init = create([
|
|
81
|
-
codePointRange(one(terminal))(
|
|
82
|
-
rangeSet(['\t', ' '
|
|
83
|
-
|
|
84
|
-
range('
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
range('
|
|
88
|
-
range('
|
|
89
|
-
range(
|
|
90
|
-
range('
|
|
91
|
-
range('
|
|
92
|
-
range('
|
|
93
|
-
range('
|
|
94
|
-
range('
|
|
95
|
-
range('
|
|
96
|
-
range('
|
|
97
|
-
range('
|
|
98
|
-
range('
|
|
99
|
-
range('
|
|
100
|
-
range('
|
|
101
|
-
range('
|
|
102
|
-
range('
|
|
103
|
-
range('
|
|
104
|
-
range('
|
|
105
|
-
range('
|
|
106
|
-
range('
|
|
107
|
-
range('
|
|
108
|
-
range('
|
|
109
|
-
range('
|
|
110
|
-
range('
|
|
111
|
-
range('
|
|
112
|
-
|
|
113
|
-
])
|
|
84
|
+
codePointRange(one(terminal))(toInit),
|
|
85
|
+
rangeSet(['\t', ' ', '\n', '\r'])(toInit),
|
|
86
|
+
range('!')(() => () => [['!'], unexpectedSymbol]),
|
|
87
|
+
range('"')(() => () => [['"'], unexpectedSymbol]),
|
|
88
|
+
rangeSet(['$', '_', 'AZ', 'az'])(() => c => [[fromCharCode(c)], unexpectedSymbol]),
|
|
89
|
+
range('%')(() => () => [['%'], unexpectedSymbol]),
|
|
90
|
+
range('&')(() => () => [['&'], unexpectedSymbol]),
|
|
91
|
+
range("'")(() => () => [["'"], unexpectedSymbol]),
|
|
92
|
+
range('(')(() => () => [['('], unexpectedSymbol]),
|
|
93
|
+
range(')')(() => () => [[')'], unexpectedSymbol]),
|
|
94
|
+
range('*')(() => () => [['*'], unexpectedSymbol]),
|
|
95
|
+
range('+')(() => () => [['+'], unexpectedSymbol]),
|
|
96
|
+
range(',')(() => () => [[','], unexpectedSymbol]),
|
|
97
|
+
range('-')(() => () => [['-'], unexpectedSymbol]),
|
|
98
|
+
range('.')(() => () => [['.'], unexpectedSymbol]),
|
|
99
|
+
range('/')(() => () => [['/'], unexpectedSymbol]),
|
|
100
|
+
range('09')(() => a => [[fromCharCode(a)], unexpectedSymbol]),
|
|
101
|
+
range(':')(() => () => [[':'], unexpectedSymbol]),
|
|
102
|
+
range(';')(() => () => [[';'], unexpectedSymbol]),
|
|
103
|
+
range('<')(() => () => [['<'], unexpectedSymbol]),
|
|
104
|
+
range('=')(() => () => [['='], unexpectedSymbol]),
|
|
105
|
+
range('>')(() => () => [['>'], unexpectedSymbol]),
|
|
106
|
+
range('?')(() => () => [['?'], unexpectedSymbol]),
|
|
107
|
+
range('[')(() => () => [['['], unexpectedSymbol]),
|
|
108
|
+
range(']')(() => () => [[']'], unexpectedSymbol]),
|
|
109
|
+
range('^')(() => () => [['^'], unexpectedSymbol]),
|
|
110
|
+
range('`')(() => () => [['`'], unexpectedSymbol]),
|
|
111
|
+
range('{')(() => () => [['{'], unexpectedSymbol]),
|
|
112
|
+
range('|')(() => () => [['|'], unexpectedSymbol]),
|
|
113
|
+
range('}')(() => () => [['}'], unexpectedSymbol]),
|
|
114
|
+
range('~')(() => () => [['~'], unexpectedSymbol]),
|
|
115
|
+
])(void 0)
|
|
114
116
|
|
|
115
117
|
module.exports = {
|
|
118
|
+
/** @readonly */
|
|
119
|
+
terminal,
|
|
116
120
|
/** @readonly */
|
|
117
121
|
init,
|
|
118
122
|
}
|
package/fsc/test.f.cjs
CHANGED
|
@@ -84,7 +84,7 @@ const rangeSetWhiteSpace = [
|
|
|
84
84
|
one(space)
|
|
85
85
|
]
|
|
86
86
|
|
|
87
|
-
const
|
|
87
|
+
const rangeSetTerminalForNumber = [
|
|
88
88
|
one(ht),
|
|
89
89
|
one(lf),
|
|
90
90
|
one(cr),
|
|
@@ -134,15 +134,22 @@ const rangeCapitalAF = range('AF')
|
|
|
134
134
|
|
|
135
135
|
/** @typedef {{ readonly kind: 'escapeChar', readonly value: string}} ParseEscapeCharState */
|
|
136
136
|
|
|
137
|
-
/**
|
|
137
|
+
/**
|
|
138
|
+
* @typedef {{
|
|
139
|
+
* readonly kind: 'unicodeChar'
|
|
140
|
+
* readonly value: string
|
|
141
|
+
* readonly unicode: number
|
|
142
|
+
* readonly hexIndex: number
|
|
143
|
+
* }} ParseUnicodeCharState
|
|
144
|
+
*/
|
|
138
145
|
|
|
139
146
|
/**
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
147
|
+
* @typedef {{
|
|
148
|
+
* readonly kind: 'number',
|
|
149
|
+
* readonly numberKind: '0' | '-' | 'int' | '.' | 'fractional' | 'e' | 'e+' | 'e-' | 'expDigits'
|
|
150
|
+
* readonly value: string
|
|
144
151
|
* }} ParseNumberState
|
|
145
|
-
|
|
152
|
+
*/
|
|
146
153
|
|
|
147
154
|
/** @typedef {{ readonly kind: 'invalidNumber'}} InvalidNumberState */
|
|
148
155
|
|
|
@@ -323,12 +330,12 @@ const parseNumberStateOp = create(invalidNumberToToken)([
|
|
|
323
330
|
rangeSetFunc([one(latinSmallLetterE), one(latinCapitalLetterE)])(expToToken),
|
|
324
331
|
rangeFunc(one(hyphenMinus))(hyphenMinusToToken),
|
|
325
332
|
rangeFunc(one(plusSign))(plusSignToToken),
|
|
326
|
-
rangeSetFunc(
|
|
333
|
+
rangeSetFunc(rangeSetTerminalForNumber)(terminalToToken)
|
|
327
334
|
])
|
|
328
335
|
|
|
329
336
|
/** @type {(state: InvalidNumberState) => (input: number) => readonly[list.List<JsonToken>, TokenizerState]} */
|
|
330
337
|
const invalidNumberStateOp = create(() => () => [empty, { kind: 'invalidNumber' }])([
|
|
331
|
-
rangeSetFunc(
|
|
338
|
+
rangeSetFunc(rangeSetTerminalForNumber)(() => input => {
|
|
332
339
|
const next = tokenizeOp({ kind: 'initial' })(input)
|
|
333
340
|
return [{ first: { kind: 'error', message: 'invalid number' }, tail: next[0] }, next[1]]
|
|
334
341
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functionalscript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.498",
|
|
4
4
|
"description": "FunctionalScript is a functional subset of JavaScript",
|
|
5
5
|
"main": "module.f.cjs",
|
|
6
6
|
"scripts": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://github.com/functionalscript/functionalscript#readme",
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@types/node": "^18.11.
|
|
33
|
+
"@types/node": "^18.11.18",
|
|
34
34
|
"typescript": "^4.9.4"
|
|
35
35
|
}
|
|
36
36
|
}
|