firefly-compiler 0.4.5 → 0.4.6

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 (78) hide show
  1. package/.hintrc +4 -4
  2. package/README.md +1 -1
  3. package/core/HttpClient.ff +1 -1
  4. package/lsp/LanguageServer.ff +32 -7
  5. package/lsp/stderr.txt +1 -0
  6. package/lsp/stdin.txt +11 -0
  7. package/lsp/stdout.txt +41 -0
  8. package/lux/Main.ff +56 -2
  9. package/meetup/AutoCompletion.ff +6 -0
  10. package/output/js/ff/compiler/Builder.mjs +444 -444
  11. package/output/js/ff/compiler/Compiler.mjs +416 -416
  12. package/output/js/ff/compiler/Dependencies.mjs +389 -389
  13. package/output/js/ff/compiler/Deriver.mjs +1170 -1170
  14. package/output/js/ff/compiler/Dictionaries.mjs +1309 -1309
  15. package/output/js/ff/compiler/Environment.mjs +1015 -1015
  16. package/output/js/ff/compiler/Inference.mjs +4268 -4268
  17. package/output/js/ff/compiler/JsEmitter.mjs +5391 -5391
  18. package/output/js/ff/compiler/JsImporter.mjs +266 -266
  19. package/output/js/ff/compiler/LspHook.mjs +793 -793
  20. package/output/js/ff/compiler/Main.mjs +1675 -1675
  21. package/output/js/ff/compiler/Parser.mjs +4008 -4008
  22. package/output/js/ff/compiler/Patterns.mjs +927 -927
  23. package/output/js/ff/compiler/Resolver.mjs +2307 -2307
  24. package/output/js/ff/compiler/Substitution.mjs +1150 -1150
  25. package/output/js/ff/compiler/Syntax.mjs +12434 -12434
  26. package/output/js/ff/compiler/Token.mjs +3096 -3096
  27. package/output/js/ff/compiler/Tokenizer.mjs +593 -593
  28. package/output/js/ff/compiler/Unification.mjs +1752 -1752
  29. package/output/js/ff/compiler/Wildcards.mjs +608 -608
  30. package/output/js/ff/compiler/Workspace.mjs +687 -687
  31. package/output/js/ff/core/Any.mjs +143 -143
  32. package/output/js/ff/core/Array.mjs +547 -547
  33. package/output/js/ff/core/AssetSystem.mjs +274 -274
  34. package/output/js/ff/core/Atomic.mjs +154 -154
  35. package/output/js/ff/core/Bool.mjs +152 -152
  36. package/output/js/ff/core/Box.mjs +112 -112
  37. package/output/js/ff/core/BrowserSystem.mjs +126 -126
  38. package/output/js/ff/core/Buffer.mjs +395 -395
  39. package/output/js/ff/core/BuildSystem.mjs +296 -296
  40. package/output/js/ff/core/Channel.mjs +189 -189
  41. package/output/js/ff/core/Char.mjs +149 -149
  42. package/output/js/ff/core/Core.mjs +300 -300
  43. package/output/js/ff/core/Duration.mjs +116 -116
  44. package/output/js/ff/core/Equal.mjs +179 -179
  45. package/output/js/ff/core/Error.mjs +142 -142
  46. package/output/js/ff/core/FileHandle.mjs +150 -150
  47. package/output/js/ff/core/Float.mjs +225 -225
  48. package/output/js/ff/core/HttpClient.mjs +190 -190
  49. package/output/js/ff/core/Instant.mjs +109 -109
  50. package/output/js/ff/core/Int.mjs +265 -265
  51. package/output/js/ff/core/IntMap.mjs +280 -280
  52. package/output/js/ff/core/JsSystem.mjs +238 -238
  53. package/output/js/ff/core/JsValue.mjs +708 -708
  54. package/output/js/ff/core/List.mjs +2334 -2334
  55. package/output/js/ff/core/Lock.mjs +229 -229
  56. package/output/js/ff/core/Log.mjs +163 -163
  57. package/output/js/ff/core/Map.mjs +362 -362
  58. package/output/js/ff/core/NodeSystem.mjs +294 -294
  59. package/output/js/ff/core/Nothing.mjs +104 -104
  60. package/output/js/ff/core/Option.mjs +1015 -1015
  61. package/output/js/ff/core/Ordering.mjs +730 -730
  62. package/output/js/ff/core/Pair.mjs +331 -331
  63. package/output/js/ff/core/Path.mjs +545 -545
  64. package/output/js/ff/core/RbMap.mjs +1940 -1940
  65. package/output/js/ff/core/Serializable.mjs +428 -428
  66. package/output/js/ff/core/Set.mjs +254 -254
  67. package/output/js/ff/core/Show.mjs +205 -205
  68. package/output/js/ff/core/SourceLocation.mjs +229 -229
  69. package/output/js/ff/core/Stack.mjs +529 -529
  70. package/output/js/ff/core/Stream.mjs +1304 -1304
  71. package/output/js/ff/core/String.mjs +365 -365
  72. package/output/js/ff/core/StringMap.mjs +280 -280
  73. package/output/js/ff/core/Task.mjs +320 -320
  74. package/output/js/ff/core/Try.mjs +507 -507
  75. package/output/js/ff/core/Unit.mjs +151 -151
  76. package/package.json +29 -29
  77. package/vscode/package-lock.json +5 -5
  78. package/vscode/package.json +1 -1
@@ -1,593 +1,593 @@
1
-
2
-
3
- import * as ff_compiler_Tokenizer from "../../ff/compiler/Tokenizer.mjs"
4
-
5
- import * as ff_compiler_LspHook from "../../ff/compiler/LspHook.mjs"
6
-
7
- import * as ff_compiler_Syntax from "../../ff/compiler/Syntax.mjs"
8
-
9
- import * as ff_compiler_Token from "../../ff/compiler/Token.mjs"
10
-
11
- import * as ff_core_Any from "../../ff/core/Any.mjs"
12
-
13
- import * as ff_core_Array from "../../ff/core/Array.mjs"
14
-
15
- import * as ff_core_AssetSystem from "../../ff/core/AssetSystem.mjs"
16
-
17
- import * as ff_core_Atomic from "../../ff/core/Atomic.mjs"
18
-
19
- import * as ff_core_Bool from "../../ff/core/Bool.mjs"
20
-
21
- import * as ff_core_Box from "../../ff/core/Box.mjs"
22
-
23
- import * as ff_core_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
24
-
25
- import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
26
-
27
- import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
28
-
29
- import * as ff_core_Channel from "../../ff/core/Channel.mjs"
30
-
31
- import * as ff_core_Char from "../../ff/core/Char.mjs"
32
-
33
- import * as ff_core_Core from "../../ff/core/Core.mjs"
34
-
35
- import * as ff_core_Duration from "../../ff/core/Duration.mjs"
36
-
37
- import * as ff_core_Equal from "../../ff/core/Equal.mjs"
38
-
39
- import * as ff_core_Error from "../../ff/core/Error.mjs"
40
-
41
- import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
42
-
43
- import * as ff_core_Float from "../../ff/core/Float.mjs"
44
-
45
- import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
46
-
47
- import * as ff_core_Instant from "../../ff/core/Instant.mjs"
48
-
49
- import * as ff_core_Int from "../../ff/core/Int.mjs"
50
-
51
- import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
52
-
53
- import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
54
-
55
- import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
56
-
57
- import * as ff_core_List from "../../ff/core/List.mjs"
58
-
59
- import * as ff_core_Lock from "../../ff/core/Lock.mjs"
60
-
61
- import * as ff_core_Log from "../../ff/core/Log.mjs"
62
-
63
- import * as ff_core_Map from "../../ff/core/Map.mjs"
64
-
65
- import * as ff_core_NodeSystem from "../../ff/core/NodeSystem.mjs"
66
-
67
- import * as ff_core_Nothing from "../../ff/core/Nothing.mjs"
68
-
69
- import * as ff_core_Option from "../../ff/core/Option.mjs"
70
-
71
- import * as ff_core_Ordering from "../../ff/core/Ordering.mjs"
72
-
73
- import * as ff_core_Pair from "../../ff/core/Pair.mjs"
74
-
75
- import * as ff_core_Path from "../../ff/core/Path.mjs"
76
-
77
- import * as ff_core_Serializable from "../../ff/core/Serializable.mjs"
78
-
79
- import * as ff_core_Set from "../../ff/core/Set.mjs"
80
-
81
- import * as ff_core_Show from "../../ff/core/Show.mjs"
82
-
83
- import * as ff_core_SourceLocation from "../../ff/core/SourceLocation.mjs"
84
-
85
- import * as ff_core_Stack from "../../ff/core/Stack.mjs"
86
-
87
- import * as ff_core_Stream from "../../ff/core/Stream.mjs"
88
-
89
- import * as ff_core_String from "../../ff/core/String.mjs"
90
-
91
- import * as ff_core_StringMap from "../../ff/core/StringMap.mjs"
92
-
93
- import * as ff_core_Task from "../../ff/core/Task.mjs"
94
-
95
- import * as ff_core_Try from "../../ff/core/Try.mjs"
96
-
97
- import * as ff_core_Unit from "../../ff/core/Unit.mjs"
98
-
99
-
100
-
101
-
102
-
103
- export function tokenize_(file_, code_, completionAt_, attemptFixes_) {
104
- const completionLine_ = ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Option.Option_filter(completionAt_, ((_w1) => {
105
- return (_w1.file_ === file_)
106
- })), ((_w1) => {
107
- return _w1.line_
108
- })), (() => {
109
- return (-1)
110
- }));
111
- const completionColumn_ = ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Option.Option_filter(completionAt_, ((_w1) => {
112
- return (_w1.file_ === file_)
113
- })), ((_w1) => {
114
- return _w1.column_
115
- })), (() => {
116
- return (-1)
117
- }));
118
- const tokens_ = ff_core_Stack.make_();
119
- let line_ = 1;
120
- let lineOffset_ = 0;
121
- let startLine_ = line_;
122
- let startLineOffset_ = lineOffset_;
123
- const operatorCharactersString_ = "!@#$%&/=?+|^~*<>.:-;";
124
- let operatorCharacters_ = ff_core_Set.empty_();
125
- ff_core_List.List_map(ff_core_List.range_(ff_core_String.String_size(operatorCharactersString_)), ((j_) => {
126
- operatorCharacters_ = ff_core_Set.Set_add(operatorCharacters_, ff_core_String.String_grab(operatorCharactersString_, j_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Char_Char)
127
- }));
128
- function emitToken_(kind_, startOffset_, stopOffset_) {
129
- if((!ff_core_Stack.Stack_isEmpty(tokens_))) {
130
- const last_ = ff_core_Stack.Stack_grabLast(tokens_);
131
- if((((last_.stopLine_ === startLine_) && ff_compiler_Token.ff_core_Equal_Equal$ff_compiler_Token_TokenKind.equals_(last_.kind_, ff_compiler_Token.LLower())) && ff_compiler_Token.TokenKind_afterKeyword(kind_))) {
132
- if((((completionLine_ === last_.startLine_) && (completionColumn_ >= ((1 + last_.startOffset_) - last_.startLineOffset_))) && (completionColumn_ <= ((1 + last_.stopOffset_) - last_.stopLineOffset_)))) {
133
- ff_core_Stack.Stack_push(tokens_, ff_compiler_Token.Token(file_, code_, ff_compiler_Token.LSeparator(), startLine_, startLineOffset_, startLineOffset_, startLine_, startLineOffset_, startLineOffset_))
134
- } else {
135
- ff_core_Stack.Stack_modify(tokens_, (ff_core_Stack.Stack_size(tokens_) - 1), ((_w1) => {
136
- {
137
- const _1 = _w1;
138
- {
139
- const _c = _1;
140
- return ff_compiler_Token.Token(_c.file_, _c.code_, ff_compiler_Token.LKeyword(), _c.startLine_, _c.startLineOffset_, _c.startOffset_, _c.stopLine_, _c.stopLineOffset_, _c.stopOffset_)
141
- return
142
- }
143
- }
144
- }))
145
- }
146
- };
147
- if((((last_.stopLine_ !== startLine_) && ff_compiler_Token.TokenKind_beforeSeparator(last_.kind_)) && ff_compiler_Token.TokenKind_afterSeparator(kind_))) {
148
- ff_core_Stack.Stack_push(tokens_, ff_compiler_Token.Token(file_, code_, ff_compiler_Token.LSeparator(), startLine_, startLineOffset_, startLineOffset_, startLine_, startLineOffset_, startLineOffset_))
149
- }
150
- };
151
- ff_core_Stack.Stack_push(tokens_, ff_compiler_Token.Token(file_, code_, kind_, startLine_, startLineOffset_, startOffset_, line_, lineOffset_, stopOffset_))
152
- }
153
- let i_ = 0;
154
- function throwError_(message_) {
155
- const column_ = ((i_ - startLineOffset_) + 1);
156
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(ff_compiler_Syntax.Location(file_, line_, column_), message_), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
157
- }
158
- try {
159
- while((i_ < ff_core_String.String_size(code_))) {
160
- startLine_ = line_;
161
- startLineOffset_ = lineOffset_;
162
- if((completionLine_ === line_)) {
163
- while(((i_ < ff_core_String.String_size(code_)) && (((ff_core_String.String_grab(code_, i_) === 32) || (ff_core_String.String_grab(code_, i_) === 9)) || (ff_core_String.String_grab(code_, i_) === 13)))) {
164
- if((completionColumn_ === ((1 + i_) - lineOffset_))) {
165
- emitToken_(ff_compiler_Token.LLower(), i_, i_)
166
- };
167
- i_ += 1
168
- };
169
- if(((i_ < ff_core_String.String_size(code_)) && (completionColumn_ === ((1 + i_) - lineOffset_)))) {
170
- const c_ = ff_core_String.String_grab(code_, i_);
171
- if(((((!ff_core_Char.Char_isAsciiLetterOrDigit(c_)) && (c_ !== 95)) && (c_ !== 39)) && (c_ !== 34))) {
172
- emitToken_(ff_compiler_Token.LLower(), i_, i_);
173
- if((((i_ + 1) < ff_core_String.String_size(code_)) && (ff_core_String.String_grab(code_, i_) === 95))) {
174
- i_ += 1
175
- }
176
- }
177
- }
178
- } else {
179
- while(((i_ < ff_core_String.String_size(code_)) && (((ff_core_String.String_grab(code_, i_) === 32) || (ff_core_String.String_grab(code_, i_) === 9)) || (ff_core_String.String_grab(code_, i_) === 13)))) {
180
- i_ += 1
181
- }
182
- };
183
- if((i_ < ff_core_String.String_size(code_))) {
184
- const start_ = i_;
185
- if((ff_core_String.String_grab(code_, i_) === 10)) {
186
- i_ += 1;
187
- line_ += 1;
188
- lineOffset_ = i_
189
- } else if(((ff_core_String.String_grab(code_, i_) === 47) && (ff_core_String.String_grab(code_, (i_ + 1)) === 47))) {
190
- i_ += 2;
191
- while(((i_ < ff_core_String.String_size(code_)) && (ff_core_String.String_grab(code_, i_) !== 10))) {
192
- i_ += 1
193
- }
194
- } else if(((ff_core_String.String_grab(code_, i_) === 47) && (ff_core_String.String_grab(code_, (i_ + 1)) === 42))) {
195
- i_ += 2;
196
- while(((i_ < ff_core_String.String_size(code_)) && ((ff_core_String.String_grab(code_, i_) !== 42) || (ff_core_String.String_grab(code_, (i_ + 1)) !== 47)))) {
197
- if((i_ >= ff_core_String.String_size(code_))) {
198
- throwError_((("Expected end of comment started on line " + startLine_) + ", got end of file."))
199
- };
200
- if((ff_core_String.String_grab(code_, i_) === 10)) {
201
- line_ += 1;
202
- lineOffset_ = (i_ + 1)
203
- };
204
- i_ += 1
205
- };
206
- i_ += 2
207
- } else if(((ff_core_String.String_grab(code_, i_) === 34) || (ff_core_String.String_grab(code_, i_) === 39))) {
208
- const endSign_ = ff_core_String.String_grab(code_, i_);
209
- let multiLine_ = (((((i_ + 2) < ff_core_String.String_size(code_)) && (ff_core_String.String_grab(code_, i_) === 34)) && (ff_core_String.String_grab(code_, (i_ + 1)) === 34)) && (ff_core_String.String_grab(code_, (i_ + 2)) === 34));
210
- i_ += (multiLine_
211
- ? 3
212
- : 1);
213
- while(((i_ < ff_core_String.String_size(code_)) && (multiLine_ || (ff_core_String.String_grab(code_, i_) !== endSign_)))) {
214
- if((ff_core_String.String_grab(code_, i_) === 10)) {
215
- if(multiLine_) {
216
- line_ += 1;
217
- lineOffset_ = (i_ + 1)
218
- } else {
219
- throwError_("Unexpected end of line in string.")
220
- }
221
- };
222
- if((i_ >= ff_core_String.String_size(code_))) {
223
- throwError_((("Expected end of string started on line " + startLine_) + ", got end of file."))
224
- };
225
- if(((ff_core_String.String_grab(code_, i_) === 92) && (ff_core_String.String_grab(code_, (i_ + 1)) !== 10))) {
226
- i_ += 1
227
- };
228
- if((((((multiLine_ && ((i_ + 2) < ff_core_String.String_size(code_))) && (((i_ + 3) >= ff_core_String.String_size(code_)) || (ff_core_String.String_grab(code_, (i_ + 3)) !== 34))) && (ff_core_String.String_grab(code_, i_) === 34)) && (ff_core_String.String_grab(code_, (i_ + 1)) === 34)) && (ff_core_String.String_grab(code_, (i_ + 2)) === 34))) {
229
- multiLine_ = false;
230
- i_ += 2
231
- } else {
232
- i_ += 1
233
- }
234
- };
235
- i_ += 1;
236
- emitToken_(((endSign_ === 34)
237
- ? ff_compiler_Token.LString()
238
- : ff_compiler_Token.LChar()), start_, i_)
239
- } else if(ff_core_Char.Char_isAsciiLetter(ff_core_String.String_grab(code_, i_))) {
240
- const kind_ = ((ff_core_String.String_grab(code_, i_) >= 97)
241
- ? ff_compiler_Token.LLower()
242
- : ff_compiler_Token.LUpper());
243
- i_ += 1;
244
- while(((i_ < ff_core_String.String_size(code_)) && ff_core_Char.Char_isAsciiLetterOrDigit(ff_core_String.String_grab(code_, i_)))) {
245
- i_ += 1
246
- };
247
- if((((i_ < ff_core_String.String_size(code_)) && ff_compiler_Token.ff_core_Equal_Equal$ff_compiler_Token_TokenKind.equals_(kind_, ff_compiler_Token.LUpper())) && (ff_core_String.String_grab(code_, i_) === 46))) {
248
- i_ += 1;
249
- emitToken_(ff_compiler_Token.LNamespace(), start_, i_)
250
- } else {
251
- emitToken_(kind_, start_, i_)
252
- }
253
- } else if(ff_core_Char.Char_isAsciiDigit(ff_core_String.String_grab(code_, i_))) {
254
- let dot_ = false;
255
- let exponent_ = false;
256
- while(((i_ < ff_core_String.String_size(code_)) && ff_core_Char.Char_isAsciiDigit(ff_core_String.String_grab(code_, i_)))) {
257
- i_ += 1;
258
- if((((ff_core_String.String_grab(code_, i_) === 101) || (ff_core_String.String_grab(code_, i_) === 69)) && (!exponent_))) {
259
- i_ += 1;
260
- dot_ = true;
261
- exponent_ = true;
262
- if(((ff_core_String.String_grab(code_, i_) === 43) || (ff_core_String.String_grab(code_, i_) === 45))) {
263
- i_ += 1
264
- }
265
- };
266
- if(((((((i_ + 1) < ff_core_String.String_size(code_)) && (ff_core_String.String_grab(code_, i_) === 46)) && ff_core_Char.Char_isAsciiDigit(ff_core_String.String_grab(code_, (i_ + 1)))) && (!dot_)) && (!exponent_))) {
267
- i_ += 1;
268
- dot_ = true
269
- }
270
- };
271
- emitToken_(((dot_ || exponent_)
272
- ? ff_compiler_Token.LFloat()
273
- : ff_compiler_Token.LInt()), start_, i_)
274
- } else if((ff_core_String.String_grab(code_, i_) === 95)) {
275
- i_ += 1;
276
- emitToken_(ff_compiler_Token.LWildcard(), start_, i_)
277
- } else if((ff_core_String.String_grab(code_, i_) === 44)) {
278
- i_ += 1;
279
- emitToken_(ff_compiler_Token.LComma(), start_, i_)
280
- } else if(ff_core_Set.Set_contains(operatorCharacters_, ff_core_String.String_grab(code_, i_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Char_Char)) {
281
- i_ += 1;
282
- if(((((ff_core_String.String_grab(code_, (i_ - 1)) === 46) && ((i_ + 1) < ff_core_String.String_size(code_))) && (ff_core_String.String_grab(code_, i_) === 46)) && (ff_core_String.String_grab(code_, (i_ + 1)) !== 46))) {
283
- emitToken_(ff_compiler_Token.LDot(), start_, i_);
284
- const newStart_ = i_;
285
- if((!ff_core_Option.Option_isEmpty(completionAt_))) {
286
- emitToken_(ff_compiler_Token.LLower(), newStart_, newStart_)
287
- };
288
- i_ += 1;
289
- emitToken_(ff_compiler_Token.LDot(), newStart_, i_)
290
- } else {
291
- while(((i_ < ff_core_String.String_size(code_)) && ff_core_Set.Set_contains(operatorCharacters_, ff_core_String.String_grab(code_, i_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Char_Char))) {
292
- i_ += 1
293
- };
294
- const o_ = ((((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 46))
295
- ? ff_compiler_Token.LDot()
296
- : (((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 59))
297
- ? ff_compiler_Token.LSemicolon()
298
- : (((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 124))
299
- ? ff_compiler_Token.LPipe()
300
- : (((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 58))
301
- ? ff_compiler_Token.LColon()
302
- : (((((i_ - start_) === 3) && (ff_core_String.String_grab(code_, (i_ - 3)) === 46)) && (ff_core_String.String_grab(code_, (i_ - 2)) === 46)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 46))
303
- ? ff_compiler_Token.LDotDotDot()
304
- : ((((i_ - start_) === 2) && (ff_core_String.String_grab(code_, (i_ - 2)) === 61)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 62))
305
- ? ff_compiler_Token.LArrowThick()
306
- : (((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 61))
307
- ? ff_compiler_Token.LAssign()
308
- : ((((i_ - start_) === 2) && (ff_core_String.String_grab(code_, (i_ - 2)) === 43)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 61))
309
- ? ff_compiler_Token.LAssignPlus()
310
- : ((((i_ - start_) === 2) && (ff_core_String.String_grab(code_, (i_ - 2)) === 45)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 61))
311
- ? ff_compiler_Token.LAssignMinus()
312
- : (((((i_ - start_) === 3) && (ff_core_String.String_grab(code_, (i_ - 3)) === 58)) && (ff_core_String.String_grab(code_, (i_ - 2)) === 58)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 61))
313
- ? ff_compiler_Token.LAssignLink()
314
- : ff_compiler_Token.LOperator());
315
- emitToken_(o_, start_, i_)
316
- }
317
- } else if((((ff_core_String.String_grab(code_, i_) === 40) || (ff_core_String.String_grab(code_, i_) === 91)) || (ff_core_String.String_grab(code_, i_) === 123))) {
318
- i_ += 1;
319
- emitToken_(ff_compiler_Token.LBracketLeft(), start_, i_)
320
- } else if((((ff_core_String.String_grab(code_, i_) === 41) || (ff_core_String.String_grab(code_, i_) === 93)) || (ff_core_String.String_grab(code_, i_) === 125))) {
321
- i_ += 1;
322
- emitToken_(ff_compiler_Token.LBracketRight(), start_, i_)
323
- } else if((i_ < ff_core_String.String_size(code_))) {
324
- if(attemptFixes_) {
325
- i_ += 1
326
- } else {
327
- throwError_(("Unexpected character: " + ff_core_Show.ff_core_Show_Show$ff_core_Char_Char.show_(ff_core_String.String_grab(code_, i_))))
328
- }
329
- } else {}
330
- }
331
- }
332
- } catch(_error) {
333
- if(!_error.ffException) throw _error
334
- const _exception = ff_core_Any.fromAny_(_error.ffException, ff_core_Core.ff_core_Any_HasAnyTag$ff_core_Core_GrabException)
335
- if(!_exception.Some) throw _error
336
- const e_ = _exception.value_;
337
- const error_ = _error;
338
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(ff_compiler_Syntax.Location(file_, line_, (i_ - lineOffset_)), "Unexpected end of file"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
339
- };
340
- ff_core_List.List_each(ff_core_List.range_(5), ((_) => {
341
- emitToken_(ff_compiler_Token.LEnd(), i_, i_)
342
- }));
343
- return ff_core_Stack.Stack_drain(tokens_)
344
- }
345
-
346
- export async function tokenize_$(file_, code_, completionAt_, attemptFixes_, $task) {
347
- const completionLine_ = ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Option.Option_filter(completionAt_, ((_w1) => {
348
- return (_w1.file_ === file_)
349
- })), ((_w1) => {
350
- return _w1.line_
351
- })), (() => {
352
- return (-1)
353
- }));
354
- const completionColumn_ = ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Option.Option_filter(completionAt_, ((_w1) => {
355
- return (_w1.file_ === file_)
356
- })), ((_w1) => {
357
- return _w1.column_
358
- })), (() => {
359
- return (-1)
360
- }));
361
- const tokens_ = ff_core_Stack.make_();
362
- let line_ = 1;
363
- let lineOffset_ = 0;
364
- let startLine_ = line_;
365
- let startLineOffset_ = lineOffset_;
366
- const operatorCharactersString_ = "!@#$%&/=?+|^~*<>.:-;";
367
- let operatorCharacters_ = ff_core_Set.empty_();
368
- ff_core_List.List_map(ff_core_List.range_(ff_core_String.String_size(operatorCharactersString_)), ((j_) => {
369
- operatorCharacters_ = ff_core_Set.Set_add(operatorCharacters_, ff_core_String.String_grab(operatorCharactersString_, j_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Char_Char)
370
- }));
371
- function emitToken_(kind_, startOffset_, stopOffset_) {
372
- if((!ff_core_Stack.Stack_isEmpty(tokens_))) {
373
- const last_ = ff_core_Stack.Stack_grabLast(tokens_);
374
- if((((last_.stopLine_ === startLine_) && ff_compiler_Token.ff_core_Equal_Equal$ff_compiler_Token_TokenKind.equals_(last_.kind_, ff_compiler_Token.LLower())) && ff_compiler_Token.TokenKind_afterKeyword(kind_))) {
375
- if((((completionLine_ === last_.startLine_) && (completionColumn_ >= ((1 + last_.startOffset_) - last_.startLineOffset_))) && (completionColumn_ <= ((1 + last_.stopOffset_) - last_.stopLineOffset_)))) {
376
- ff_core_Stack.Stack_push(tokens_, ff_compiler_Token.Token(file_, code_, ff_compiler_Token.LSeparator(), startLine_, startLineOffset_, startLineOffset_, startLine_, startLineOffset_, startLineOffset_))
377
- } else {
378
- ff_core_Stack.Stack_modify(tokens_, (ff_core_Stack.Stack_size(tokens_) - 1), ((_w1) => {
379
- {
380
- const _1 = _w1;
381
- {
382
- const _c = _1;
383
- return ff_compiler_Token.Token(_c.file_, _c.code_, ff_compiler_Token.LKeyword(), _c.startLine_, _c.startLineOffset_, _c.startOffset_, _c.stopLine_, _c.stopLineOffset_, _c.stopOffset_)
384
- return
385
- }
386
- }
387
- }))
388
- }
389
- };
390
- if((((last_.stopLine_ !== startLine_) && ff_compiler_Token.TokenKind_beforeSeparator(last_.kind_)) && ff_compiler_Token.TokenKind_afterSeparator(kind_))) {
391
- ff_core_Stack.Stack_push(tokens_, ff_compiler_Token.Token(file_, code_, ff_compiler_Token.LSeparator(), startLine_, startLineOffset_, startLineOffset_, startLine_, startLineOffset_, startLineOffset_))
392
- }
393
- };
394
- ff_core_Stack.Stack_push(tokens_, ff_compiler_Token.Token(file_, code_, kind_, startLine_, startLineOffset_, startOffset_, line_, lineOffset_, stopOffset_))
395
- }
396
- let i_ = 0;
397
- function throwError_(message_) {
398
- const column_ = ((i_ - startLineOffset_) + 1);
399
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(ff_compiler_Syntax.Location(file_, line_, column_), message_), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
400
- }
401
- try {
402
- while((i_ < ff_core_String.String_size(code_))) {
403
- startLine_ = line_;
404
- startLineOffset_ = lineOffset_;
405
- if((completionLine_ === line_)) {
406
- while(((i_ < ff_core_String.String_size(code_)) && (((ff_core_String.String_grab(code_, i_) === 32) || (ff_core_String.String_grab(code_, i_) === 9)) || (ff_core_String.String_grab(code_, i_) === 13)))) {
407
- if((completionColumn_ === ((1 + i_) - lineOffset_))) {
408
- emitToken_(ff_compiler_Token.LLower(), i_, i_)
409
- };
410
- i_ += 1
411
- };
412
- if(((i_ < ff_core_String.String_size(code_)) && (completionColumn_ === ((1 + i_) - lineOffset_)))) {
413
- const c_ = ff_core_String.String_grab(code_, i_);
414
- if(((((!ff_core_Char.Char_isAsciiLetterOrDigit(c_)) && (c_ !== 95)) && (c_ !== 39)) && (c_ !== 34))) {
415
- emitToken_(ff_compiler_Token.LLower(), i_, i_);
416
- if((((i_ + 1) < ff_core_String.String_size(code_)) && (ff_core_String.String_grab(code_, i_) === 95))) {
417
- i_ += 1
418
- }
419
- }
420
- }
421
- } else {
422
- while(((i_ < ff_core_String.String_size(code_)) && (((ff_core_String.String_grab(code_, i_) === 32) || (ff_core_String.String_grab(code_, i_) === 9)) || (ff_core_String.String_grab(code_, i_) === 13)))) {
423
- i_ += 1
424
- }
425
- };
426
- if((i_ < ff_core_String.String_size(code_))) {
427
- const start_ = i_;
428
- if((ff_core_String.String_grab(code_, i_) === 10)) {
429
- i_ += 1;
430
- line_ += 1;
431
- lineOffset_ = i_
432
- } else if(((ff_core_String.String_grab(code_, i_) === 47) && (ff_core_String.String_grab(code_, (i_ + 1)) === 47))) {
433
- i_ += 2;
434
- while(((i_ < ff_core_String.String_size(code_)) && (ff_core_String.String_grab(code_, i_) !== 10))) {
435
- i_ += 1
436
- }
437
- } else if(((ff_core_String.String_grab(code_, i_) === 47) && (ff_core_String.String_grab(code_, (i_ + 1)) === 42))) {
438
- i_ += 2;
439
- while(((i_ < ff_core_String.String_size(code_)) && ((ff_core_String.String_grab(code_, i_) !== 42) || (ff_core_String.String_grab(code_, (i_ + 1)) !== 47)))) {
440
- if((i_ >= ff_core_String.String_size(code_))) {
441
- throwError_((("Expected end of comment started on line " + startLine_) + ", got end of file."))
442
- };
443
- if((ff_core_String.String_grab(code_, i_) === 10)) {
444
- line_ += 1;
445
- lineOffset_ = (i_ + 1)
446
- };
447
- i_ += 1
448
- };
449
- i_ += 2
450
- } else if(((ff_core_String.String_grab(code_, i_) === 34) || (ff_core_String.String_grab(code_, i_) === 39))) {
451
- const endSign_ = ff_core_String.String_grab(code_, i_);
452
- let multiLine_ = (((((i_ + 2) < ff_core_String.String_size(code_)) && (ff_core_String.String_grab(code_, i_) === 34)) && (ff_core_String.String_grab(code_, (i_ + 1)) === 34)) && (ff_core_String.String_grab(code_, (i_ + 2)) === 34));
453
- i_ += (multiLine_
454
- ? 3
455
- : 1);
456
- while(((i_ < ff_core_String.String_size(code_)) && (multiLine_ || (ff_core_String.String_grab(code_, i_) !== endSign_)))) {
457
- if((ff_core_String.String_grab(code_, i_) === 10)) {
458
- if(multiLine_) {
459
- line_ += 1;
460
- lineOffset_ = (i_ + 1)
461
- } else {
462
- throwError_("Unexpected end of line in string.")
463
- }
464
- };
465
- if((i_ >= ff_core_String.String_size(code_))) {
466
- throwError_((("Expected end of string started on line " + startLine_) + ", got end of file."))
467
- };
468
- if(((ff_core_String.String_grab(code_, i_) === 92) && (ff_core_String.String_grab(code_, (i_ + 1)) !== 10))) {
469
- i_ += 1
470
- };
471
- if((((((multiLine_ && ((i_ + 2) < ff_core_String.String_size(code_))) && (((i_ + 3) >= ff_core_String.String_size(code_)) || (ff_core_String.String_grab(code_, (i_ + 3)) !== 34))) && (ff_core_String.String_grab(code_, i_) === 34)) && (ff_core_String.String_grab(code_, (i_ + 1)) === 34)) && (ff_core_String.String_grab(code_, (i_ + 2)) === 34))) {
472
- multiLine_ = false;
473
- i_ += 2
474
- } else {
475
- i_ += 1
476
- }
477
- };
478
- i_ += 1;
479
- emitToken_(((endSign_ === 34)
480
- ? ff_compiler_Token.LString()
481
- : ff_compiler_Token.LChar()), start_, i_)
482
- } else if(ff_core_Char.Char_isAsciiLetter(ff_core_String.String_grab(code_, i_))) {
483
- const kind_ = ((ff_core_String.String_grab(code_, i_) >= 97)
484
- ? ff_compiler_Token.LLower()
485
- : ff_compiler_Token.LUpper());
486
- i_ += 1;
487
- while(((i_ < ff_core_String.String_size(code_)) && ff_core_Char.Char_isAsciiLetterOrDigit(ff_core_String.String_grab(code_, i_)))) {
488
- i_ += 1
489
- };
490
- if((((i_ < ff_core_String.String_size(code_)) && ff_compiler_Token.ff_core_Equal_Equal$ff_compiler_Token_TokenKind.equals_(kind_, ff_compiler_Token.LUpper())) && (ff_core_String.String_grab(code_, i_) === 46))) {
491
- i_ += 1;
492
- emitToken_(ff_compiler_Token.LNamespace(), start_, i_)
493
- } else {
494
- emitToken_(kind_, start_, i_)
495
- }
496
- } else if(ff_core_Char.Char_isAsciiDigit(ff_core_String.String_grab(code_, i_))) {
497
- let dot_ = false;
498
- let exponent_ = false;
499
- while(((i_ < ff_core_String.String_size(code_)) && ff_core_Char.Char_isAsciiDigit(ff_core_String.String_grab(code_, i_)))) {
500
- i_ += 1;
501
- if((((ff_core_String.String_grab(code_, i_) === 101) || (ff_core_String.String_grab(code_, i_) === 69)) && (!exponent_))) {
502
- i_ += 1;
503
- dot_ = true;
504
- exponent_ = true;
505
- if(((ff_core_String.String_grab(code_, i_) === 43) || (ff_core_String.String_grab(code_, i_) === 45))) {
506
- i_ += 1
507
- }
508
- };
509
- if(((((((i_ + 1) < ff_core_String.String_size(code_)) && (ff_core_String.String_grab(code_, i_) === 46)) && ff_core_Char.Char_isAsciiDigit(ff_core_String.String_grab(code_, (i_ + 1)))) && (!dot_)) && (!exponent_))) {
510
- i_ += 1;
511
- dot_ = true
512
- }
513
- };
514
- emitToken_(((dot_ || exponent_)
515
- ? ff_compiler_Token.LFloat()
516
- : ff_compiler_Token.LInt()), start_, i_)
517
- } else if((ff_core_String.String_grab(code_, i_) === 95)) {
518
- i_ += 1;
519
- emitToken_(ff_compiler_Token.LWildcard(), start_, i_)
520
- } else if((ff_core_String.String_grab(code_, i_) === 44)) {
521
- i_ += 1;
522
- emitToken_(ff_compiler_Token.LComma(), start_, i_)
523
- } else if(ff_core_Set.Set_contains(operatorCharacters_, ff_core_String.String_grab(code_, i_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Char_Char)) {
524
- i_ += 1;
525
- if(((((ff_core_String.String_grab(code_, (i_ - 1)) === 46) && ((i_ + 1) < ff_core_String.String_size(code_))) && (ff_core_String.String_grab(code_, i_) === 46)) && (ff_core_String.String_grab(code_, (i_ + 1)) !== 46))) {
526
- emitToken_(ff_compiler_Token.LDot(), start_, i_);
527
- const newStart_ = i_;
528
- if((!ff_core_Option.Option_isEmpty(completionAt_))) {
529
- emitToken_(ff_compiler_Token.LLower(), newStart_, newStart_)
530
- };
531
- i_ += 1;
532
- emitToken_(ff_compiler_Token.LDot(), newStart_, i_)
533
- } else {
534
- while(((i_ < ff_core_String.String_size(code_)) && ff_core_Set.Set_contains(operatorCharacters_, ff_core_String.String_grab(code_, i_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Char_Char))) {
535
- i_ += 1
536
- };
537
- const o_ = ((((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 46))
538
- ? ff_compiler_Token.LDot()
539
- : (((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 59))
540
- ? ff_compiler_Token.LSemicolon()
541
- : (((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 124))
542
- ? ff_compiler_Token.LPipe()
543
- : (((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 58))
544
- ? ff_compiler_Token.LColon()
545
- : (((((i_ - start_) === 3) && (ff_core_String.String_grab(code_, (i_ - 3)) === 46)) && (ff_core_String.String_grab(code_, (i_ - 2)) === 46)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 46))
546
- ? ff_compiler_Token.LDotDotDot()
547
- : ((((i_ - start_) === 2) && (ff_core_String.String_grab(code_, (i_ - 2)) === 61)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 62))
548
- ? ff_compiler_Token.LArrowThick()
549
- : (((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 61))
550
- ? ff_compiler_Token.LAssign()
551
- : ((((i_ - start_) === 2) && (ff_core_String.String_grab(code_, (i_ - 2)) === 43)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 61))
552
- ? ff_compiler_Token.LAssignPlus()
553
- : ((((i_ - start_) === 2) && (ff_core_String.String_grab(code_, (i_ - 2)) === 45)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 61))
554
- ? ff_compiler_Token.LAssignMinus()
555
- : (((((i_ - start_) === 3) && (ff_core_String.String_grab(code_, (i_ - 3)) === 58)) && (ff_core_String.String_grab(code_, (i_ - 2)) === 58)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 61))
556
- ? ff_compiler_Token.LAssignLink()
557
- : ff_compiler_Token.LOperator());
558
- emitToken_(o_, start_, i_)
559
- }
560
- } else if((((ff_core_String.String_grab(code_, i_) === 40) || (ff_core_String.String_grab(code_, i_) === 91)) || (ff_core_String.String_grab(code_, i_) === 123))) {
561
- i_ += 1;
562
- emitToken_(ff_compiler_Token.LBracketLeft(), start_, i_)
563
- } else if((((ff_core_String.String_grab(code_, i_) === 41) || (ff_core_String.String_grab(code_, i_) === 93)) || (ff_core_String.String_grab(code_, i_) === 125))) {
564
- i_ += 1;
565
- emitToken_(ff_compiler_Token.LBracketRight(), start_, i_)
566
- } else if((i_ < ff_core_String.String_size(code_))) {
567
- if(attemptFixes_) {
568
- i_ += 1
569
- } else {
570
- throwError_(("Unexpected character: " + ff_core_Show.ff_core_Show_Show$ff_core_Char_Char.show_(ff_core_String.String_grab(code_, i_))))
571
- }
572
- } else {}
573
- }
574
- }
575
- } catch(_error) {
576
- if(!_error.ffException) throw _error
577
- const _exception = ff_core_Any.fromAny_(_error.ffException, ff_core_Core.ff_core_Any_HasAnyTag$ff_core_Core_GrabException)
578
- if(!_exception.Some) throw _error
579
- const e_ = _exception.value_;
580
- const error_ = _error;
581
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(ff_compiler_Syntax.Location(file_, line_, (i_ - lineOffset_)), "Unexpected end of file"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
582
- };
583
- ff_core_List.List_each(ff_core_List.range_(5), ((_) => {
584
- emitToken_(ff_compiler_Token.LEnd(), i_, i_)
585
- }));
586
- return ff_core_Stack.Stack_drain(tokens_)
587
- }
588
-
589
-
590
-
591
-
592
-
593
-
1
+
2
+
3
+ import * as ff_compiler_Tokenizer from "../../ff/compiler/Tokenizer.mjs"
4
+
5
+ import * as ff_compiler_LspHook from "../../ff/compiler/LspHook.mjs"
6
+
7
+ import * as ff_compiler_Syntax from "../../ff/compiler/Syntax.mjs"
8
+
9
+ import * as ff_compiler_Token from "../../ff/compiler/Token.mjs"
10
+
11
+ import * as ff_core_Any from "../../ff/core/Any.mjs"
12
+
13
+ import * as ff_core_Array from "../../ff/core/Array.mjs"
14
+
15
+ import * as ff_core_AssetSystem from "../../ff/core/AssetSystem.mjs"
16
+
17
+ import * as ff_core_Atomic from "../../ff/core/Atomic.mjs"
18
+
19
+ import * as ff_core_Bool from "../../ff/core/Bool.mjs"
20
+
21
+ import * as ff_core_Box from "../../ff/core/Box.mjs"
22
+
23
+ import * as ff_core_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
24
+
25
+ import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
26
+
27
+ import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
28
+
29
+ import * as ff_core_Channel from "../../ff/core/Channel.mjs"
30
+
31
+ import * as ff_core_Char from "../../ff/core/Char.mjs"
32
+
33
+ import * as ff_core_Core from "../../ff/core/Core.mjs"
34
+
35
+ import * as ff_core_Duration from "../../ff/core/Duration.mjs"
36
+
37
+ import * as ff_core_Equal from "../../ff/core/Equal.mjs"
38
+
39
+ import * as ff_core_Error from "../../ff/core/Error.mjs"
40
+
41
+ import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
42
+
43
+ import * as ff_core_Float from "../../ff/core/Float.mjs"
44
+
45
+ import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
46
+
47
+ import * as ff_core_Instant from "../../ff/core/Instant.mjs"
48
+
49
+ import * as ff_core_Int from "../../ff/core/Int.mjs"
50
+
51
+ import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
52
+
53
+ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
54
+
55
+ import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
56
+
57
+ import * as ff_core_List from "../../ff/core/List.mjs"
58
+
59
+ import * as ff_core_Lock from "../../ff/core/Lock.mjs"
60
+
61
+ import * as ff_core_Log from "../../ff/core/Log.mjs"
62
+
63
+ import * as ff_core_Map from "../../ff/core/Map.mjs"
64
+
65
+ import * as ff_core_NodeSystem from "../../ff/core/NodeSystem.mjs"
66
+
67
+ import * as ff_core_Nothing from "../../ff/core/Nothing.mjs"
68
+
69
+ import * as ff_core_Option from "../../ff/core/Option.mjs"
70
+
71
+ import * as ff_core_Ordering from "../../ff/core/Ordering.mjs"
72
+
73
+ import * as ff_core_Pair from "../../ff/core/Pair.mjs"
74
+
75
+ import * as ff_core_Path from "../../ff/core/Path.mjs"
76
+
77
+ import * as ff_core_Serializable from "../../ff/core/Serializable.mjs"
78
+
79
+ import * as ff_core_Set from "../../ff/core/Set.mjs"
80
+
81
+ import * as ff_core_Show from "../../ff/core/Show.mjs"
82
+
83
+ import * as ff_core_SourceLocation from "../../ff/core/SourceLocation.mjs"
84
+
85
+ import * as ff_core_Stack from "../../ff/core/Stack.mjs"
86
+
87
+ import * as ff_core_Stream from "../../ff/core/Stream.mjs"
88
+
89
+ import * as ff_core_String from "../../ff/core/String.mjs"
90
+
91
+ import * as ff_core_StringMap from "../../ff/core/StringMap.mjs"
92
+
93
+ import * as ff_core_Task from "../../ff/core/Task.mjs"
94
+
95
+ import * as ff_core_Try from "../../ff/core/Try.mjs"
96
+
97
+ import * as ff_core_Unit from "../../ff/core/Unit.mjs"
98
+
99
+
100
+
101
+
102
+
103
+ export function tokenize_(file_, code_, completionAt_, attemptFixes_) {
104
+ const completionLine_ = ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Option.Option_filter(completionAt_, ((_w1) => {
105
+ return (_w1.file_ === file_)
106
+ })), ((_w1) => {
107
+ return _w1.line_
108
+ })), (() => {
109
+ return (-1)
110
+ }));
111
+ const completionColumn_ = ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Option.Option_filter(completionAt_, ((_w1) => {
112
+ return (_w1.file_ === file_)
113
+ })), ((_w1) => {
114
+ return _w1.column_
115
+ })), (() => {
116
+ return (-1)
117
+ }));
118
+ const tokens_ = ff_core_Stack.make_();
119
+ let line_ = 1;
120
+ let lineOffset_ = 0;
121
+ let startLine_ = line_;
122
+ let startLineOffset_ = lineOffset_;
123
+ const operatorCharactersString_ = "!@#$%&/=?+|^~*<>.:-;";
124
+ let operatorCharacters_ = ff_core_Set.empty_();
125
+ ff_core_List.List_map(ff_core_List.range_(ff_core_String.String_size(operatorCharactersString_)), ((j_) => {
126
+ operatorCharacters_ = ff_core_Set.Set_add(operatorCharacters_, ff_core_String.String_grab(operatorCharactersString_, j_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Char_Char)
127
+ }));
128
+ function emitToken_(kind_, startOffset_, stopOffset_) {
129
+ if((!ff_core_Stack.Stack_isEmpty(tokens_))) {
130
+ const last_ = ff_core_Stack.Stack_grabLast(tokens_);
131
+ if((((last_.stopLine_ === startLine_) && ff_compiler_Token.ff_core_Equal_Equal$ff_compiler_Token_TokenKind.equals_(last_.kind_, ff_compiler_Token.LLower())) && ff_compiler_Token.TokenKind_afterKeyword(kind_))) {
132
+ if((((completionLine_ === last_.startLine_) && (completionColumn_ >= ((1 + last_.startOffset_) - last_.startLineOffset_))) && (completionColumn_ <= ((1 + last_.stopOffset_) - last_.stopLineOffset_)))) {
133
+ ff_core_Stack.Stack_push(tokens_, ff_compiler_Token.Token(file_, code_, ff_compiler_Token.LSeparator(), startLine_, startLineOffset_, startLineOffset_, startLine_, startLineOffset_, startLineOffset_))
134
+ } else {
135
+ ff_core_Stack.Stack_modify(tokens_, (ff_core_Stack.Stack_size(tokens_) - 1), ((_w1) => {
136
+ {
137
+ const _1 = _w1;
138
+ {
139
+ const _c = _1;
140
+ return ff_compiler_Token.Token(_c.file_, _c.code_, ff_compiler_Token.LKeyword(), _c.startLine_, _c.startLineOffset_, _c.startOffset_, _c.stopLine_, _c.stopLineOffset_, _c.stopOffset_)
141
+ return
142
+ }
143
+ }
144
+ }))
145
+ }
146
+ };
147
+ if((((last_.stopLine_ !== startLine_) && ff_compiler_Token.TokenKind_beforeSeparator(last_.kind_)) && ff_compiler_Token.TokenKind_afterSeparator(kind_))) {
148
+ ff_core_Stack.Stack_push(tokens_, ff_compiler_Token.Token(file_, code_, ff_compiler_Token.LSeparator(), startLine_, startLineOffset_, startLineOffset_, startLine_, startLineOffset_, startLineOffset_))
149
+ }
150
+ };
151
+ ff_core_Stack.Stack_push(tokens_, ff_compiler_Token.Token(file_, code_, kind_, startLine_, startLineOffset_, startOffset_, line_, lineOffset_, stopOffset_))
152
+ }
153
+ let i_ = 0;
154
+ function throwError_(message_) {
155
+ const column_ = ((i_ - startLineOffset_) + 1);
156
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(ff_compiler_Syntax.Location(file_, line_, column_), message_), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
157
+ }
158
+ try {
159
+ while((i_ < ff_core_String.String_size(code_))) {
160
+ startLine_ = line_;
161
+ startLineOffset_ = lineOffset_;
162
+ if((completionLine_ === line_)) {
163
+ while(((i_ < ff_core_String.String_size(code_)) && (((ff_core_String.String_grab(code_, i_) === 32) || (ff_core_String.String_grab(code_, i_) === 9)) || (ff_core_String.String_grab(code_, i_) === 13)))) {
164
+ if((completionColumn_ === ((1 + i_) - lineOffset_))) {
165
+ emitToken_(ff_compiler_Token.LLower(), i_, i_)
166
+ };
167
+ i_ += 1
168
+ };
169
+ if(((i_ < ff_core_String.String_size(code_)) && (completionColumn_ === ((1 + i_) - lineOffset_)))) {
170
+ const c_ = ff_core_String.String_grab(code_, i_);
171
+ if(((((!ff_core_Char.Char_isAsciiLetterOrDigit(c_)) && (c_ !== 95)) && (c_ !== 39)) && (c_ !== 34))) {
172
+ emitToken_(ff_compiler_Token.LLower(), i_, i_);
173
+ if((((i_ + 1) < ff_core_String.String_size(code_)) && (ff_core_String.String_grab(code_, i_) === 95))) {
174
+ i_ += 1
175
+ }
176
+ }
177
+ }
178
+ } else {
179
+ while(((i_ < ff_core_String.String_size(code_)) && (((ff_core_String.String_grab(code_, i_) === 32) || (ff_core_String.String_grab(code_, i_) === 9)) || (ff_core_String.String_grab(code_, i_) === 13)))) {
180
+ i_ += 1
181
+ }
182
+ };
183
+ if((i_ < ff_core_String.String_size(code_))) {
184
+ const start_ = i_;
185
+ if((ff_core_String.String_grab(code_, i_) === 10)) {
186
+ i_ += 1;
187
+ line_ += 1;
188
+ lineOffset_ = i_
189
+ } else if(((ff_core_String.String_grab(code_, i_) === 47) && (ff_core_String.String_grab(code_, (i_ + 1)) === 47))) {
190
+ i_ += 2;
191
+ while(((i_ < ff_core_String.String_size(code_)) && (ff_core_String.String_grab(code_, i_) !== 10))) {
192
+ i_ += 1
193
+ }
194
+ } else if(((ff_core_String.String_grab(code_, i_) === 47) && (ff_core_String.String_grab(code_, (i_ + 1)) === 42))) {
195
+ i_ += 2;
196
+ while(((i_ < ff_core_String.String_size(code_)) && ((ff_core_String.String_grab(code_, i_) !== 42) || (ff_core_String.String_grab(code_, (i_ + 1)) !== 47)))) {
197
+ if((i_ >= ff_core_String.String_size(code_))) {
198
+ throwError_((("Expected end of comment started on line " + startLine_) + ", got end of file."))
199
+ };
200
+ if((ff_core_String.String_grab(code_, i_) === 10)) {
201
+ line_ += 1;
202
+ lineOffset_ = (i_ + 1)
203
+ };
204
+ i_ += 1
205
+ };
206
+ i_ += 2
207
+ } else if(((ff_core_String.String_grab(code_, i_) === 34) || (ff_core_String.String_grab(code_, i_) === 39))) {
208
+ const endSign_ = ff_core_String.String_grab(code_, i_);
209
+ let multiLine_ = (((((i_ + 2) < ff_core_String.String_size(code_)) && (ff_core_String.String_grab(code_, i_) === 34)) && (ff_core_String.String_grab(code_, (i_ + 1)) === 34)) && (ff_core_String.String_grab(code_, (i_ + 2)) === 34));
210
+ i_ += (multiLine_
211
+ ? 3
212
+ : 1);
213
+ while(((i_ < ff_core_String.String_size(code_)) && (multiLine_ || (ff_core_String.String_grab(code_, i_) !== endSign_)))) {
214
+ if((ff_core_String.String_grab(code_, i_) === 10)) {
215
+ if(multiLine_) {
216
+ line_ += 1;
217
+ lineOffset_ = (i_ + 1)
218
+ } else {
219
+ throwError_("Unexpected end of line in string.")
220
+ }
221
+ };
222
+ if((i_ >= ff_core_String.String_size(code_))) {
223
+ throwError_((("Expected end of string started on line " + startLine_) + ", got end of file."))
224
+ };
225
+ if(((ff_core_String.String_grab(code_, i_) === 92) && (ff_core_String.String_grab(code_, (i_ + 1)) !== 10))) {
226
+ i_ += 1
227
+ };
228
+ if((((((multiLine_ && ((i_ + 2) < ff_core_String.String_size(code_))) && (((i_ + 3) >= ff_core_String.String_size(code_)) || (ff_core_String.String_grab(code_, (i_ + 3)) !== 34))) && (ff_core_String.String_grab(code_, i_) === 34)) && (ff_core_String.String_grab(code_, (i_ + 1)) === 34)) && (ff_core_String.String_grab(code_, (i_ + 2)) === 34))) {
229
+ multiLine_ = false;
230
+ i_ += 2
231
+ } else {
232
+ i_ += 1
233
+ }
234
+ };
235
+ i_ += 1;
236
+ emitToken_(((endSign_ === 34)
237
+ ? ff_compiler_Token.LString()
238
+ : ff_compiler_Token.LChar()), start_, i_)
239
+ } else if(ff_core_Char.Char_isAsciiLetter(ff_core_String.String_grab(code_, i_))) {
240
+ const kind_ = ((ff_core_String.String_grab(code_, i_) >= 97)
241
+ ? ff_compiler_Token.LLower()
242
+ : ff_compiler_Token.LUpper());
243
+ i_ += 1;
244
+ while(((i_ < ff_core_String.String_size(code_)) && ff_core_Char.Char_isAsciiLetterOrDigit(ff_core_String.String_grab(code_, i_)))) {
245
+ i_ += 1
246
+ };
247
+ if((((i_ < ff_core_String.String_size(code_)) && ff_compiler_Token.ff_core_Equal_Equal$ff_compiler_Token_TokenKind.equals_(kind_, ff_compiler_Token.LUpper())) && (ff_core_String.String_grab(code_, i_) === 46))) {
248
+ i_ += 1;
249
+ emitToken_(ff_compiler_Token.LNamespace(), start_, i_)
250
+ } else {
251
+ emitToken_(kind_, start_, i_)
252
+ }
253
+ } else if(ff_core_Char.Char_isAsciiDigit(ff_core_String.String_grab(code_, i_))) {
254
+ let dot_ = false;
255
+ let exponent_ = false;
256
+ while(((i_ < ff_core_String.String_size(code_)) && ff_core_Char.Char_isAsciiDigit(ff_core_String.String_grab(code_, i_)))) {
257
+ i_ += 1;
258
+ if((((ff_core_String.String_grab(code_, i_) === 101) || (ff_core_String.String_grab(code_, i_) === 69)) && (!exponent_))) {
259
+ i_ += 1;
260
+ dot_ = true;
261
+ exponent_ = true;
262
+ if(((ff_core_String.String_grab(code_, i_) === 43) || (ff_core_String.String_grab(code_, i_) === 45))) {
263
+ i_ += 1
264
+ }
265
+ };
266
+ if(((((((i_ + 1) < ff_core_String.String_size(code_)) && (ff_core_String.String_grab(code_, i_) === 46)) && ff_core_Char.Char_isAsciiDigit(ff_core_String.String_grab(code_, (i_ + 1)))) && (!dot_)) && (!exponent_))) {
267
+ i_ += 1;
268
+ dot_ = true
269
+ }
270
+ };
271
+ emitToken_(((dot_ || exponent_)
272
+ ? ff_compiler_Token.LFloat()
273
+ : ff_compiler_Token.LInt()), start_, i_)
274
+ } else if((ff_core_String.String_grab(code_, i_) === 95)) {
275
+ i_ += 1;
276
+ emitToken_(ff_compiler_Token.LWildcard(), start_, i_)
277
+ } else if((ff_core_String.String_grab(code_, i_) === 44)) {
278
+ i_ += 1;
279
+ emitToken_(ff_compiler_Token.LComma(), start_, i_)
280
+ } else if(ff_core_Set.Set_contains(operatorCharacters_, ff_core_String.String_grab(code_, i_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Char_Char)) {
281
+ i_ += 1;
282
+ if(((((ff_core_String.String_grab(code_, (i_ - 1)) === 46) && ((i_ + 1) < ff_core_String.String_size(code_))) && (ff_core_String.String_grab(code_, i_) === 46)) && (ff_core_String.String_grab(code_, (i_ + 1)) !== 46))) {
283
+ emitToken_(ff_compiler_Token.LDot(), start_, i_);
284
+ const newStart_ = i_;
285
+ if((!ff_core_Option.Option_isEmpty(completionAt_))) {
286
+ emitToken_(ff_compiler_Token.LLower(), newStart_, newStart_)
287
+ };
288
+ i_ += 1;
289
+ emitToken_(ff_compiler_Token.LDot(), newStart_, i_)
290
+ } else {
291
+ while(((i_ < ff_core_String.String_size(code_)) && ff_core_Set.Set_contains(operatorCharacters_, ff_core_String.String_grab(code_, i_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Char_Char))) {
292
+ i_ += 1
293
+ };
294
+ const o_ = ((((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 46))
295
+ ? ff_compiler_Token.LDot()
296
+ : (((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 59))
297
+ ? ff_compiler_Token.LSemicolon()
298
+ : (((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 124))
299
+ ? ff_compiler_Token.LPipe()
300
+ : (((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 58))
301
+ ? ff_compiler_Token.LColon()
302
+ : (((((i_ - start_) === 3) && (ff_core_String.String_grab(code_, (i_ - 3)) === 46)) && (ff_core_String.String_grab(code_, (i_ - 2)) === 46)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 46))
303
+ ? ff_compiler_Token.LDotDotDot()
304
+ : ((((i_ - start_) === 2) && (ff_core_String.String_grab(code_, (i_ - 2)) === 61)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 62))
305
+ ? ff_compiler_Token.LArrowThick()
306
+ : (((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 61))
307
+ ? ff_compiler_Token.LAssign()
308
+ : ((((i_ - start_) === 2) && (ff_core_String.String_grab(code_, (i_ - 2)) === 43)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 61))
309
+ ? ff_compiler_Token.LAssignPlus()
310
+ : ((((i_ - start_) === 2) && (ff_core_String.String_grab(code_, (i_ - 2)) === 45)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 61))
311
+ ? ff_compiler_Token.LAssignMinus()
312
+ : (((((i_ - start_) === 3) && (ff_core_String.String_grab(code_, (i_ - 3)) === 58)) && (ff_core_String.String_grab(code_, (i_ - 2)) === 58)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 61))
313
+ ? ff_compiler_Token.LAssignLink()
314
+ : ff_compiler_Token.LOperator());
315
+ emitToken_(o_, start_, i_)
316
+ }
317
+ } else if((((ff_core_String.String_grab(code_, i_) === 40) || (ff_core_String.String_grab(code_, i_) === 91)) || (ff_core_String.String_grab(code_, i_) === 123))) {
318
+ i_ += 1;
319
+ emitToken_(ff_compiler_Token.LBracketLeft(), start_, i_)
320
+ } else if((((ff_core_String.String_grab(code_, i_) === 41) || (ff_core_String.String_grab(code_, i_) === 93)) || (ff_core_String.String_grab(code_, i_) === 125))) {
321
+ i_ += 1;
322
+ emitToken_(ff_compiler_Token.LBracketRight(), start_, i_)
323
+ } else if((i_ < ff_core_String.String_size(code_))) {
324
+ if(attemptFixes_) {
325
+ i_ += 1
326
+ } else {
327
+ throwError_(("Unexpected character: " + ff_core_Show.ff_core_Show_Show$ff_core_Char_Char.show_(ff_core_String.String_grab(code_, i_))))
328
+ }
329
+ } else {}
330
+ }
331
+ }
332
+ } catch(_error) {
333
+ if(!_error.ffException) throw _error
334
+ const _exception = ff_core_Any.fromAny_(_error.ffException, ff_core_Core.ff_core_Any_HasAnyTag$ff_core_Core_GrabException)
335
+ if(!_exception.Some) throw _error
336
+ const e_ = _exception.value_;
337
+ const error_ = _error;
338
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(ff_compiler_Syntax.Location(file_, line_, (i_ - lineOffset_)), "Unexpected end of file"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
339
+ };
340
+ ff_core_List.List_each(ff_core_List.range_(5), ((_) => {
341
+ emitToken_(ff_compiler_Token.LEnd(), i_, i_)
342
+ }));
343
+ return ff_core_Stack.Stack_drain(tokens_)
344
+ }
345
+
346
+ export async function tokenize_$(file_, code_, completionAt_, attemptFixes_, $task) {
347
+ const completionLine_ = ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Option.Option_filter(completionAt_, ((_w1) => {
348
+ return (_w1.file_ === file_)
349
+ })), ((_w1) => {
350
+ return _w1.line_
351
+ })), (() => {
352
+ return (-1)
353
+ }));
354
+ const completionColumn_ = ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Option.Option_filter(completionAt_, ((_w1) => {
355
+ return (_w1.file_ === file_)
356
+ })), ((_w1) => {
357
+ return _w1.column_
358
+ })), (() => {
359
+ return (-1)
360
+ }));
361
+ const tokens_ = ff_core_Stack.make_();
362
+ let line_ = 1;
363
+ let lineOffset_ = 0;
364
+ let startLine_ = line_;
365
+ let startLineOffset_ = lineOffset_;
366
+ const operatorCharactersString_ = "!@#$%&/=?+|^~*<>.:-;";
367
+ let operatorCharacters_ = ff_core_Set.empty_();
368
+ ff_core_List.List_map(ff_core_List.range_(ff_core_String.String_size(operatorCharactersString_)), ((j_) => {
369
+ operatorCharacters_ = ff_core_Set.Set_add(operatorCharacters_, ff_core_String.String_grab(operatorCharactersString_, j_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Char_Char)
370
+ }));
371
+ function emitToken_(kind_, startOffset_, stopOffset_) {
372
+ if((!ff_core_Stack.Stack_isEmpty(tokens_))) {
373
+ const last_ = ff_core_Stack.Stack_grabLast(tokens_);
374
+ if((((last_.stopLine_ === startLine_) && ff_compiler_Token.ff_core_Equal_Equal$ff_compiler_Token_TokenKind.equals_(last_.kind_, ff_compiler_Token.LLower())) && ff_compiler_Token.TokenKind_afterKeyword(kind_))) {
375
+ if((((completionLine_ === last_.startLine_) && (completionColumn_ >= ((1 + last_.startOffset_) - last_.startLineOffset_))) && (completionColumn_ <= ((1 + last_.stopOffset_) - last_.stopLineOffset_)))) {
376
+ ff_core_Stack.Stack_push(tokens_, ff_compiler_Token.Token(file_, code_, ff_compiler_Token.LSeparator(), startLine_, startLineOffset_, startLineOffset_, startLine_, startLineOffset_, startLineOffset_))
377
+ } else {
378
+ ff_core_Stack.Stack_modify(tokens_, (ff_core_Stack.Stack_size(tokens_) - 1), ((_w1) => {
379
+ {
380
+ const _1 = _w1;
381
+ {
382
+ const _c = _1;
383
+ return ff_compiler_Token.Token(_c.file_, _c.code_, ff_compiler_Token.LKeyword(), _c.startLine_, _c.startLineOffset_, _c.startOffset_, _c.stopLine_, _c.stopLineOffset_, _c.stopOffset_)
384
+ return
385
+ }
386
+ }
387
+ }))
388
+ }
389
+ };
390
+ if((((last_.stopLine_ !== startLine_) && ff_compiler_Token.TokenKind_beforeSeparator(last_.kind_)) && ff_compiler_Token.TokenKind_afterSeparator(kind_))) {
391
+ ff_core_Stack.Stack_push(tokens_, ff_compiler_Token.Token(file_, code_, ff_compiler_Token.LSeparator(), startLine_, startLineOffset_, startLineOffset_, startLine_, startLineOffset_, startLineOffset_))
392
+ }
393
+ };
394
+ ff_core_Stack.Stack_push(tokens_, ff_compiler_Token.Token(file_, code_, kind_, startLine_, startLineOffset_, startOffset_, line_, lineOffset_, stopOffset_))
395
+ }
396
+ let i_ = 0;
397
+ function throwError_(message_) {
398
+ const column_ = ((i_ - startLineOffset_) + 1);
399
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(ff_compiler_Syntax.Location(file_, line_, column_), message_), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
400
+ }
401
+ try {
402
+ while((i_ < ff_core_String.String_size(code_))) {
403
+ startLine_ = line_;
404
+ startLineOffset_ = lineOffset_;
405
+ if((completionLine_ === line_)) {
406
+ while(((i_ < ff_core_String.String_size(code_)) && (((ff_core_String.String_grab(code_, i_) === 32) || (ff_core_String.String_grab(code_, i_) === 9)) || (ff_core_String.String_grab(code_, i_) === 13)))) {
407
+ if((completionColumn_ === ((1 + i_) - lineOffset_))) {
408
+ emitToken_(ff_compiler_Token.LLower(), i_, i_)
409
+ };
410
+ i_ += 1
411
+ };
412
+ if(((i_ < ff_core_String.String_size(code_)) && (completionColumn_ === ((1 + i_) - lineOffset_)))) {
413
+ const c_ = ff_core_String.String_grab(code_, i_);
414
+ if(((((!ff_core_Char.Char_isAsciiLetterOrDigit(c_)) && (c_ !== 95)) && (c_ !== 39)) && (c_ !== 34))) {
415
+ emitToken_(ff_compiler_Token.LLower(), i_, i_);
416
+ if((((i_ + 1) < ff_core_String.String_size(code_)) && (ff_core_String.String_grab(code_, i_) === 95))) {
417
+ i_ += 1
418
+ }
419
+ }
420
+ }
421
+ } else {
422
+ while(((i_ < ff_core_String.String_size(code_)) && (((ff_core_String.String_grab(code_, i_) === 32) || (ff_core_String.String_grab(code_, i_) === 9)) || (ff_core_String.String_grab(code_, i_) === 13)))) {
423
+ i_ += 1
424
+ }
425
+ };
426
+ if((i_ < ff_core_String.String_size(code_))) {
427
+ const start_ = i_;
428
+ if((ff_core_String.String_grab(code_, i_) === 10)) {
429
+ i_ += 1;
430
+ line_ += 1;
431
+ lineOffset_ = i_
432
+ } else if(((ff_core_String.String_grab(code_, i_) === 47) && (ff_core_String.String_grab(code_, (i_ + 1)) === 47))) {
433
+ i_ += 2;
434
+ while(((i_ < ff_core_String.String_size(code_)) && (ff_core_String.String_grab(code_, i_) !== 10))) {
435
+ i_ += 1
436
+ }
437
+ } else if(((ff_core_String.String_grab(code_, i_) === 47) && (ff_core_String.String_grab(code_, (i_ + 1)) === 42))) {
438
+ i_ += 2;
439
+ while(((i_ < ff_core_String.String_size(code_)) && ((ff_core_String.String_grab(code_, i_) !== 42) || (ff_core_String.String_grab(code_, (i_ + 1)) !== 47)))) {
440
+ if((i_ >= ff_core_String.String_size(code_))) {
441
+ throwError_((("Expected end of comment started on line " + startLine_) + ", got end of file."))
442
+ };
443
+ if((ff_core_String.String_grab(code_, i_) === 10)) {
444
+ line_ += 1;
445
+ lineOffset_ = (i_ + 1)
446
+ };
447
+ i_ += 1
448
+ };
449
+ i_ += 2
450
+ } else if(((ff_core_String.String_grab(code_, i_) === 34) || (ff_core_String.String_grab(code_, i_) === 39))) {
451
+ const endSign_ = ff_core_String.String_grab(code_, i_);
452
+ let multiLine_ = (((((i_ + 2) < ff_core_String.String_size(code_)) && (ff_core_String.String_grab(code_, i_) === 34)) && (ff_core_String.String_grab(code_, (i_ + 1)) === 34)) && (ff_core_String.String_grab(code_, (i_ + 2)) === 34));
453
+ i_ += (multiLine_
454
+ ? 3
455
+ : 1);
456
+ while(((i_ < ff_core_String.String_size(code_)) && (multiLine_ || (ff_core_String.String_grab(code_, i_) !== endSign_)))) {
457
+ if((ff_core_String.String_grab(code_, i_) === 10)) {
458
+ if(multiLine_) {
459
+ line_ += 1;
460
+ lineOffset_ = (i_ + 1)
461
+ } else {
462
+ throwError_("Unexpected end of line in string.")
463
+ }
464
+ };
465
+ if((i_ >= ff_core_String.String_size(code_))) {
466
+ throwError_((("Expected end of string started on line " + startLine_) + ", got end of file."))
467
+ };
468
+ if(((ff_core_String.String_grab(code_, i_) === 92) && (ff_core_String.String_grab(code_, (i_ + 1)) !== 10))) {
469
+ i_ += 1
470
+ };
471
+ if((((((multiLine_ && ((i_ + 2) < ff_core_String.String_size(code_))) && (((i_ + 3) >= ff_core_String.String_size(code_)) || (ff_core_String.String_grab(code_, (i_ + 3)) !== 34))) && (ff_core_String.String_grab(code_, i_) === 34)) && (ff_core_String.String_grab(code_, (i_ + 1)) === 34)) && (ff_core_String.String_grab(code_, (i_ + 2)) === 34))) {
472
+ multiLine_ = false;
473
+ i_ += 2
474
+ } else {
475
+ i_ += 1
476
+ }
477
+ };
478
+ i_ += 1;
479
+ emitToken_(((endSign_ === 34)
480
+ ? ff_compiler_Token.LString()
481
+ : ff_compiler_Token.LChar()), start_, i_)
482
+ } else if(ff_core_Char.Char_isAsciiLetter(ff_core_String.String_grab(code_, i_))) {
483
+ const kind_ = ((ff_core_String.String_grab(code_, i_) >= 97)
484
+ ? ff_compiler_Token.LLower()
485
+ : ff_compiler_Token.LUpper());
486
+ i_ += 1;
487
+ while(((i_ < ff_core_String.String_size(code_)) && ff_core_Char.Char_isAsciiLetterOrDigit(ff_core_String.String_grab(code_, i_)))) {
488
+ i_ += 1
489
+ };
490
+ if((((i_ < ff_core_String.String_size(code_)) && ff_compiler_Token.ff_core_Equal_Equal$ff_compiler_Token_TokenKind.equals_(kind_, ff_compiler_Token.LUpper())) && (ff_core_String.String_grab(code_, i_) === 46))) {
491
+ i_ += 1;
492
+ emitToken_(ff_compiler_Token.LNamespace(), start_, i_)
493
+ } else {
494
+ emitToken_(kind_, start_, i_)
495
+ }
496
+ } else if(ff_core_Char.Char_isAsciiDigit(ff_core_String.String_grab(code_, i_))) {
497
+ let dot_ = false;
498
+ let exponent_ = false;
499
+ while(((i_ < ff_core_String.String_size(code_)) && ff_core_Char.Char_isAsciiDigit(ff_core_String.String_grab(code_, i_)))) {
500
+ i_ += 1;
501
+ if((((ff_core_String.String_grab(code_, i_) === 101) || (ff_core_String.String_grab(code_, i_) === 69)) && (!exponent_))) {
502
+ i_ += 1;
503
+ dot_ = true;
504
+ exponent_ = true;
505
+ if(((ff_core_String.String_grab(code_, i_) === 43) || (ff_core_String.String_grab(code_, i_) === 45))) {
506
+ i_ += 1
507
+ }
508
+ };
509
+ if(((((((i_ + 1) < ff_core_String.String_size(code_)) && (ff_core_String.String_grab(code_, i_) === 46)) && ff_core_Char.Char_isAsciiDigit(ff_core_String.String_grab(code_, (i_ + 1)))) && (!dot_)) && (!exponent_))) {
510
+ i_ += 1;
511
+ dot_ = true
512
+ }
513
+ };
514
+ emitToken_(((dot_ || exponent_)
515
+ ? ff_compiler_Token.LFloat()
516
+ : ff_compiler_Token.LInt()), start_, i_)
517
+ } else if((ff_core_String.String_grab(code_, i_) === 95)) {
518
+ i_ += 1;
519
+ emitToken_(ff_compiler_Token.LWildcard(), start_, i_)
520
+ } else if((ff_core_String.String_grab(code_, i_) === 44)) {
521
+ i_ += 1;
522
+ emitToken_(ff_compiler_Token.LComma(), start_, i_)
523
+ } else if(ff_core_Set.Set_contains(operatorCharacters_, ff_core_String.String_grab(code_, i_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Char_Char)) {
524
+ i_ += 1;
525
+ if(((((ff_core_String.String_grab(code_, (i_ - 1)) === 46) && ((i_ + 1) < ff_core_String.String_size(code_))) && (ff_core_String.String_grab(code_, i_) === 46)) && (ff_core_String.String_grab(code_, (i_ + 1)) !== 46))) {
526
+ emitToken_(ff_compiler_Token.LDot(), start_, i_);
527
+ const newStart_ = i_;
528
+ if((!ff_core_Option.Option_isEmpty(completionAt_))) {
529
+ emitToken_(ff_compiler_Token.LLower(), newStart_, newStart_)
530
+ };
531
+ i_ += 1;
532
+ emitToken_(ff_compiler_Token.LDot(), newStart_, i_)
533
+ } else {
534
+ while(((i_ < ff_core_String.String_size(code_)) && ff_core_Set.Set_contains(operatorCharacters_, ff_core_String.String_grab(code_, i_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Char_Char))) {
535
+ i_ += 1
536
+ };
537
+ const o_ = ((((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 46))
538
+ ? ff_compiler_Token.LDot()
539
+ : (((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 59))
540
+ ? ff_compiler_Token.LSemicolon()
541
+ : (((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 124))
542
+ ? ff_compiler_Token.LPipe()
543
+ : (((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 58))
544
+ ? ff_compiler_Token.LColon()
545
+ : (((((i_ - start_) === 3) && (ff_core_String.String_grab(code_, (i_ - 3)) === 46)) && (ff_core_String.String_grab(code_, (i_ - 2)) === 46)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 46))
546
+ ? ff_compiler_Token.LDotDotDot()
547
+ : ((((i_ - start_) === 2) && (ff_core_String.String_grab(code_, (i_ - 2)) === 61)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 62))
548
+ ? ff_compiler_Token.LArrowThick()
549
+ : (((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 61))
550
+ ? ff_compiler_Token.LAssign()
551
+ : ((((i_ - start_) === 2) && (ff_core_String.String_grab(code_, (i_ - 2)) === 43)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 61))
552
+ ? ff_compiler_Token.LAssignPlus()
553
+ : ((((i_ - start_) === 2) && (ff_core_String.String_grab(code_, (i_ - 2)) === 45)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 61))
554
+ ? ff_compiler_Token.LAssignMinus()
555
+ : (((((i_ - start_) === 3) && (ff_core_String.String_grab(code_, (i_ - 3)) === 58)) && (ff_core_String.String_grab(code_, (i_ - 2)) === 58)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 61))
556
+ ? ff_compiler_Token.LAssignLink()
557
+ : ff_compiler_Token.LOperator());
558
+ emitToken_(o_, start_, i_)
559
+ }
560
+ } else if((((ff_core_String.String_grab(code_, i_) === 40) || (ff_core_String.String_grab(code_, i_) === 91)) || (ff_core_String.String_grab(code_, i_) === 123))) {
561
+ i_ += 1;
562
+ emitToken_(ff_compiler_Token.LBracketLeft(), start_, i_)
563
+ } else if((((ff_core_String.String_grab(code_, i_) === 41) || (ff_core_String.String_grab(code_, i_) === 93)) || (ff_core_String.String_grab(code_, i_) === 125))) {
564
+ i_ += 1;
565
+ emitToken_(ff_compiler_Token.LBracketRight(), start_, i_)
566
+ } else if((i_ < ff_core_String.String_size(code_))) {
567
+ if(attemptFixes_) {
568
+ i_ += 1
569
+ } else {
570
+ throwError_(("Unexpected character: " + ff_core_Show.ff_core_Show_Show$ff_core_Char_Char.show_(ff_core_String.String_grab(code_, i_))))
571
+ }
572
+ } else {}
573
+ }
574
+ }
575
+ } catch(_error) {
576
+ if(!_error.ffException) throw _error
577
+ const _exception = ff_core_Any.fromAny_(_error.ffException, ff_core_Core.ff_core_Any_HasAnyTag$ff_core_Core_GrabException)
578
+ if(!_exception.Some) throw _error
579
+ const e_ = _exception.value_;
580
+ const error_ = _error;
581
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(ff_compiler_Syntax.Location(file_, line_, (i_ - lineOffset_)), "Unexpected end of file"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
582
+ };
583
+ ff_core_List.List_each(ff_core_List.range_(5), ((_) => {
584
+ emitToken_(ff_compiler_Token.LEnd(), i_, i_)
585
+ }));
586
+ return ff_core_Stack.Stack_drain(tokens_)
587
+ }
588
+
589
+
590
+
591
+
592
+
593
+