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 CHANGED
@@ -12,7 +12,7 @@ const { toArray, map } = list
12
12
 
13
13
  /** @typedef {readonly[readonly string[], ToResult]} Result */
14
14
 
15
- /** @typedef {(a: number) => Result} ToResult */
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 unknownSymbol = a => [[`unknown symbol ${a}`], unknownSymbol]
28
+ const unexpectedSymbol = codePoint => [[`unexpected symbol ${codePoint}`], unexpectedSymbol]
29
29
 
30
- /** @type {<T>(a: T) => ToResult} */
31
- const def = () => unknownSymbol
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))(() => () => [[], unknownSymbol]),
82
- rangeSet(['\t', ' '])(() => () => [[' '], unknownSymbol]),
83
- rangeSet(['\n', '\r'])(() => () => [['\n'], unknownSymbol]),
84
- range('!')(() => () => [['!'], unknownSymbol]),
85
- range('"')(() => () => [['"'], unknownSymbol]),
86
- rangeSet(['$', '_', 'AZ', 'az'])(() => c => [[fromCharCode(c)], unknownSymbol]),
87
- range('%')(() => () => [['%'], unknownSymbol]),
88
- range('&')(() => () => [['&'], unknownSymbol]),
89
- range("'")(() => () => [["'"], unknownSymbol]),
90
- range('(')(() => () => [['('], unknownSymbol]),
91
- range(')')(() => () => [[')'], unknownSymbol]),
92
- range('*')(() => () => [['*'], unknownSymbol]),
93
- range('+')(() => () => [['+'], unknownSymbol]),
94
- range(',')(() => () => [[','], unknownSymbol]),
95
- range('-')(() => () => [['-'], unknownSymbol]),
96
- range('.')(() => () => [['.'], unknownSymbol]),
97
- range('/')(() => () => [['/'], unknownSymbol]),
98
- range('09')(() => a => [[fromCharCode(a)], unknownSymbol]),
99
- range(':')(() => () => [[':'], unknownSymbol]),
100
- range(';')(() => () => [[';'], unknownSymbol]),
101
- range('<')(() => () => [['<'], unknownSymbol]),
102
- range('=')(() => () => [['='], unknownSymbol]),
103
- range('>')(() => () => [['>'], unknownSymbol]),
104
- range('?')(() => () => [['?'], unknownSymbol]),
105
- range('[')(() => () => [['['], unknownSymbol]),
106
- range(']')(() => () => [[']'], unknownSymbol]),
107
- range('^')(() => () => [['^'], unknownSymbol]),
108
- range('`')(() => () => [['`'], unknownSymbol]),
109
- range('{')(() => () => [['{'], unknownSymbol]),
110
- range('|')(() => () => [['|'], unknownSymbol]),
111
- range('}')(() => () => [['}'], unknownSymbol]),
112
- range('~')(() => () => [['~'], unknownSymbol]),
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
@@ -6,7 +6,7 @@ const s = stringify(i => i)
6
6
  /** @type {(v: string) => string} */
7
7
  const f = v => {
8
8
  const n = one(v)
9
- return s(_.init(null)(n)[0])
9
+ return s(_.init(n)[0])
10
10
  }
11
11
 
12
12
  module.exports = {
@@ -84,7 +84,7 @@ const rangeSetWhiteSpace = [
84
84
  one(space)
85
85
  ]
86
86
 
87
- const rangeSetTerminalForNumer = [
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
- /** @typedef {{ readonly kind: 'unicodeChar', readonly value: string, readonly unicode: number, readonly hexIndex: number}} ParseUnicodeCharState */
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
- * @typedef {{
141
- * readonly kind: 'number',
142
- * readonly numberKind: '0' | '-' | 'int' | '.' | 'fractional' | 'e' | 'e+' | 'e-' | 'expDigits'
143
- * readonly value: string
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(rangeSetTerminalForNumer)(terminalToToken)
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(rangeSetTerminalForNumer)(() => input => {
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.497",
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.15",
33
+ "@types/node": "^18.11.18",
34
34
  "typescript": "^4.9.4"
35
35
  }
36
36
  }