@magnusopera/fscript 0.75.0

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.
Files changed (79) hide show
  1. package/README.md +5 -0
  2. package/dist/FScript.Language/Ast.js +234 -0
  3. package/dist/FScript.Language/BuiltinFunctions.js +2039 -0
  4. package/dist/FScript.Language/BuiltinSignatures.js +24 -0
  5. package/dist/FScript.Language/BuiltinTypes.js +13 -0
  6. package/dist/FScript.Language/Error.js +74 -0
  7. package/dist/FScript.Language/Eval.js +2404 -0
  8. package/dist/FScript.Language/IncludeResolver.js +806 -0
  9. package/dist/FScript.Language/Lexer.js +1067 -0
  10. package/dist/FScript.Language/Library.js +28 -0
  11. package/dist/FScript.Language/Parser.js +2368 -0
  12. package/dist/FScript.Language/Pretty.js +115 -0
  13. package/dist/FScript.Language/Span.js +33 -0
  14. package/dist/FScript.Language/Token.js +32 -0
  15. package/dist/FScript.Language/TypeInfer.js +2561 -0
  16. package/dist/FScript.Language/Types.js +205 -0
  17. package/dist/FScript.Language/Value.js +91 -0
  18. package/dist/Library.js +732 -0
  19. package/dist/fable_modules/fable-library-js.5.2.0/Array.js +1347 -0
  20. package/dist/fable_modules/fable-library-js.5.2.0/Async.js +134 -0
  21. package/dist/fable_modules/fable-library-js.5.2.0/AsyncBuilder.js +183 -0
  22. package/dist/fable_modules/fable-library-js.5.2.0/BigInt.js +306 -0
  23. package/dist/fable_modules/fable-library-js.5.2.0/BitConverter.js +138 -0
  24. package/dist/fable_modules/fable-library-js.5.2.0/Boolean.js +22 -0
  25. package/dist/fable_modules/fable-library-js.5.2.0/CHANGELOG.md +234 -0
  26. package/dist/fable_modules/fable-library-js.5.2.0/Char.js +202 -0
  27. package/dist/fable_modules/fable-library-js.5.2.0/Choice.js +184 -0
  28. package/dist/fable_modules/fable-library-js.5.2.0/CollectionUtil.js +182 -0
  29. package/dist/fable_modules/fable-library-js.5.2.0/ConditionalWeakTable.js +21 -0
  30. package/dist/fable_modules/fable-library-js.5.2.0/Date.js +841 -0
  31. package/dist/fable_modules/fable-library-js.5.2.0/DateOffset.js +261 -0
  32. package/dist/fable_modules/fable-library-js.5.2.0/DateOnly.js +124 -0
  33. package/dist/fable_modules/fable-library-js.5.2.0/Decimal.js +238 -0
  34. package/dist/fable_modules/fable-library-js.5.2.0/Double.js +47 -0
  35. package/dist/fable_modules/fable-library-js.5.2.0/Encoding.js +185 -0
  36. package/dist/fable_modules/fable-library-js.5.2.0/Event.js +93 -0
  37. package/dist/fable_modules/fable-library-js.5.2.0/FSharp.Collections.js +45 -0
  38. package/dist/fable_modules/fable-library-js.5.2.0/FSharp.Core.CompilerServices.js +27 -0
  39. package/dist/fable_modules/fable-library-js.5.2.0/FSharp.Core.js +156 -0
  40. package/dist/fable_modules/fable-library-js.5.2.0/Global.js +29 -0
  41. package/dist/fable_modules/fable-library-js.5.2.0/Guid.js +161 -0
  42. package/dist/fable_modules/fable-library-js.5.2.0/Int32.js +135 -0
  43. package/dist/fable_modules/fable-library-js.5.2.0/List.js +1323 -0
  44. package/dist/fable_modules/fable-library-js.5.2.0/Long.js +47 -0
  45. package/dist/fable_modules/fable-library-js.5.2.0/MailboxProcessor.js +94 -0
  46. package/dist/fable_modules/fable-library-js.5.2.0/Map.js +1396 -0
  47. package/dist/fable_modules/fable-library-js.5.2.0/MapUtil.js +130 -0
  48. package/dist/fable_modules/fable-library-js.5.2.0/MutableMap.js +339 -0
  49. package/dist/fable_modules/fable-library-js.5.2.0/MutableSet.js +233 -0
  50. package/dist/fable_modules/fable-library-js.5.2.0/Native.js +14 -0
  51. package/dist/fable_modules/fable-library-js.5.2.0/Numeric.js +75 -0
  52. package/dist/fable_modules/fable-library-js.5.2.0/Observable.js +113 -0
  53. package/dist/fable_modules/fable-library-js.5.2.0/Option.js +104 -0
  54. package/dist/fable_modules/fable-library-js.5.2.0/README.md +3 -0
  55. package/dist/fable_modules/fable-library-js.5.2.0/Random.js +172 -0
  56. package/dist/fable_modules/fable-library-js.5.2.0/Range.js +45 -0
  57. package/dist/fable_modules/fable-library-js.5.2.0/Reflection.js +479 -0
  58. package/dist/fable_modules/fable-library-js.5.2.0/RegExp.js +141 -0
  59. package/dist/fable_modules/fable-library-js.5.2.0/Result.js +165 -0
  60. package/dist/fable_modules/fable-library-js.5.2.0/Seq.js +1417 -0
  61. package/dist/fable_modules/fable-library-js.5.2.0/Seq2.js +111 -0
  62. package/dist/fable_modules/fable-library-js.5.2.0/Set.js +1816 -0
  63. package/dist/fable_modules/fable-library-js.5.2.0/String.js +674 -0
  64. package/dist/fable_modules/fable-library-js.5.2.0/System.Collections.Generic.js +333 -0
  65. package/dist/fable_modules/fable-library-js.5.2.0/System.Text.js +200 -0
  66. package/dist/fable_modules/fable-library-js.5.2.0/System.js +283 -0
  67. package/dist/fable_modules/fable-library-js.5.2.0/TimeOnly.js +122 -0
  68. package/dist/fable_modules/fable-library-js.5.2.0/TimeSpan.js +180 -0
  69. package/dist/fable_modules/fable-library-js.5.2.0/Timer.js +67 -0
  70. package/dist/fable_modules/fable-library-js.5.2.0/Types.js +198 -0
  71. package/dist/fable_modules/fable-library-js.5.2.0/Unicode.13.0.0.js +4 -0
  72. package/dist/fable_modules/fable-library-js.5.2.0/Uri.js +165 -0
  73. package/dist/fable_modules/fable-library-js.5.2.0/Util.js +795 -0
  74. package/dist/fable_modules/fable-library-js.5.2.0/big.d.ts +338 -0
  75. package/dist/fable_modules/fable-library-js.5.2.0/lib/big.js +825 -0
  76. package/dist/fable_modules/fable-library-js.5.2.0/package.json +24 -0
  77. package/dist/fable_modules/fable-library-js.5.2.0/quotation.js +618 -0
  78. package/dist/fable_modules/project_cracked.json +1 -0
  79. package/package.json +36 -0
@@ -0,0 +1,1067 @@
1
+
2
+ import { isDigit, isLetterOrDigit, isLetter } from "../fable_modules/fable-library-js.5.2.0/Char.js";
3
+ import { parse } from "../fable_modules/fable-library-js.5.2.0/Double.js";
4
+ import { Span, Position } from "./Span.js";
5
+ import { Token, TokenKind } from "./Token.js";
6
+ import { StringBuilder__Append_244C7CD6, StringBuilder_$ctor } from "../fable_modules/fable-library-js.5.2.0/System.Text.js";
7
+ import { ParseException, ParseError } from "./Error.js";
8
+ import { toString } from "../fable_modules/fable-library-js.5.2.0/Types.js";
9
+ import { printf, toText, substring } from "../fable_modules/fable-library-js.5.2.0/String.js";
10
+ import { item } from "../fable_modules/fable-library-js.5.2.0/Array.js";
11
+ import { toInt64_unchecked } from "../fable_modules/fable-library-js.5.2.0/BigInt.js";
12
+ import { parse as parse_1 } from "../fable_modules/fable-library-js.5.2.0/Long.js";
13
+ import { toList } from "../fable_modules/fable-library-js.5.2.0/Seq.js";
14
+
15
+ function isIdentStart(c) {
16
+ if (isLetter(c)) {
17
+ return true;
18
+ }
19
+ else {
20
+ return c === "_";
21
+ }
22
+ }
23
+
24
+ function isIdentPart(c) {
25
+ if (isLetterOrDigit(c) ? true : (c === "_")) {
26
+ return true;
27
+ }
28
+ else {
29
+ return c === "\'";
30
+ }
31
+ }
32
+
33
+ function parseFloatLiteral(text) {
34
+ return parse(text);
35
+ }
36
+
37
+ function mkSpan(sourceName, line, col, length) {
38
+ return new Span(new Position(sourceName, line, col), new Position(sourceName, line, col + length));
39
+ }
40
+
41
+ function keywordToken(ident) {
42
+ switch (ident) {
43
+ case "let":
44
+ return new TokenKind(10, []);
45
+ case "rec":
46
+ return new TokenKind(11, []);
47
+ case "and":
48
+ return new TokenKind(12, []);
49
+ case "type":
50
+ return new TokenKind(45, []);
51
+ case "typeof":
52
+ return new TokenKind(46, []);
53
+ case "nameof":
54
+ return new TokenKind(47, []);
55
+ case "of":
56
+ return new TokenKind(48, []);
57
+ case "fun":
58
+ return new TokenKind(13, []);
59
+ case "match":
60
+ return new TokenKind(14, []);
61
+ case "with":
62
+ return new TokenKind(15, []);
63
+ case "when":
64
+ return new TokenKind(16, []);
65
+ case "if":
66
+ return new TokenKind(17, []);
67
+ case "then":
68
+ return new TokenKind(18, []);
69
+ case "else":
70
+ return new TokenKind(19, []);
71
+ case "elif":
72
+ return new TokenKind(20, []);
73
+ case "raise":
74
+ return new TokenKind(21, []);
75
+ case "for":
76
+ return new TokenKind(22, []);
77
+ case "import":
78
+ return new TokenKind(39, []);
79
+ case "as":
80
+ return new TokenKind(40, []);
81
+ case "include":
82
+ return new TokenKind(41, []);
83
+ case "module":
84
+ return new TokenKind(42, []);
85
+ case "true":
86
+ return new TokenKind(9, [true]);
87
+ case "false":
88
+ return new TokenKind(9, [false]);
89
+ default:
90
+ return undefined;
91
+ }
92
+ }
93
+
94
+ function addToken(kind, span, tokens) {
95
+ void (tokens.push(new Token(kind, span)));
96
+ }
97
+
98
+ function readString(sourceName, src, i, line, col) {
99
+ const sb = StringBuilder_$ctor();
100
+ let idx = i + 1;
101
+ let cLine = line;
102
+ let cCol = col + 1;
103
+ let doneFlag = false;
104
+ while ((idx < src.length) && !doneFlag) {
105
+ const ch = src[idx];
106
+ if (ch === "\"") {
107
+ doneFlag = true;
108
+ idx = ((idx + 1) | 0);
109
+ cCol = ((cCol + 1) | 0);
110
+ }
111
+ else if ((ch === "\\") && ((idx + 1) < src.length)) {
112
+ const next = src[idx + 1];
113
+ switch (next) {
114
+ case "\"": {
115
+ StringBuilder__Append_244C7CD6(sb, "\"");
116
+ break;
117
+ }
118
+ case "\\": {
119
+ StringBuilder__Append_244C7CD6(sb, "\\");
120
+ break;
121
+ }
122
+ case "n": {
123
+ StringBuilder__Append_244C7CD6(sb, "\n");
124
+ break;
125
+ }
126
+ case "t": {
127
+ StringBuilder__Append_244C7CD6(sb, "\t");
128
+ break;
129
+ }
130
+ default:
131
+ StringBuilder__Append_244C7CD6(sb, next);
132
+ }
133
+ idx = ((idx + 2) | 0);
134
+ cCol = ((cCol + 2) | 0);
135
+ }
136
+ else {
137
+ StringBuilder__Append_244C7CD6(sb, ch);
138
+ if (ch === "\n") {
139
+ cLine = ((cLine + 1) | 0);
140
+ cCol = 1;
141
+ }
142
+ else {
143
+ cCol = ((cCol + 1) | 0);
144
+ }
145
+ idx = ((idx + 1) | 0);
146
+ }
147
+ }
148
+ if (!doneFlag) {
149
+ throw new ParseException(new ParseError("Unterminated string literal", mkSpan(sourceName, line, col, 1)));
150
+ }
151
+ return [toString(sb), idx, cLine, cCol];
152
+ }
153
+
154
+ function readInterpolatedRaw(sourceName, src, i, line, col) {
155
+ let idx = i + 2;
156
+ let cLine = line;
157
+ let cCol = col + 2;
158
+ let doneFlag = false;
159
+ let escaped = false;
160
+ let placeholderDepth = 0;
161
+ let inPlaceholderString = false;
162
+ let placeholderEscaped = false;
163
+ while ((idx < src.length) && !doneFlag) {
164
+ const ch = src[idx];
165
+ if (placeholderDepth > 0) {
166
+ if (inPlaceholderString) {
167
+ if (placeholderEscaped) {
168
+ placeholderEscaped = false;
169
+ }
170
+ else {
171
+ switch (ch) {
172
+ case "\"": {
173
+ inPlaceholderString = false;
174
+ break;
175
+ }
176
+ case "\\": {
177
+ placeholderEscaped = true;
178
+ break;
179
+ }
180
+ default:
181
+ undefined;
182
+ }
183
+ }
184
+ }
185
+ else {
186
+ switch (ch) {
187
+ case "\"": {
188
+ inPlaceholderString = true;
189
+ break;
190
+ }
191
+ case "{": {
192
+ placeholderDepth = ((placeholderDepth + 1) | 0);
193
+ break;
194
+ }
195
+ case "}": {
196
+ placeholderDepth = ((placeholderDepth - 1) | 0);
197
+ break;
198
+ }
199
+ default:
200
+ undefined;
201
+ }
202
+ }
203
+ if (ch === "\n") {
204
+ cLine = ((cLine + 1) | 0);
205
+ cCol = 1;
206
+ }
207
+ else {
208
+ cCol = ((cCol + 1) | 0);
209
+ }
210
+ idx = ((idx + 1) | 0);
211
+ }
212
+ else if (escaped) {
213
+ escaped = false;
214
+ if (ch === "\n") {
215
+ cLine = ((cLine + 1) | 0);
216
+ cCol = 1;
217
+ }
218
+ else {
219
+ cCol = ((cCol + 1) | 0);
220
+ }
221
+ idx = ((idx + 1) | 0);
222
+ }
223
+ else {
224
+ switch (ch) {
225
+ case "\n": {
226
+ idx = ((idx + 1) | 0);
227
+ cLine = ((cLine + 1) | 0);
228
+ cCol = 1;
229
+ break;
230
+ }
231
+ case "\"": {
232
+ doneFlag = true;
233
+ idx = ((idx + 1) | 0);
234
+ cCol = ((cCol + 1) | 0);
235
+ break;
236
+ }
237
+ case "\\": {
238
+ escaped = true;
239
+ idx = ((idx + 1) | 0);
240
+ cCol = ((cCol + 1) | 0);
241
+ break;
242
+ }
243
+ case "{": {
244
+ if (((idx + 1) < src.length) && (src[idx + 1] === "{")) {
245
+ idx = ((idx + 2) | 0);
246
+ cCol = ((cCol + 2) | 0);
247
+ }
248
+ else {
249
+ placeholderDepth = 1;
250
+ idx = ((idx + 1) | 0);
251
+ cCol = ((cCol + 1) | 0);
252
+ }
253
+ break;
254
+ }
255
+ default: {
256
+ idx = ((idx + 1) | 0);
257
+ cCol = ((cCol + 1) | 0);
258
+ }
259
+ }
260
+ }
261
+ }
262
+ if (!doneFlag) {
263
+ throw new ParseException(new ParseError("Unterminated interpolated string literal", mkSpan(sourceName, line, col, 2)));
264
+ }
265
+ const start = (i + 2) | 0;
266
+ const contentLen = ((idx - 1) - start) | 0;
267
+ return [(contentLen <= 0) ? "" : substring(src, start, contentLen), idx, cLine, cCol];
268
+ }
269
+
270
+ export function tokenizeWithSourceName(sourceName, src) {
271
+ const tokens = [];
272
+ const indentStack = [];
273
+ void (indentStack.push(0));
274
+ let i = 0;
275
+ let line = 1;
276
+ let col = 1;
277
+ let atLineStart = true;
278
+ let inLetBindingHead = false;
279
+ let parenDepth = 0;
280
+ let bracketDepth = 0;
281
+ let braceDepth = 0;
282
+ while (i < src.length) {
283
+ const ch = src[i];
284
+ if (atLineStart) {
285
+ let idx = i;
286
+ let indent = 0;
287
+ let cCol = col;
288
+ let onlyWhitespace = true;
289
+ while ((idx < src.length) && ((src[idx] === " ") ? true : (src[idx] === "\t"))) {
290
+ indent = ((indent + ((src[idx] === "\t") ? 4 : 1)) | 0);
291
+ idx = ((idx + 1) | 0);
292
+ cCol = ((cCol + 1) | 0);
293
+ }
294
+ if ((idx < src.length) && (src[idx] === "\n")) {
295
+ addToken(new TokenKind(1, []), mkSpan(sourceName, line, col, 1), tokens);
296
+ i = ((idx + 1) | 0);
297
+ line = ((line + 1) | 0);
298
+ col = 1;
299
+ atLineStart = true;
300
+ }
301
+ else if ((((idx < src.length) && (src[idx] === "/")) && ((idx + 1) < src.length)) && (src[idx + 1] === "/")) {
302
+ while ((i < src.length) && (src[i] !== "\n")) {
303
+ i = ((i + 1) | 0);
304
+ }
305
+ addToken(new TokenKind(1, []), mkSpan(sourceName, line, col, 1), tokens);
306
+ if ((i < src.length) && (src[i] === "\n")) {
307
+ i = ((i + 1) | 0);
308
+ line = ((line + 1) | 0);
309
+ col = 1;
310
+ }
311
+ atLineStart = true;
312
+ }
313
+ else {
314
+ const span_1 = mkSpan(sourceName, line, col, 1);
315
+ const startsWithParameterHead = (idx < src.length) && ((src[idx] === "(") ? true : isIdentStart(src[idx]));
316
+ if (inLetBindingHead && startsWithParameterHead) {
317
+ }
318
+ else {
319
+ const newIndent = indent | 0;
320
+ const span = span_1;
321
+ const current = item(indentStack.length - 1, indentStack) | 0;
322
+ if (newIndent > current) {
323
+ void (indentStack.push(newIndent));
324
+ addToken(new TokenKind(2, []), span, tokens);
325
+ }
326
+ else if (newIndent < current) {
327
+ let j = indentStack.length - 1;
328
+ while ((j > 0) && (item(j, indentStack) > newIndent)) {
329
+ indentStack.splice(j, 1);
330
+ addToken(new TokenKind(3, []), span, tokens);
331
+ j = ((j - 1) | 0);
332
+ }
333
+ if (item(indentStack.length - 1, indentStack) !== newIndent) {
334
+ if ((((parenDepth > 0) ? true : (bracketDepth > 0)) ? true : (braceDepth > 0)) && (item(indentStack.length - 1, indentStack) < newIndent)) {
335
+ void (indentStack.push(newIndent));
336
+ addToken(new TokenKind(2, []), span, tokens);
337
+ }
338
+ else {
339
+ throw new ParseException(new ParseError("Inconsistent indentation", span));
340
+ }
341
+ }
342
+ }
343
+ }
344
+ i = (idx | 0);
345
+ col = (cCol | 0);
346
+ atLineStart = false;
347
+ }
348
+ }
349
+ else {
350
+ let matchResult, c_48, c_49;
351
+ switch (ch) {
352
+ case "\t":
353
+ case " ": {
354
+ matchResult = 0;
355
+ break;
356
+ }
357
+ case "\n": {
358
+ matchResult = 2;
359
+ break;
360
+ }
361
+ case "\r": {
362
+ matchResult = 1;
363
+ break;
364
+ }
365
+ case "\"": {
366
+ matchResult = 5;
367
+ break;
368
+ }
369
+ case "#": {
370
+ if (isDigit(ch)) {
371
+ matchResult = 7;
372
+ c_48 = ch;
373
+ }
374
+ else if (isIdentStart(ch)) {
375
+ matchResult = 8;
376
+ c_49 = ch;
377
+ }
378
+ else {
379
+ matchResult = 37;
380
+ }
381
+ break;
382
+ }
383
+ case "$": {
384
+ if (((i + 1) < src.length) && (src[i + 1] === "\"")) {
385
+ matchResult = 6;
386
+ }
387
+ else if (isDigit(ch)) {
388
+ matchResult = 7;
389
+ c_48 = ch;
390
+ }
391
+ else if (isIdentStart(ch)) {
392
+ matchResult = 8;
393
+ c_49 = ch;
394
+ }
395
+ else {
396
+ matchResult = 40;
397
+ }
398
+ break;
399
+ }
400
+ case "%": {
401
+ if (isDigit(ch)) {
402
+ matchResult = 7;
403
+ c_48 = ch;
404
+ }
405
+ else if (isIdentStart(ch)) {
406
+ matchResult = 8;
407
+ c_49 = ch;
408
+ }
409
+ else {
410
+ matchResult = 21;
411
+ }
412
+ break;
413
+ }
414
+ case "&": {
415
+ if (isDigit(ch)) {
416
+ matchResult = 7;
417
+ c_48 = ch;
418
+ }
419
+ else if (isIdentStart(ch)) {
420
+ matchResult = 8;
421
+ c_49 = ch;
422
+ }
423
+ else if (((i + 1) < src.length) && (src[i + 1] === "&")) {
424
+ matchResult = 13;
425
+ }
426
+ else {
427
+ matchResult = 40;
428
+ }
429
+ break;
430
+ }
431
+ case "(": {
432
+ if (((i + 1) < src.length) && (src[i + 1] === "*")) {
433
+ matchResult = 4;
434
+ }
435
+ else if (isDigit(ch)) {
436
+ matchResult = 7;
437
+ c_48 = ch;
438
+ }
439
+ else if (isIdentStart(ch)) {
440
+ matchResult = 8;
441
+ c_49 = ch;
442
+ }
443
+ else {
444
+ matchResult = 27;
445
+ }
446
+ break;
447
+ }
448
+ case ")": {
449
+ if (isDigit(ch)) {
450
+ matchResult = 7;
451
+ c_48 = ch;
452
+ }
453
+ else if (isIdentStart(ch)) {
454
+ matchResult = 8;
455
+ c_49 = ch;
456
+ }
457
+ else {
458
+ matchResult = 28;
459
+ }
460
+ break;
461
+ }
462
+ case "*": {
463
+ if (isDigit(ch)) {
464
+ matchResult = 7;
465
+ c_48 = ch;
466
+ }
467
+ else if (isIdentStart(ch)) {
468
+ matchResult = 8;
469
+ c_49 = ch;
470
+ }
471
+ else {
472
+ matchResult = 19;
473
+ }
474
+ break;
475
+ }
476
+ case "+": {
477
+ if (isDigit(ch)) {
478
+ matchResult = 7;
479
+ c_48 = ch;
480
+ }
481
+ else if (isIdentStart(ch)) {
482
+ matchResult = 8;
483
+ c_49 = ch;
484
+ }
485
+ else {
486
+ matchResult = 17;
487
+ }
488
+ break;
489
+ }
490
+ case ",": {
491
+ if (isDigit(ch)) {
492
+ matchResult = 7;
493
+ c_48 = ch;
494
+ }
495
+ else if (isIdentStart(ch)) {
496
+ matchResult = 8;
497
+ c_49 = ch;
498
+ }
499
+ else {
500
+ matchResult = 33;
501
+ }
502
+ break;
503
+ }
504
+ case "-": {
505
+ if (isDigit(ch)) {
506
+ matchResult = 7;
507
+ c_48 = ch;
508
+ }
509
+ else if (isIdentStart(ch)) {
510
+ matchResult = 8;
511
+ c_49 = ch;
512
+ }
513
+ else if (((i + 1) < src.length) && (src[i + 1] === ">")) {
514
+ matchResult = 9;
515
+ }
516
+ else {
517
+ matchResult = 18;
518
+ }
519
+ break;
520
+ }
521
+ case ".": {
522
+ if (isDigit(ch)) {
523
+ matchResult = 7;
524
+ c_48 = ch;
525
+ }
526
+ else if (isIdentStart(ch)) {
527
+ matchResult = 8;
528
+ c_49 = ch;
529
+ }
530
+ else if (((i + 1) < src.length) && (src[i + 1] === ".")) {
531
+ matchResult = 35;
532
+ }
533
+ else {
534
+ matchResult = 36;
535
+ }
536
+ break;
537
+ }
538
+ case "/": {
539
+ if (((i + 1) < src.length) && (src[i + 1] === "/")) {
540
+ matchResult = 3;
541
+ }
542
+ else if (isDigit(ch)) {
543
+ matchResult = 7;
544
+ c_48 = ch;
545
+ }
546
+ else if (isIdentStart(ch)) {
547
+ matchResult = 8;
548
+ c_49 = ch;
549
+ }
550
+ else {
551
+ matchResult = 20;
552
+ }
553
+ break;
554
+ }
555
+ case ":": {
556
+ if (isDigit(ch)) {
557
+ matchResult = 7;
558
+ c_48 = ch;
559
+ }
560
+ else if (isIdentStart(ch)) {
561
+ matchResult = 8;
562
+ c_49 = ch;
563
+ }
564
+ else if (((i + 1) < src.length) && (src[i + 1] === ":")) {
565
+ matchResult = 10;
566
+ }
567
+ else {
568
+ matchResult = 34;
569
+ }
570
+ break;
571
+ }
572
+ case ";": {
573
+ if (isDigit(ch)) {
574
+ matchResult = 7;
575
+ c_48 = ch;
576
+ }
577
+ else if (isIdentStart(ch)) {
578
+ matchResult = 8;
579
+ c_49 = ch;
580
+ }
581
+ else {
582
+ matchResult = 32;
583
+ }
584
+ break;
585
+ }
586
+ case "<": {
587
+ if (isDigit(ch)) {
588
+ matchResult = 7;
589
+ c_48 = ch;
590
+ }
591
+ else if (isIdentStart(ch)) {
592
+ matchResult = 8;
593
+ c_49 = ch;
594
+ }
595
+ else if (((i + 1) < src.length) && (src[i + 1] === "=")) {
596
+ matchResult = 11;
597
+ }
598
+ else {
599
+ matchResult = 23;
600
+ }
601
+ break;
602
+ }
603
+ case "=": {
604
+ if (isDigit(ch)) {
605
+ matchResult = 7;
606
+ c_48 = ch;
607
+ }
608
+ else if (isIdentStart(ch)) {
609
+ matchResult = 8;
610
+ c_49 = ch;
611
+ }
612
+ else {
613
+ matchResult = 22;
614
+ }
615
+ break;
616
+ }
617
+ case ">": {
618
+ if (isDigit(ch)) {
619
+ matchResult = 7;
620
+ c_48 = ch;
621
+ }
622
+ else if (isIdentStart(ch)) {
623
+ matchResult = 8;
624
+ c_49 = ch;
625
+ }
626
+ else if (((i + 1) < src.length) && (src[i + 1] === "=")) {
627
+ matchResult = 12;
628
+ }
629
+ else {
630
+ matchResult = 24;
631
+ }
632
+ break;
633
+ }
634
+ case "@": {
635
+ if (isDigit(ch)) {
636
+ matchResult = 7;
637
+ c_48 = ch;
638
+ }
639
+ else if (isIdentStart(ch)) {
640
+ matchResult = 8;
641
+ c_49 = ch;
642
+ }
643
+ else {
644
+ matchResult = 26;
645
+ }
646
+ break;
647
+ }
648
+ case "[": {
649
+ if (isDigit(ch)) {
650
+ matchResult = 7;
651
+ c_48 = ch;
652
+ }
653
+ else if (isIdentStart(ch)) {
654
+ matchResult = 8;
655
+ c_49 = ch;
656
+ }
657
+ else if (((i + 1) < src.length) && (src[i + 1] === "|")) {
658
+ matchResult = 29;
659
+ }
660
+ else {
661
+ matchResult = 30;
662
+ }
663
+ break;
664
+ }
665
+ case "]": {
666
+ if (isDigit(ch)) {
667
+ matchResult = 7;
668
+ c_48 = ch;
669
+ }
670
+ else if (isIdentStart(ch)) {
671
+ matchResult = 8;
672
+ c_49 = ch;
673
+ }
674
+ else {
675
+ matchResult = 31;
676
+ }
677
+ break;
678
+ }
679
+ case "{": {
680
+ if (isDigit(ch)) {
681
+ matchResult = 7;
682
+ c_48 = ch;
683
+ }
684
+ else if (isIdentStart(ch)) {
685
+ matchResult = 8;
686
+ c_49 = ch;
687
+ }
688
+ else {
689
+ matchResult = 38;
690
+ }
691
+ break;
692
+ }
693
+ case "|": {
694
+ if (isDigit(ch)) {
695
+ matchResult = 7;
696
+ c_48 = ch;
697
+ }
698
+ else if (isIdentStart(ch)) {
699
+ matchResult = 8;
700
+ c_49 = ch;
701
+ }
702
+ else if (((i + 1) < src.length) && (src[i + 1] === "]")) {
703
+ matchResult = 14;
704
+ }
705
+ else if (((i + 1) < src.length) && (src[i + 1] === "|")) {
706
+ matchResult = 15;
707
+ }
708
+ else if (((i + 1) < src.length) && (src[i + 1] === ">")) {
709
+ matchResult = 16;
710
+ }
711
+ else {
712
+ matchResult = 25;
713
+ }
714
+ break;
715
+ }
716
+ case "}": {
717
+ if (isDigit(ch)) {
718
+ matchResult = 7;
719
+ c_48 = ch;
720
+ }
721
+ else if (isIdentStart(ch)) {
722
+ matchResult = 8;
723
+ c_49 = ch;
724
+ }
725
+ else {
726
+ matchResult = 39;
727
+ }
728
+ break;
729
+ }
730
+ default:
731
+ if (isDigit(ch)) {
732
+ matchResult = 7;
733
+ c_48 = ch;
734
+ }
735
+ else if (isIdentStart(ch)) {
736
+ matchResult = 8;
737
+ c_49 = ch;
738
+ }
739
+ else {
740
+ matchResult = 40;
741
+ }
742
+ }
743
+ switch (matchResult) {
744
+ case 0: {
745
+ i = ((i + 1) | 0);
746
+ col = ((col + 1) | 0);
747
+ break;
748
+ }
749
+ case 1: {
750
+ i = ((i + 1) | 0);
751
+ break;
752
+ }
753
+ case 2: {
754
+ addToken(new TokenKind(1, []), mkSpan(sourceName, line, col, 1), tokens);
755
+ i = ((i + 1) | 0);
756
+ line = ((line + 1) | 0);
757
+ col = 1;
758
+ atLineStart = true;
759
+ break;
760
+ }
761
+ case 3: {
762
+ while ((i < src.length) && (src[i] !== "\n")) {
763
+ i = ((i + 1) | 0);
764
+ }
765
+ break;
766
+ }
767
+ case 4: {
768
+ throw new ParseException(new ParseError("Block comments are not supported", mkSpan(sourceName, line, col, 2)));
769
+ break;
770
+ }
771
+ case 5: {
772
+ const patternInput = readString(sourceName, src, i, line, col);
773
+ const idx_1 = patternInput[1] | 0;
774
+ addToken(new TokenKind(7, [patternInput[0]]), mkSpan(sourceName, line, col, idx_1 - i), tokens);
775
+ i = (idx_1 | 0);
776
+ line = (patternInput[2] | 0);
777
+ col = (patternInput[3] | 0);
778
+ break;
779
+ }
780
+ case 6: {
781
+ const patternInput_1 = readInterpolatedRaw(sourceName, src, i, line, col);
782
+ const idx_2 = patternInput_1[1] | 0;
783
+ addToken(new TokenKind(8, [patternInput_1[0]]), mkSpan(sourceName, line, col, idx_2 - i), tokens);
784
+ i = (idx_2 | 0);
785
+ line = (patternInput_1[2] | 0);
786
+ col = (patternInput_1[3] | 0);
787
+ break;
788
+ }
789
+ case 7: {
790
+ const start = i | 0;
791
+ const startCol = col | 0;
792
+ let hasDot = false;
793
+ let idx_3 = i;
794
+ while ((idx_3 < src.length) && (isDigit(src[idx_3]) ? true : ((((src[idx_3] === ".") && !hasDot) && ((idx_3 + 1) < src.length)) && isDigit(src[idx_3 + 1])))) {
795
+ if (src[idx_3] === ".") {
796
+ hasDot = true;
797
+ idx_3 = ((idx_3 + 1) | 0);
798
+ }
799
+ else {
800
+ idx_3 = ((idx_3 + 1) | 0);
801
+ }
802
+ }
803
+ const text = substring(src, start, idx_3 - start);
804
+ const span_4 = mkSpan(sourceName, line, startCol, idx_3 - start);
805
+ if (hasDot) {
806
+ addToken(new TokenKind(6, [parseFloatLiteral(text)]), span_4, tokens);
807
+ }
808
+ else {
809
+ addToken(new TokenKind(5, [toInt64_unchecked(parse_1(text, 511, false, 64))]), span_4, tokens);
810
+ }
811
+ i = (idx_3 | 0);
812
+ col = ((startCol + (idx_3 - start)) | 0);
813
+ break;
814
+ }
815
+ case 8: {
816
+ const start_1 = i | 0;
817
+ const startCol_1 = col | 0;
818
+ let idx_4 = i + 1;
819
+ while ((idx_4 < src.length) && isIdentPart(src[idx_4])) {
820
+ idx_4 = ((idx_4 + 1) | 0);
821
+ }
822
+ const ident = substring(src, start_1, idx_4 - start_1);
823
+ const span_5 = mkSpan(sourceName, line, startCol_1, idx_4 - start_1);
824
+ const matchValue = keywordToken(ident);
825
+ if (matchValue == null) {
826
+ addToken(new TokenKind(4, [ident]), span_5, tokens);
827
+ }
828
+ else {
829
+ const k = matchValue;
830
+ addToken(k, span_5, tokens);
831
+ switch (k.tag) {
832
+ case 10:
833
+ case 12: {
834
+ inLetBindingHead = true;
835
+ break;
836
+ }
837
+ default:
838
+ undefined;
839
+ }
840
+ }
841
+ i = (idx_4 | 0);
842
+ col = ((startCol_1 + (idx_4 - start_1)) | 0);
843
+ break;
844
+ }
845
+ case 9: {
846
+ addToken(new TokenKind(24, []), mkSpan(sourceName, line, col, 2), tokens);
847
+ i = ((i + 2) | 0);
848
+ col = ((col + 2) | 0);
849
+ break;
850
+ }
851
+ case 10: {
852
+ addToken(new TokenKind(61, []), mkSpan(sourceName, line, col, 2), tokens);
853
+ i = ((i + 2) | 0);
854
+ col = ((col + 2) | 0);
855
+ break;
856
+ }
857
+ case 11: {
858
+ addToken(new TokenKind(56, []), mkSpan(sourceName, line, col, 2), tokens);
859
+ i = ((i + 2) | 0);
860
+ col = ((col + 2) | 0);
861
+ break;
862
+ }
863
+ case 12: {
864
+ addToken(new TokenKind(57, []), mkSpan(sourceName, line, col, 2), tokens);
865
+ i = ((i + 2) | 0);
866
+ col = ((col + 2) | 0);
867
+ break;
868
+ }
869
+ case 13: {
870
+ addToken(new TokenKind(58, []), mkSpan(sourceName, line, col, 2), tokens);
871
+ i = ((i + 2) | 0);
872
+ col = ((col + 2) | 0);
873
+ break;
874
+ }
875
+ case 14: {
876
+ addToken(new TokenKind(32, []), mkSpan(sourceName, line, col, 2), tokens);
877
+ if (bracketDepth > 0) {
878
+ bracketDepth = ((bracketDepth - 1) | 0);
879
+ }
880
+ i = ((i + 2) | 0);
881
+ col = ((col + 2) | 0);
882
+ break;
883
+ }
884
+ case 15: {
885
+ addToken(new TokenKind(59, []), mkSpan(sourceName, line, col, 2), tokens);
886
+ i = ((i + 2) | 0);
887
+ col = ((col + 2) | 0);
888
+ break;
889
+ }
890
+ case 16: {
891
+ addToken(new TokenKind(60, []), mkSpan(sourceName, line, col, 2), tokens);
892
+ i = ((i + 2) | 0);
893
+ col = ((col + 2) | 0);
894
+ break;
895
+ }
896
+ case 17: {
897
+ addToken(new TokenKind(49, []), mkSpan(sourceName, line, col, 1), tokens);
898
+ i = ((i + 1) | 0);
899
+ col = ((col + 1) | 0);
900
+ break;
901
+ }
902
+ case 18: {
903
+ addToken(new TokenKind(50, []), mkSpan(sourceName, line, col, 1), tokens);
904
+ i = ((i + 1) | 0);
905
+ col = ((col + 1) | 0);
906
+ break;
907
+ }
908
+ case 19: {
909
+ addToken(new TokenKind(51, []), mkSpan(sourceName, line, col, 1), tokens);
910
+ i = ((i + 1) | 0);
911
+ col = ((col + 1) | 0);
912
+ break;
913
+ }
914
+ case 20: {
915
+ addToken(new TokenKind(52, []), mkSpan(sourceName, line, col, 1), tokens);
916
+ i = ((i + 1) | 0);
917
+ col = ((col + 1) | 0);
918
+ break;
919
+ }
920
+ case 21: {
921
+ addToken(new TokenKind(53, []), mkSpan(sourceName, line, col, 1), tokens);
922
+ i = ((i + 1) | 0);
923
+ col = ((col + 1) | 0);
924
+ break;
925
+ }
926
+ case 22: {
927
+ addToken(new TokenKind(25, []), mkSpan(sourceName, line, col, 1), tokens);
928
+ inLetBindingHead = false;
929
+ i = ((i + 1) | 0);
930
+ col = ((col + 1) | 0);
931
+ break;
932
+ }
933
+ case 23: {
934
+ addToken(new TokenKind(54, []), mkSpan(sourceName, line, col, 1), tokens);
935
+ i = ((i + 1) | 0);
936
+ col = ((col + 1) | 0);
937
+ break;
938
+ }
939
+ case 24: {
940
+ addToken(new TokenKind(55, []), mkSpan(sourceName, line, col, 1), tokens);
941
+ i = ((i + 1) | 0);
942
+ col = ((col + 1) | 0);
943
+ break;
944
+ }
945
+ case 25: {
946
+ addToken(new TokenKind(26, []), mkSpan(sourceName, line, col, 1), tokens);
947
+ i = ((i + 1) | 0);
948
+ col = ((col + 1) | 0);
949
+ break;
950
+ }
951
+ case 26: {
952
+ addToken(new TokenKind(62, []), mkSpan(sourceName, line, col, 1), tokens);
953
+ i = ((i + 1) | 0);
954
+ col = ((col + 1) | 0);
955
+ break;
956
+ }
957
+ case 27: {
958
+ addToken(new TokenKind(27, []), mkSpan(sourceName, line, col, 1), tokens);
959
+ parenDepth = ((parenDepth + 1) | 0);
960
+ i = ((i + 1) | 0);
961
+ col = ((col + 1) | 0);
962
+ break;
963
+ }
964
+ case 28: {
965
+ addToken(new TokenKind(28, []), mkSpan(sourceName, line, col, 1), tokens);
966
+ if (parenDepth > 0) {
967
+ parenDepth = ((parenDepth - 1) | 0);
968
+ }
969
+ i = ((i + 1) | 0);
970
+ col = ((col + 1) | 0);
971
+ break;
972
+ }
973
+ case 29: {
974
+ addToken(new TokenKind(31, []), mkSpan(sourceName, line, col, 2), tokens);
975
+ bracketDepth = ((bracketDepth + 1) | 0);
976
+ i = ((i + 2) | 0);
977
+ col = ((col + 2) | 0);
978
+ break;
979
+ }
980
+ case 30: {
981
+ addToken(new TokenKind(29, []), mkSpan(sourceName, line, col, 1), tokens);
982
+ bracketDepth = ((bracketDepth + 1) | 0);
983
+ i = ((i + 1) | 0);
984
+ col = ((col + 1) | 0);
985
+ break;
986
+ }
987
+ case 31: {
988
+ addToken(new TokenKind(30, []), mkSpan(sourceName, line, col, 1), tokens);
989
+ if (bracketDepth > 0) {
990
+ bracketDepth = ((bracketDepth - 1) | 0);
991
+ }
992
+ i = ((i + 1) | 0);
993
+ col = ((col + 1) | 0);
994
+ break;
995
+ }
996
+ case 32: {
997
+ addToken(new TokenKind(33, []), mkSpan(sourceName, line, col, 1), tokens);
998
+ i = ((i + 1) | 0);
999
+ col = ((col + 1) | 0);
1000
+ break;
1001
+ }
1002
+ case 33: {
1003
+ addToken(new TokenKind(34, []), mkSpan(sourceName, line, col, 1), tokens);
1004
+ i = ((i + 1) | 0);
1005
+ col = ((col + 1) | 0);
1006
+ break;
1007
+ }
1008
+ case 34: {
1009
+ addToken(new TokenKind(35, []), mkSpan(sourceName, line, col, 1), tokens);
1010
+ i = ((i + 1) | 0);
1011
+ col = ((col + 1) | 0);
1012
+ break;
1013
+ }
1014
+ case 35: {
1015
+ addToken(new TokenKind(37, []), mkSpan(sourceName, line, col, 2), tokens);
1016
+ i = ((i + 2) | 0);
1017
+ col = ((col + 2) | 0);
1018
+ break;
1019
+ }
1020
+ case 36: {
1021
+ addToken(new TokenKind(36, []), mkSpan(sourceName, line, col, 1), tokens);
1022
+ i = ((i + 1) | 0);
1023
+ col = ((col + 1) | 0);
1024
+ break;
1025
+ }
1026
+ case 37: {
1027
+ addToken(new TokenKind(38, []), mkSpan(sourceName, line, col, 1), tokens);
1028
+ i = ((i + 1) | 0);
1029
+ col = ((col + 1) | 0);
1030
+ break;
1031
+ }
1032
+ case 38: {
1033
+ addToken(new TokenKind(43, []), mkSpan(sourceName, line, col, 1), tokens);
1034
+ braceDepth = ((braceDepth + 1) | 0);
1035
+ i = ((i + 1) | 0);
1036
+ col = ((col + 1) | 0);
1037
+ break;
1038
+ }
1039
+ case 39: {
1040
+ addToken(new TokenKind(44, []), mkSpan(sourceName, line, col, 1), tokens);
1041
+ if (braceDepth > 0) {
1042
+ braceDepth = ((braceDepth - 1) | 0);
1043
+ }
1044
+ i = ((i + 1) | 0);
1045
+ col = ((col + 1) | 0);
1046
+ break;
1047
+ }
1048
+ case 40: {
1049
+ throw new ParseException(new ParseError(toText(printf("Unexpected character \'%c\'"))(ch), mkSpan(sourceName, line, col, 1)));
1050
+ break;
1051
+ }
1052
+ }
1053
+ }
1054
+ }
1055
+ addToken(new TokenKind(1, []), mkSpan(sourceName, line, col, 1), tokens);
1056
+ while (indentStack.length > 1) {
1057
+ indentStack.splice(indentStack.length - 1, 1);
1058
+ addToken(new TokenKind(3, []), mkSpan(sourceName, line, col, 1), tokens);
1059
+ }
1060
+ addToken(new TokenKind(0, []), mkSpan(sourceName, line, col, 1), tokens);
1061
+ return toList(tokens);
1062
+ }
1063
+
1064
+ export function tokenize(src) {
1065
+ return tokenizeWithSourceName(undefined, src);
1066
+ }
1067
+