functionalscript 0.0.337 → 0.0.338
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/json/tokenizer/index.js +6 -9
- package/package.json +1 -1
package/json/tokenizer/index.js
CHANGED
|
@@ -116,22 +116,19 @@ const letterZ = 0x7a
|
|
|
116
116
|
|
|
117
117
|
/** @typedef {number|undefined} CharCodeOrEof */
|
|
118
118
|
|
|
119
|
-
/** @type {(old: string) => (input:
|
|
120
|
-
const appendChar = old => input =>
|
|
121
|
-
|
|
122
|
-
/** @type {(input: CharCodeOrEof) => string} */
|
|
123
|
-
const charToString = input => input === undefined ? '' : String.fromCharCode(input)
|
|
119
|
+
/** @type {(old: string) => (input: number) => string} */
|
|
120
|
+
const appendChar = old => input => `${old}${String.fromCharCode(input)}`
|
|
124
121
|
|
|
125
122
|
/** @type {(state: InitialState) => (input: number) => readonly[list.List<JsonToken>, TokenizerState]} */
|
|
126
123
|
const initialStateOp = initialState => input =>
|
|
127
124
|
{
|
|
128
125
|
if (input >= digit1 && input <= digit9)
|
|
129
126
|
{
|
|
130
|
-
return [undefined, { kind: 'number', value:
|
|
127
|
+
return [undefined, { kind: 'number', value: String.fromCharCode(input), numberKind: 'int'}]
|
|
131
128
|
}
|
|
132
129
|
if (input >= letterA && input <= letterZ)
|
|
133
130
|
{
|
|
134
|
-
return [undefined, { kind: 'keyword', value:
|
|
131
|
+
return [undefined, { kind: 'keyword', value: String.fromCharCode(input)}]
|
|
135
132
|
}
|
|
136
133
|
switch(input)
|
|
137
134
|
{
|
|
@@ -142,8 +139,8 @@ const initialStateOp = initialState => input =>
|
|
|
142
139
|
case leftBracket: return [[{kind: '['}], initialState]
|
|
143
140
|
case rightBracket: return [[{kind: ']'}], initialState]
|
|
144
141
|
case quotationMark: return[undefined, {kind: 'string', value: ''}]
|
|
145
|
-
case digit0: return [undefined, { kind: 'number', value:
|
|
146
|
-
case signMinus: return [undefined, { kind: 'number', value:
|
|
142
|
+
case digit0: return [undefined, { kind: 'number', value: String.fromCharCode(input), numberKind: '0'}]
|
|
143
|
+
case signMinus: return [undefined, { kind: 'number', value: String.fromCharCode(input), numberKind: '-'}]
|
|
147
144
|
case horizontalTab:
|
|
148
145
|
case newLine:
|
|
149
146
|
case carriageReturn:
|