firefly-compiler 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.firefly-workspace +1 -0
- package/.vscode/settings.json +5 -0
- package/LICENSE.txt +21 -0
- package/README.md +96 -0
- package/bin/firefly.mjs +2 -0
- package/compiler/.firefly/package.ff +1 -0
- package/compiler/Builder.ff +218 -0
- package/compiler/Compiler.ff +241 -0
- package/compiler/Dependencies.ff +179 -0
- package/compiler/Deriver.ff +647 -0
- package/compiler/Dictionaries.ff +205 -0
- package/compiler/Environment.ff +166 -0
- package/compiler/Inference.ff +1117 -0
- package/compiler/JsEmitter.ff +861 -0
- package/compiler/JsImporter.ff +56 -0
- package/compiler/LspHook.ff +188 -0
- package/compiler/Main.ff +237 -0
- package/compiler/Parser.ff +1383 -0
- package/compiler/Patterns.ff +111 -0
- package/compiler/Resolver.ff +620 -0
- package/compiler/Substitution.ff +178 -0
- package/compiler/Syntax.ff +299 -0
- package/compiler/Token.ff +180 -0
- package/compiler/Tokenizer.ff +278 -0
- package/compiler/Unification.ff +220 -0
- package/compiler/Wildcards.ff +50 -0
- package/compiler/Workspace.ff +88 -0
- package/core/.firefly/package.ff +2 -0
- package/core/Any.ff +30 -0
- package/core/Array.ff +249 -0
- package/core/AssetSystem.ff +61 -0
- package/core/Atomic.ff +64 -0
- package/core/Bool.ff +13 -0
- package/core/BrowserSystem.ff +14 -0
- package/core/Buffer.ff +211 -0
- package/core/BuildSystem.ff +144 -0
- package/core/Channel.ff +131 -0
- package/core/Char.ff +18 -0
- package/core/Core.ff +58 -0
- package/core/Duration.ff +15 -0
- package/core/Equal.ff +52 -0
- package/core/Error.ff +20 -0
- package/core/FileHandle.ff +41 -0
- package/core/Float.ff +41 -0
- package/core/HttpClient.ff +84 -0
- package/core/Instant.ff +9 -0
- package/core/Int.ff +61 -0
- package/core/IntMap.ff +85 -0
- package/core/JsSystem.ff +66 -0
- package/core/JsValue.ff +240 -0
- package/core/List.ff +440 -0
- package/core/Lock.ff +144 -0
- package/core/Log.ff +24 -0
- package/core/Map.ff +126 -0
- package/core/NodeSystem.ff +88 -0
- package/core/Nothing.ff +1 -0
- package/core/Option.ff +133 -0
- package/core/Ordering.ff +157 -0
- package/core/Pair.ff +55 -0
- package/core/Path.ff +393 -0
- package/core/RbMap.ff +216 -0
- package/core/Serializable.ff +173 -0
- package/core/Set.ff +38 -0
- package/core/Show.ff +43 -0
- package/core/Stack.ff +263 -0
- package/core/Stream.ff +406 -0
- package/core/String.ff +175 -0
- package/core/StringMap.ff +85 -0
- package/core/Task.ff +138 -0
- package/core/Try.ff +81 -0
- package/core/Unit.ff +3 -0
- package/experimental/random/AltGeneric.ff +44 -0
- package/experimental/random/Async.ff +68 -0
- package/experimental/random/Buffer2.ff +77 -0
- package/experimental/random/Cat.ff +12 -0
- package/experimental/random/Dictionary.ff +52 -0
- package/experimental/random/Example.ff +46 -0
- package/experimental/random/Generic.ff +102 -0
- package/experimental/random/HappyEyeballs.ff +40 -0
- package/experimental/random/HashMap.ff +72 -0
- package/experimental/random/IfElseUnit.ff +9 -0
- package/experimental/random/InputOutput.ff +23 -0
- package/experimental/random/ListVsArray.ff +45 -0
- package/experimental/random/Main.ff +44 -0
- package/experimental/random/MapTest.ff +67 -0
- package/experimental/random/OldTaskSystem.ff +210 -0
- package/experimental/random/PatternTest.ff +39 -0
- package/experimental/random/Patterns.ff +226 -0
- package/experimental/random/ReadBytesTest.ff +10 -0
- package/experimental/random/RunLength.ff +65 -0
- package/experimental/random/Scrape.ff +51 -0
- package/experimental/random/Serialization.ff +217 -0
- package/experimental/random/SerializationTest.ff +46 -0
- package/experimental/random/Serializer.ff +36 -0
- package/experimental/random/StdInOutErr.ff +4 -0
- package/experimental/random/Symbols.ff +74 -0
- package/experimental/random/Tag.ff +49 -0
- package/experimental/random/Tensor.ff +52 -0
- package/experimental/random/Try.ff +56 -0
- package/experimental/random/Tsv.ff +9 -0
- package/experimental/random/TypesAreModules.ff +87 -0
- package/experimental/random/blueprints/Blueprint.ff +52 -0
- package/experimental/random/blueprints/Main.ff +11 -0
- package/experimental/random/blueprints/Pretty.ff +58 -0
- package/experimental/random/blueprints/User.ff +64 -0
- package/experimental/random/blueprintsystem/BlueprintSystem.ff +48 -0
- package/experimental/random/blueprintsystem/Deserialize.ff +53 -0
- package/experimental/random/blueprintsystem/ReadJs.ff +13 -0
- package/experimental/random/blueprintsystem/User.ff +2 -0
- package/experimental/random/kahrs/Kahrs.ff +112 -0
- package/experimental/random/kahrs/TestKahrs.ff +22 -0
- package/experimental/random/kahrs/TestMap.ff +18 -0
- package/experimental/random/streaming/Gzip.ff +3 -0
- package/experimental/random/streaming/Main.ff +34 -0
- package/experimental/random/streaming/S3Bucket.ff +11 -0
- package/experimental/random/streaming/Tar.ff +5 -0
- package/experimental/rhymeapp/Main.ff +81 -0
- package/experimental/rhymeapp/index.html +14 -0
- package/firefly.sh +5 -0
- package/fireflysite/Main.ff +13 -0
- package/httpserver/.firefly/package.ff +1 -0
- package/httpserver/HttpServer.ff +184 -0
- package/lsp/.firefly/package.ff +1 -0
- package/lsp/CompletionHandler.ff +814 -0
- package/lsp/Handler.ff +551 -0
- package/lsp/HoverHandler.ff +82 -0
- package/lsp/LanguageServer.ff +229 -0
- package/lsp/SignatureHelpHandler.ff +55 -0
- package/lsp/SymbolHandler.ff +167 -0
- package/output/js/ff/compiler/Builder.mjs +483 -0
- package/output/js/ff/compiler/Compiler.mjs +410 -0
- package/output/js/ff/compiler/Dependencies.mjs +388 -0
- package/output/js/ff/compiler/Deriver.mjs +1166 -0
- package/output/js/ff/compiler/Dictionaries.mjs +1305 -0
- package/output/js/ff/compiler/Environment.mjs +1005 -0
- package/output/js/ff/compiler/Inference.mjs +4264 -0
- package/output/js/ff/compiler/JsEmitter.mjs +5353 -0
- package/output/js/ff/compiler/JsImporter.mjs +262 -0
- package/output/js/ff/compiler/LspHook.mjs +789 -0
- package/output/js/ff/compiler/Main.mjs +1695 -0
- package/output/js/ff/compiler/Parser.mjs +4004 -0
- package/output/js/ff/compiler/Patterns.mjs +923 -0
- package/output/js/ff/compiler/Resolver.mjs +2303 -0
- package/output/js/ff/compiler/Substitution.mjs +1146 -0
- package/output/js/ff/compiler/Syntax.mjs +12430 -0
- package/output/js/ff/compiler/Token.mjs +3092 -0
- package/output/js/ff/compiler/Tokenizer.mjs +589 -0
- package/output/js/ff/compiler/Unification.mjs +1748 -0
- package/output/js/ff/compiler/Wildcards.mjs +604 -0
- package/output/js/ff/compiler/Workspace.mjs +683 -0
- package/output/js/ff/core/Any.mjs +139 -0
- package/output/js/ff/core/Array.mjs +594 -0
- package/output/js/ff/core/AssetSystem.mjs +270 -0
- package/output/js/ff/core/Atomic.mjs +186 -0
- package/output/js/ff/core/Bool.mjs +141 -0
- package/output/js/ff/core/BrowserSystem.mjs +122 -0
- package/output/js/ff/core/Buffer.mjs +467 -0
- package/output/js/ff/core/BuildSystem.mjs +320 -0
- package/output/js/ff/core/Channel.mjs +268 -0
- package/output/js/ff/core/Char.mjs +145 -0
- package/output/js/ff/core/Core.mjs +300 -0
- package/output/js/ff/core/Duration.mjs +112 -0
- package/output/js/ff/core/Equal.mjs +175 -0
- package/output/js/ff/core/Error.mjs +138 -0
- package/output/js/ff/core/FileHandle.mjs +164 -0
- package/output/js/ff/core/Float.mjs +214 -0
- package/output/js/ff/core/HttpClient.mjs +210 -0
- package/output/js/ff/core/Instant.mjs +105 -0
- package/output/js/ff/core/Int.mjs +254 -0
- package/output/js/ff/core/IntMap.mjs +282 -0
- package/output/js/ff/core/JsSystem.mjs +234 -0
- package/output/js/ff/core/JsValue.mjs +678 -0
- package/output/js/ff/core/List.mjs +2335 -0
- package/output/js/ff/core/Lock.mjs +322 -0
- package/output/js/ff/core/Log.mjs +159 -0
- package/output/js/ff/core/Map.mjs +358 -0
- package/output/js/ff/core/NodeSystem.mjs +288 -0
- package/output/js/ff/core/Nothing.mjs +100 -0
- package/output/js/ff/core/Option.mjs +1002 -0
- package/output/js/ff/core/Ordering.mjs +734 -0
- package/output/js/ff/core/Pair.mjs +318 -0
- package/output/js/ff/core/Path.mjs +768 -0
- package/output/js/ff/core/RbMap.mjs +1936 -0
- package/output/js/ff/core/Serializable.mjs +434 -0
- package/output/js/ff/core/Set.mjs +250 -0
- package/output/js/ff/core/Show.mjs +201 -0
- package/output/js/ff/core/Stack.mjs +595 -0
- package/output/js/ff/core/Stream.mjs +1300 -0
- package/output/js/ff/core/String.mjs +433 -0
- package/output/js/ff/core/StringMap.mjs +282 -0
- package/output/js/ff/core/Task.mjs +345 -0
- package/output/js/ff/core/Try.mjs +503 -0
- package/output/js/ff/core/Unit.mjs +103 -0
- package/package.json +29 -0
- package/postgresql/.firefly/include/package-lock.json +250 -0
- package/postgresql/.firefly/include/package.json +5 -0
- package/postgresql/.firefly/include/prepare.sh +2 -0
- package/postgresql/.firefly/package.ff +3 -0
- package/postgresql/Pg.ff +530 -0
- package/unsafejs/.firefly/package.ff +1 -0
- package/unsafejs/UnsafeJs.ff +19 -0
- package/vscode/.vscode/launch.json +18 -0
- package/vscode/.vscode/tasks.json +33 -0
- package/vscode/LICENSE.txt +21 -0
- package/vscode/Prepublish.ff +15 -0
- package/vscode/README.md +17 -0
- package/vscode/client/package-lock.json +544 -0
- package/vscode/client/package.json +22 -0
- package/vscode/client/src/extension.ts +64 -0
- package/vscode/client/tsconfig.json +12 -0
- package/vscode/icons/firefly-icon.png +0 -0
- package/vscode/icons/firefly-icon.svg +10 -0
- package/vscode/icons/firefly-logo-notext.png +0 -0
- package/vscode/icons/firefly-logo.png +0 -0
- package/vscode/language-configuration.json +39 -0
- package/vscode/package-lock.json +3623 -0
- package/vscode/package.json +144 -0
- package/vscode/snippets-none.json +1 -0
- package/vscode/snippets.json +241 -0
- package/vscode/syntaxes/firefly.tmLanguage.json +294 -0
- package/vscode/tsconfig.json +20 -0
|
@@ -0,0 +1,589 @@
|
|
|
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_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
|
|
22
|
+
|
|
23
|
+
import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
|
|
24
|
+
|
|
25
|
+
import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
|
|
26
|
+
|
|
27
|
+
import * as ff_core_Channel from "../../ff/core/Channel.mjs"
|
|
28
|
+
|
|
29
|
+
import * as ff_core_Char from "../../ff/core/Char.mjs"
|
|
30
|
+
|
|
31
|
+
import * as ff_core_Core from "../../ff/core/Core.mjs"
|
|
32
|
+
|
|
33
|
+
import * as ff_core_Duration from "../../ff/core/Duration.mjs"
|
|
34
|
+
|
|
35
|
+
import * as ff_core_Equal from "../../ff/core/Equal.mjs"
|
|
36
|
+
|
|
37
|
+
import * as ff_core_Error from "../../ff/core/Error.mjs"
|
|
38
|
+
|
|
39
|
+
import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
|
|
40
|
+
|
|
41
|
+
import * as ff_core_Float from "../../ff/core/Float.mjs"
|
|
42
|
+
|
|
43
|
+
import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
|
|
44
|
+
|
|
45
|
+
import * as ff_core_Instant from "../../ff/core/Instant.mjs"
|
|
46
|
+
|
|
47
|
+
import * as ff_core_Int from "../../ff/core/Int.mjs"
|
|
48
|
+
|
|
49
|
+
import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
|
|
50
|
+
|
|
51
|
+
import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
52
|
+
|
|
53
|
+
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
54
|
+
|
|
55
|
+
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
56
|
+
|
|
57
|
+
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
58
|
+
|
|
59
|
+
import * as ff_core_Log from "../../ff/core/Log.mjs"
|
|
60
|
+
|
|
61
|
+
import * as ff_core_Map from "../../ff/core/Map.mjs"
|
|
62
|
+
|
|
63
|
+
import * as ff_core_NodeSystem from "../../ff/core/NodeSystem.mjs"
|
|
64
|
+
|
|
65
|
+
import * as ff_core_Nothing from "../../ff/core/Nothing.mjs"
|
|
66
|
+
|
|
67
|
+
import * as ff_core_Option from "../../ff/core/Option.mjs"
|
|
68
|
+
|
|
69
|
+
import * as ff_core_Ordering from "../../ff/core/Ordering.mjs"
|
|
70
|
+
|
|
71
|
+
import * as ff_core_Pair from "../../ff/core/Pair.mjs"
|
|
72
|
+
|
|
73
|
+
import * as ff_core_Path from "../../ff/core/Path.mjs"
|
|
74
|
+
|
|
75
|
+
import * as ff_core_Serializable from "../../ff/core/Serializable.mjs"
|
|
76
|
+
|
|
77
|
+
import * as ff_core_Set from "../../ff/core/Set.mjs"
|
|
78
|
+
|
|
79
|
+
import * as ff_core_Show from "../../ff/core/Show.mjs"
|
|
80
|
+
|
|
81
|
+
import * as ff_core_Stack from "../../ff/core/Stack.mjs"
|
|
82
|
+
|
|
83
|
+
import * as ff_core_Stream from "../../ff/core/Stream.mjs"
|
|
84
|
+
|
|
85
|
+
import * as ff_core_String from "../../ff/core/String.mjs"
|
|
86
|
+
|
|
87
|
+
import * as ff_core_StringMap from "../../ff/core/StringMap.mjs"
|
|
88
|
+
|
|
89
|
+
import * as ff_core_Task from "../../ff/core/Task.mjs"
|
|
90
|
+
|
|
91
|
+
import * as ff_core_Try from "../../ff/core/Try.mjs"
|
|
92
|
+
|
|
93
|
+
import * as ff_core_Unit from "../../ff/core/Unit.mjs"
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
export function tokenize_(file_, code_, completionAt_, attemptFixes_) {
|
|
100
|
+
const completionLine_ = ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Option.Option_filter(completionAt_, ((_w1) => {
|
|
101
|
+
return (_w1.file_ === file_)
|
|
102
|
+
})), ((_w1) => {
|
|
103
|
+
return _w1.line_
|
|
104
|
+
})), (() => {
|
|
105
|
+
return (-1)
|
|
106
|
+
}));
|
|
107
|
+
const completionColumn_ = ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Option.Option_filter(completionAt_, ((_w1) => {
|
|
108
|
+
return (_w1.file_ === file_)
|
|
109
|
+
})), ((_w1) => {
|
|
110
|
+
return _w1.column_
|
|
111
|
+
})), (() => {
|
|
112
|
+
return (-1)
|
|
113
|
+
}));
|
|
114
|
+
const tokens_ = ff_core_Stack.make_();
|
|
115
|
+
let line_ = 1;
|
|
116
|
+
let lineOffset_ = 0;
|
|
117
|
+
let startLine_ = line_;
|
|
118
|
+
let startLineOffset_ = lineOffset_;
|
|
119
|
+
const operatorCharactersString_ = "!@#$%&/=?+|^~*<>.:-;";
|
|
120
|
+
let operatorCharacters_ = ff_core_Set.empty_();
|
|
121
|
+
ff_core_List.List_map(ff_core_List.range_(ff_core_String.String_size(operatorCharactersString_)), ((j_) => {
|
|
122
|
+
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)
|
|
123
|
+
}));
|
|
124
|
+
function emitToken_(kind_, startOffset_, stopOffset_) {
|
|
125
|
+
if((!ff_core_Stack.Stack_isEmpty(tokens_))) {
|
|
126
|
+
const last_ = ff_core_Stack.Stack_grabLast(tokens_);
|
|
127
|
+
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_))) {
|
|
128
|
+
if((((completionLine_ === last_.startLine_) && (completionColumn_ >= ((1 + last_.startOffset_) - last_.startLineOffset_))) && (completionColumn_ <= ((1 + last_.stopOffset_) - last_.stopLineOffset_)))) {
|
|
129
|
+
ff_core_Stack.Stack_push(tokens_, ff_compiler_Token.Token(file_, code_, ff_compiler_Token.LSeparator(), startLine_, startLineOffset_, startLineOffset_, startLine_, startLineOffset_, startLineOffset_))
|
|
130
|
+
} else {
|
|
131
|
+
ff_core_Stack.Stack_modify(tokens_, (ff_core_Stack.Stack_size(tokens_) - 1), ((_w1) => {
|
|
132
|
+
{
|
|
133
|
+
const _1 = _w1;
|
|
134
|
+
{
|
|
135
|
+
const _c = _1;
|
|
136
|
+
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_)
|
|
137
|
+
return
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}))
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
if((((last_.stopLine_ !== startLine_) && ff_compiler_Token.TokenKind_beforeSeparator(last_.kind_)) && ff_compiler_Token.TokenKind_afterSeparator(kind_))) {
|
|
144
|
+
ff_core_Stack.Stack_push(tokens_, ff_compiler_Token.Token(file_, code_, ff_compiler_Token.LSeparator(), startLine_, startLineOffset_, startLineOffset_, startLine_, startLineOffset_, startLineOffset_))
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
ff_core_Stack.Stack_push(tokens_, ff_compiler_Token.Token(file_, code_, kind_, startLine_, startLineOffset_, startOffset_, line_, lineOffset_, stopOffset_))
|
|
148
|
+
}
|
|
149
|
+
let i_ = 0;
|
|
150
|
+
function throwError_(message_) {
|
|
151
|
+
const column_ = ((i_ - startLineOffset_) + 1);
|
|
152
|
+
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)})
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
while((i_ < ff_core_String.String_size(code_))) {
|
|
156
|
+
startLine_ = line_;
|
|
157
|
+
startLineOffset_ = lineOffset_;
|
|
158
|
+
if((completionLine_ === line_)) {
|
|
159
|
+
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)))) {
|
|
160
|
+
if((completionColumn_ === ((1 + i_) - lineOffset_))) {
|
|
161
|
+
emitToken_(ff_compiler_Token.LLower(), i_, i_)
|
|
162
|
+
};
|
|
163
|
+
i_ += 1
|
|
164
|
+
};
|
|
165
|
+
if(((i_ < ff_core_String.String_size(code_)) && (completionColumn_ === ((1 + i_) - lineOffset_)))) {
|
|
166
|
+
const c_ = ff_core_String.String_grab(code_, i_);
|
|
167
|
+
if(((((!ff_core_Char.Char_isAsciiLetterOrDigit(c_)) && (c_ !== 95)) && (c_ !== 39)) && (c_ !== 34))) {
|
|
168
|
+
emitToken_(ff_compiler_Token.LLower(), i_, i_);
|
|
169
|
+
if((((i_ + 1) < ff_core_String.String_size(code_)) && (ff_core_String.String_grab(code_, i_) === 95))) {
|
|
170
|
+
i_ += 1
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
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)))) {
|
|
176
|
+
i_ += 1
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
if((i_ < ff_core_String.String_size(code_))) {
|
|
180
|
+
const start_ = i_;
|
|
181
|
+
if((ff_core_String.String_grab(code_, i_) === 10)) {
|
|
182
|
+
i_ += 1;
|
|
183
|
+
line_ += 1;
|
|
184
|
+
lineOffset_ = i_
|
|
185
|
+
} else if(((ff_core_String.String_grab(code_, i_) === 47) && (ff_core_String.String_grab(code_, (i_ + 1)) === 47))) {
|
|
186
|
+
i_ += 2;
|
|
187
|
+
while(((i_ < ff_core_String.String_size(code_)) && (ff_core_String.String_grab(code_, i_) !== 10))) {
|
|
188
|
+
i_ += 1
|
|
189
|
+
}
|
|
190
|
+
} else if(((ff_core_String.String_grab(code_, i_) === 47) && (ff_core_String.String_grab(code_, (i_ + 1)) === 42))) {
|
|
191
|
+
i_ += 2;
|
|
192
|
+
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)))) {
|
|
193
|
+
if((i_ >= ff_core_String.String_size(code_))) {
|
|
194
|
+
throwError_((("Expected end of comment started on line " + startLine_) + ", got end of file."))
|
|
195
|
+
};
|
|
196
|
+
if((ff_core_String.String_grab(code_, i_) === 10)) {
|
|
197
|
+
line_ += 1;
|
|
198
|
+
lineOffset_ = (i_ + 1)
|
|
199
|
+
};
|
|
200
|
+
i_ += 1
|
|
201
|
+
};
|
|
202
|
+
i_ += 2
|
|
203
|
+
} else if(((ff_core_String.String_grab(code_, i_) === 34) || (ff_core_String.String_grab(code_, i_) === 39))) {
|
|
204
|
+
const endSign_ = ff_core_String.String_grab(code_, i_);
|
|
205
|
+
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));
|
|
206
|
+
i_ += (multiLine_
|
|
207
|
+
? 3
|
|
208
|
+
: 1);
|
|
209
|
+
while(((i_ < ff_core_String.String_size(code_)) && (multiLine_ || (ff_core_String.String_grab(code_, i_) !== endSign_)))) {
|
|
210
|
+
if((ff_core_String.String_grab(code_, i_) === 10)) {
|
|
211
|
+
if(multiLine_) {
|
|
212
|
+
line_ += 1;
|
|
213
|
+
lineOffset_ = (i_ + 1)
|
|
214
|
+
} else {
|
|
215
|
+
throwError_("Unexpected end of line in string.")
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
if((i_ >= ff_core_String.String_size(code_))) {
|
|
219
|
+
throwError_((("Expected end of string started on line " + startLine_) + ", got end of file."))
|
|
220
|
+
};
|
|
221
|
+
if(((ff_core_String.String_grab(code_, i_) === 92) && (ff_core_String.String_grab(code_, (i_ + 1)) !== 10))) {
|
|
222
|
+
i_ += 1
|
|
223
|
+
};
|
|
224
|
+
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))) {
|
|
225
|
+
multiLine_ = false;
|
|
226
|
+
i_ += 2
|
|
227
|
+
} else {
|
|
228
|
+
i_ += 1
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
i_ += 1;
|
|
232
|
+
emitToken_(((endSign_ === 34)
|
|
233
|
+
? ff_compiler_Token.LString()
|
|
234
|
+
: ff_compiler_Token.LChar()), start_, i_)
|
|
235
|
+
} else if(ff_core_Char.Char_isAsciiLetter(ff_core_String.String_grab(code_, i_))) {
|
|
236
|
+
const kind_ = ((ff_core_String.String_grab(code_, i_) >= 97)
|
|
237
|
+
? ff_compiler_Token.LLower()
|
|
238
|
+
: ff_compiler_Token.LUpper());
|
|
239
|
+
i_ += 1;
|
|
240
|
+
while(((i_ < ff_core_String.String_size(code_)) && ff_core_Char.Char_isAsciiLetterOrDigit(ff_core_String.String_grab(code_, i_)))) {
|
|
241
|
+
i_ += 1
|
|
242
|
+
};
|
|
243
|
+
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))) {
|
|
244
|
+
i_ += 1;
|
|
245
|
+
emitToken_(ff_compiler_Token.LNamespace(), start_, i_)
|
|
246
|
+
} else {
|
|
247
|
+
emitToken_(kind_, start_, i_)
|
|
248
|
+
}
|
|
249
|
+
} else if(ff_core_Char.Char_isAsciiDigit(ff_core_String.String_grab(code_, i_))) {
|
|
250
|
+
let dot_ = false;
|
|
251
|
+
let exponent_ = false;
|
|
252
|
+
while(((i_ < ff_core_String.String_size(code_)) && ff_core_Char.Char_isAsciiDigit(ff_core_String.String_grab(code_, i_)))) {
|
|
253
|
+
i_ += 1;
|
|
254
|
+
if((((ff_core_String.String_grab(code_, i_) === 101) || (ff_core_String.String_grab(code_, i_) === 69)) && (!exponent_))) {
|
|
255
|
+
i_ += 1;
|
|
256
|
+
dot_ = true;
|
|
257
|
+
exponent_ = true;
|
|
258
|
+
if(((ff_core_String.String_grab(code_, i_) === 43) || (ff_core_String.String_grab(code_, i_) === 45))) {
|
|
259
|
+
i_ += 1
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
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_))) {
|
|
263
|
+
i_ += 1;
|
|
264
|
+
dot_ = true
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
emitToken_(((dot_ || exponent_)
|
|
268
|
+
? ff_compiler_Token.LFloat()
|
|
269
|
+
: ff_compiler_Token.LInt()), start_, i_)
|
|
270
|
+
} else if((ff_core_String.String_grab(code_, i_) === 95)) {
|
|
271
|
+
i_ += 1;
|
|
272
|
+
emitToken_(ff_compiler_Token.LWildcard(), start_, i_)
|
|
273
|
+
} else if((ff_core_String.String_grab(code_, i_) === 44)) {
|
|
274
|
+
i_ += 1;
|
|
275
|
+
emitToken_(ff_compiler_Token.LComma(), start_, i_)
|
|
276
|
+
} 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)) {
|
|
277
|
+
i_ += 1;
|
|
278
|
+
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))) {
|
|
279
|
+
emitToken_(ff_compiler_Token.LDot(), start_, i_);
|
|
280
|
+
const newStart_ = i_;
|
|
281
|
+
if((!ff_core_Option.Option_isEmpty(completionAt_))) {
|
|
282
|
+
emitToken_(ff_compiler_Token.LLower(), newStart_, newStart_)
|
|
283
|
+
};
|
|
284
|
+
i_ += 1;
|
|
285
|
+
emitToken_(ff_compiler_Token.LDot(), newStart_, i_)
|
|
286
|
+
} else {
|
|
287
|
+
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))) {
|
|
288
|
+
i_ += 1
|
|
289
|
+
};
|
|
290
|
+
const o_ = ((((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 46))
|
|
291
|
+
? ff_compiler_Token.LDot()
|
|
292
|
+
: (((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 59))
|
|
293
|
+
? ff_compiler_Token.LSemicolon()
|
|
294
|
+
: (((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 124))
|
|
295
|
+
? ff_compiler_Token.LPipe()
|
|
296
|
+
: (((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 58))
|
|
297
|
+
? ff_compiler_Token.LColon()
|
|
298
|
+
: (((((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))
|
|
299
|
+
? ff_compiler_Token.LDotDotDot()
|
|
300
|
+
: ((((i_ - start_) === 2) && (ff_core_String.String_grab(code_, (i_ - 2)) === 61)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 62))
|
|
301
|
+
? ff_compiler_Token.LArrowThick()
|
|
302
|
+
: (((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 61))
|
|
303
|
+
? ff_compiler_Token.LAssign()
|
|
304
|
+
: ((((i_ - start_) === 2) && (ff_core_String.String_grab(code_, (i_ - 2)) === 43)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 61))
|
|
305
|
+
? ff_compiler_Token.LAssignPlus()
|
|
306
|
+
: ((((i_ - start_) === 2) && (ff_core_String.String_grab(code_, (i_ - 2)) === 45)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 61))
|
|
307
|
+
? ff_compiler_Token.LAssignMinus()
|
|
308
|
+
: (((((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))
|
|
309
|
+
? ff_compiler_Token.LAssignLink()
|
|
310
|
+
: ff_compiler_Token.LOperator());
|
|
311
|
+
emitToken_(o_, start_, i_)
|
|
312
|
+
}
|
|
313
|
+
} 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))) {
|
|
314
|
+
i_ += 1;
|
|
315
|
+
emitToken_(ff_compiler_Token.LBracketLeft(), start_, i_)
|
|
316
|
+
} 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))) {
|
|
317
|
+
i_ += 1;
|
|
318
|
+
emitToken_(ff_compiler_Token.LBracketRight(), start_, i_)
|
|
319
|
+
} else if((i_ < ff_core_String.String_size(code_))) {
|
|
320
|
+
if(attemptFixes_) {
|
|
321
|
+
i_ += 1
|
|
322
|
+
} else {
|
|
323
|
+
throwError_(("Unexpected character: " + ff_core_Show.ff_core_Show_Show$ff_core_Char_Char.show_(ff_core_String.String_grab(code_, i_))))
|
|
324
|
+
}
|
|
325
|
+
} else {}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
} catch(_error) {
|
|
329
|
+
if(!_error.ffException) throw _error
|
|
330
|
+
const _exception = ff_core_Any.fromAny_(_error.ffException, ff_core_Core.ff_core_Any_HasAnyTag$ff_core_Core_GrabException)
|
|
331
|
+
if(!_exception.Some) throw _error
|
|
332
|
+
const e_ = _exception.value_;
|
|
333
|
+
const error_ = _error;
|
|
334
|
+
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)})
|
|
335
|
+
};
|
|
336
|
+
ff_core_List.List_each(ff_core_List.range_(5), ((_) => {
|
|
337
|
+
emitToken_(ff_compiler_Token.LEnd(), i_, i_)
|
|
338
|
+
}));
|
|
339
|
+
return ff_core_Stack.Stack_drain(tokens_)
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export async function tokenize_$(file_, code_, completionAt_, attemptFixes_, $task) {
|
|
343
|
+
const completionLine_ = ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Option.Option_filter(completionAt_, ((_w1) => {
|
|
344
|
+
return (_w1.file_ === file_)
|
|
345
|
+
})), ((_w1) => {
|
|
346
|
+
return _w1.line_
|
|
347
|
+
})), (() => {
|
|
348
|
+
return (-1)
|
|
349
|
+
}));
|
|
350
|
+
const completionColumn_ = ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Option.Option_filter(completionAt_, ((_w1) => {
|
|
351
|
+
return (_w1.file_ === file_)
|
|
352
|
+
})), ((_w1) => {
|
|
353
|
+
return _w1.column_
|
|
354
|
+
})), (() => {
|
|
355
|
+
return (-1)
|
|
356
|
+
}));
|
|
357
|
+
const tokens_ = ff_core_Stack.make_();
|
|
358
|
+
let line_ = 1;
|
|
359
|
+
let lineOffset_ = 0;
|
|
360
|
+
let startLine_ = line_;
|
|
361
|
+
let startLineOffset_ = lineOffset_;
|
|
362
|
+
const operatorCharactersString_ = "!@#$%&/=?+|^~*<>.:-;";
|
|
363
|
+
let operatorCharacters_ = ff_core_Set.empty_();
|
|
364
|
+
ff_core_List.List_map(ff_core_List.range_(ff_core_String.String_size(operatorCharactersString_)), ((j_) => {
|
|
365
|
+
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)
|
|
366
|
+
}));
|
|
367
|
+
function emitToken_(kind_, startOffset_, stopOffset_) {
|
|
368
|
+
if((!ff_core_Stack.Stack_isEmpty(tokens_))) {
|
|
369
|
+
const last_ = ff_core_Stack.Stack_grabLast(tokens_);
|
|
370
|
+
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_))) {
|
|
371
|
+
if((((completionLine_ === last_.startLine_) && (completionColumn_ >= ((1 + last_.startOffset_) - last_.startLineOffset_))) && (completionColumn_ <= ((1 + last_.stopOffset_) - last_.stopLineOffset_)))) {
|
|
372
|
+
ff_core_Stack.Stack_push(tokens_, ff_compiler_Token.Token(file_, code_, ff_compiler_Token.LSeparator(), startLine_, startLineOffset_, startLineOffset_, startLine_, startLineOffset_, startLineOffset_))
|
|
373
|
+
} else {
|
|
374
|
+
ff_core_Stack.Stack_modify(tokens_, (ff_core_Stack.Stack_size(tokens_) - 1), ((_w1) => {
|
|
375
|
+
{
|
|
376
|
+
const _1 = _w1;
|
|
377
|
+
{
|
|
378
|
+
const _c = _1;
|
|
379
|
+
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_)
|
|
380
|
+
return
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}))
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
if((((last_.stopLine_ !== startLine_) && ff_compiler_Token.TokenKind_beforeSeparator(last_.kind_)) && ff_compiler_Token.TokenKind_afterSeparator(kind_))) {
|
|
387
|
+
ff_core_Stack.Stack_push(tokens_, ff_compiler_Token.Token(file_, code_, ff_compiler_Token.LSeparator(), startLine_, startLineOffset_, startLineOffset_, startLine_, startLineOffset_, startLineOffset_))
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
ff_core_Stack.Stack_push(tokens_, ff_compiler_Token.Token(file_, code_, kind_, startLine_, startLineOffset_, startOffset_, line_, lineOffset_, stopOffset_))
|
|
391
|
+
}
|
|
392
|
+
let i_ = 0;
|
|
393
|
+
function throwError_(message_) {
|
|
394
|
+
const column_ = ((i_ - startLineOffset_) + 1);
|
|
395
|
+
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)})
|
|
396
|
+
}
|
|
397
|
+
try {
|
|
398
|
+
while((i_ < ff_core_String.String_size(code_))) {
|
|
399
|
+
startLine_ = line_;
|
|
400
|
+
startLineOffset_ = lineOffset_;
|
|
401
|
+
if((completionLine_ === line_)) {
|
|
402
|
+
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)))) {
|
|
403
|
+
if((completionColumn_ === ((1 + i_) - lineOffset_))) {
|
|
404
|
+
emitToken_(ff_compiler_Token.LLower(), i_, i_)
|
|
405
|
+
};
|
|
406
|
+
i_ += 1
|
|
407
|
+
};
|
|
408
|
+
if(((i_ < ff_core_String.String_size(code_)) && (completionColumn_ === ((1 + i_) - lineOffset_)))) {
|
|
409
|
+
const c_ = ff_core_String.String_grab(code_, i_);
|
|
410
|
+
if(((((!ff_core_Char.Char_isAsciiLetterOrDigit(c_)) && (c_ !== 95)) && (c_ !== 39)) && (c_ !== 34))) {
|
|
411
|
+
emitToken_(ff_compiler_Token.LLower(), i_, i_);
|
|
412
|
+
if((((i_ + 1) < ff_core_String.String_size(code_)) && (ff_core_String.String_grab(code_, i_) === 95))) {
|
|
413
|
+
i_ += 1
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
} else {
|
|
418
|
+
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)))) {
|
|
419
|
+
i_ += 1
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
if((i_ < ff_core_String.String_size(code_))) {
|
|
423
|
+
const start_ = i_;
|
|
424
|
+
if((ff_core_String.String_grab(code_, i_) === 10)) {
|
|
425
|
+
i_ += 1;
|
|
426
|
+
line_ += 1;
|
|
427
|
+
lineOffset_ = i_
|
|
428
|
+
} else if(((ff_core_String.String_grab(code_, i_) === 47) && (ff_core_String.String_grab(code_, (i_ + 1)) === 47))) {
|
|
429
|
+
i_ += 2;
|
|
430
|
+
while(((i_ < ff_core_String.String_size(code_)) && (ff_core_String.String_grab(code_, i_) !== 10))) {
|
|
431
|
+
i_ += 1
|
|
432
|
+
}
|
|
433
|
+
} else if(((ff_core_String.String_grab(code_, i_) === 47) && (ff_core_String.String_grab(code_, (i_ + 1)) === 42))) {
|
|
434
|
+
i_ += 2;
|
|
435
|
+
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)))) {
|
|
436
|
+
if((i_ >= ff_core_String.String_size(code_))) {
|
|
437
|
+
throwError_((("Expected end of comment started on line " + startLine_) + ", got end of file."))
|
|
438
|
+
};
|
|
439
|
+
if((ff_core_String.String_grab(code_, i_) === 10)) {
|
|
440
|
+
line_ += 1;
|
|
441
|
+
lineOffset_ = (i_ + 1)
|
|
442
|
+
};
|
|
443
|
+
i_ += 1
|
|
444
|
+
};
|
|
445
|
+
i_ += 2
|
|
446
|
+
} else if(((ff_core_String.String_grab(code_, i_) === 34) || (ff_core_String.String_grab(code_, i_) === 39))) {
|
|
447
|
+
const endSign_ = ff_core_String.String_grab(code_, i_);
|
|
448
|
+
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));
|
|
449
|
+
i_ += (multiLine_
|
|
450
|
+
? 3
|
|
451
|
+
: 1);
|
|
452
|
+
while(((i_ < ff_core_String.String_size(code_)) && (multiLine_ || (ff_core_String.String_grab(code_, i_) !== endSign_)))) {
|
|
453
|
+
if((ff_core_String.String_grab(code_, i_) === 10)) {
|
|
454
|
+
if(multiLine_) {
|
|
455
|
+
line_ += 1;
|
|
456
|
+
lineOffset_ = (i_ + 1)
|
|
457
|
+
} else {
|
|
458
|
+
throwError_("Unexpected end of line in string.")
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
if((i_ >= ff_core_String.String_size(code_))) {
|
|
462
|
+
throwError_((("Expected end of string started on line " + startLine_) + ", got end of file."))
|
|
463
|
+
};
|
|
464
|
+
if(((ff_core_String.String_grab(code_, i_) === 92) && (ff_core_String.String_grab(code_, (i_ + 1)) !== 10))) {
|
|
465
|
+
i_ += 1
|
|
466
|
+
};
|
|
467
|
+
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))) {
|
|
468
|
+
multiLine_ = false;
|
|
469
|
+
i_ += 2
|
|
470
|
+
} else {
|
|
471
|
+
i_ += 1
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
i_ += 1;
|
|
475
|
+
emitToken_(((endSign_ === 34)
|
|
476
|
+
? ff_compiler_Token.LString()
|
|
477
|
+
: ff_compiler_Token.LChar()), start_, i_)
|
|
478
|
+
} else if(ff_core_Char.Char_isAsciiLetter(ff_core_String.String_grab(code_, i_))) {
|
|
479
|
+
const kind_ = ((ff_core_String.String_grab(code_, i_) >= 97)
|
|
480
|
+
? ff_compiler_Token.LLower()
|
|
481
|
+
: ff_compiler_Token.LUpper());
|
|
482
|
+
i_ += 1;
|
|
483
|
+
while(((i_ < ff_core_String.String_size(code_)) && ff_core_Char.Char_isAsciiLetterOrDigit(ff_core_String.String_grab(code_, i_)))) {
|
|
484
|
+
i_ += 1
|
|
485
|
+
};
|
|
486
|
+
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))) {
|
|
487
|
+
i_ += 1;
|
|
488
|
+
emitToken_(ff_compiler_Token.LNamespace(), start_, i_)
|
|
489
|
+
} else {
|
|
490
|
+
emitToken_(kind_, start_, i_)
|
|
491
|
+
}
|
|
492
|
+
} else if(ff_core_Char.Char_isAsciiDigit(ff_core_String.String_grab(code_, i_))) {
|
|
493
|
+
let dot_ = false;
|
|
494
|
+
let exponent_ = false;
|
|
495
|
+
while(((i_ < ff_core_String.String_size(code_)) && ff_core_Char.Char_isAsciiDigit(ff_core_String.String_grab(code_, i_)))) {
|
|
496
|
+
i_ += 1;
|
|
497
|
+
if((((ff_core_String.String_grab(code_, i_) === 101) || (ff_core_String.String_grab(code_, i_) === 69)) && (!exponent_))) {
|
|
498
|
+
i_ += 1;
|
|
499
|
+
dot_ = true;
|
|
500
|
+
exponent_ = true;
|
|
501
|
+
if(((ff_core_String.String_grab(code_, i_) === 43) || (ff_core_String.String_grab(code_, i_) === 45))) {
|
|
502
|
+
i_ += 1
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
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_))) {
|
|
506
|
+
i_ += 1;
|
|
507
|
+
dot_ = true
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
emitToken_(((dot_ || exponent_)
|
|
511
|
+
? ff_compiler_Token.LFloat()
|
|
512
|
+
: ff_compiler_Token.LInt()), start_, i_)
|
|
513
|
+
} else if((ff_core_String.String_grab(code_, i_) === 95)) {
|
|
514
|
+
i_ += 1;
|
|
515
|
+
emitToken_(ff_compiler_Token.LWildcard(), start_, i_)
|
|
516
|
+
} else if((ff_core_String.String_grab(code_, i_) === 44)) {
|
|
517
|
+
i_ += 1;
|
|
518
|
+
emitToken_(ff_compiler_Token.LComma(), start_, i_)
|
|
519
|
+
} 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)) {
|
|
520
|
+
i_ += 1;
|
|
521
|
+
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))) {
|
|
522
|
+
emitToken_(ff_compiler_Token.LDot(), start_, i_);
|
|
523
|
+
const newStart_ = i_;
|
|
524
|
+
if((!ff_core_Option.Option_isEmpty(completionAt_))) {
|
|
525
|
+
emitToken_(ff_compiler_Token.LLower(), newStart_, newStart_)
|
|
526
|
+
};
|
|
527
|
+
i_ += 1;
|
|
528
|
+
emitToken_(ff_compiler_Token.LDot(), newStart_, i_)
|
|
529
|
+
} else {
|
|
530
|
+
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))) {
|
|
531
|
+
i_ += 1
|
|
532
|
+
};
|
|
533
|
+
const o_ = ((((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 46))
|
|
534
|
+
? ff_compiler_Token.LDot()
|
|
535
|
+
: (((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 59))
|
|
536
|
+
? ff_compiler_Token.LSemicolon()
|
|
537
|
+
: (((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 124))
|
|
538
|
+
? ff_compiler_Token.LPipe()
|
|
539
|
+
: (((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 58))
|
|
540
|
+
? ff_compiler_Token.LColon()
|
|
541
|
+
: (((((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))
|
|
542
|
+
? ff_compiler_Token.LDotDotDot()
|
|
543
|
+
: ((((i_ - start_) === 2) && (ff_core_String.String_grab(code_, (i_ - 2)) === 61)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 62))
|
|
544
|
+
? ff_compiler_Token.LArrowThick()
|
|
545
|
+
: (((i_ - start_) === 1) && (ff_core_String.String_grab(code_, (i_ - 1)) === 61))
|
|
546
|
+
? ff_compiler_Token.LAssign()
|
|
547
|
+
: ((((i_ - start_) === 2) && (ff_core_String.String_grab(code_, (i_ - 2)) === 43)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 61))
|
|
548
|
+
? ff_compiler_Token.LAssignPlus()
|
|
549
|
+
: ((((i_ - start_) === 2) && (ff_core_String.String_grab(code_, (i_ - 2)) === 45)) && (ff_core_String.String_grab(code_, (i_ - 1)) === 61))
|
|
550
|
+
? ff_compiler_Token.LAssignMinus()
|
|
551
|
+
: (((((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))
|
|
552
|
+
? ff_compiler_Token.LAssignLink()
|
|
553
|
+
: ff_compiler_Token.LOperator());
|
|
554
|
+
emitToken_(o_, start_, i_)
|
|
555
|
+
}
|
|
556
|
+
} 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))) {
|
|
557
|
+
i_ += 1;
|
|
558
|
+
emitToken_(ff_compiler_Token.LBracketLeft(), start_, i_)
|
|
559
|
+
} 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))) {
|
|
560
|
+
i_ += 1;
|
|
561
|
+
emitToken_(ff_compiler_Token.LBracketRight(), start_, i_)
|
|
562
|
+
} else if((i_ < ff_core_String.String_size(code_))) {
|
|
563
|
+
if(attemptFixes_) {
|
|
564
|
+
i_ += 1
|
|
565
|
+
} else {
|
|
566
|
+
throwError_(("Unexpected character: " + ff_core_Show.ff_core_Show_Show$ff_core_Char_Char.show_(ff_core_String.String_grab(code_, i_))))
|
|
567
|
+
}
|
|
568
|
+
} else {}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
} catch(_error) {
|
|
572
|
+
if(!_error.ffException) throw _error
|
|
573
|
+
const _exception = ff_core_Any.fromAny_(_error.ffException, ff_core_Core.ff_core_Any_HasAnyTag$ff_core_Core_GrabException)
|
|
574
|
+
if(!_exception.Some) throw _error
|
|
575
|
+
const e_ = _exception.value_;
|
|
576
|
+
const error_ = _error;
|
|
577
|
+
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)})
|
|
578
|
+
};
|
|
579
|
+
ff_core_List.List_each(ff_core_List.range_(5), ((_) => {
|
|
580
|
+
emitToken_(ff_compiler_Token.LEnd(), i_, i_)
|
|
581
|
+
}));
|
|
582
|
+
return ff_core_Stack.Stack_drain(tokens_)
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
|