firefly-compiler 0.4.79 → 0.4.81
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/.hintrc +4 -4
- package/.vscode/settings.json +4 -4
- package/bin/Release.ff +153 -153
- package/bin/firefly.mjs +1 -1
- package/compiler/Builder.ff +257 -257
- package/compiler/Compiler.ff +227 -227
- package/compiler/Dependencies.ff +187 -187
- package/compiler/DependencyLock.ff +17 -17
- package/compiler/Inference.ff +2 -1
- package/compiler/JsEmitter.ff +940 -946
- package/compiler/LspHook.ff +202 -202
- package/compiler/Main.ff +3 -3
- package/compiler/ModuleCache.ff +178 -178
- package/compiler/Tokenizer.ff +1 -1
- package/compiler/Unification.ff +1 -1
- package/compiler/Workspace.ff +88 -88
- package/core/.firefly/include/package-lock.json +564 -564
- package/core/.firefly/include/package.json +5 -5
- package/core/.firefly/include/prepare.sh +1 -1
- package/core/.firefly/package.ff +2 -2
- package/core/Array.ff +265 -265
- package/core/Atomic.ff +64 -64
- package/core/Box.ff +7 -7
- package/core/BrowserSystem.ff +40 -40
- package/core/BuildSystem.ff +148 -148
- package/core/Crypto.ff +96 -96
- package/core/Equal.ff +36 -36
- package/core/Float.ff +25 -0
- package/core/HttpClient.ff +148 -148
- package/core/JsSystem.ff +69 -69
- package/core/Json.ff +434 -434
- package/core/List.ff +486 -486
- package/core/Lock.ff +144 -144
- package/core/NodeSystem.ff +216 -216
- package/core/Ordering.ff +161 -161
- package/core/Path.ff +401 -401
- package/core/Random.ff +134 -134
- package/core/RbMap.ff +216 -216
- package/core/Show.ff +43 -43
- package/core/SourceLocation.ff +68 -68
- package/core/Stream.ff +9 -9
- package/core/Task.ff +149 -141
- package/core/Try.ff +25 -4
- package/experimental/benchmarks/ListGrab.ff +23 -23
- package/experimental/benchmarks/ListGrab.java +55 -55
- package/experimental/benchmarks/Pyrotek45.ff +30 -30
- package/experimental/benchmarks/Pyrotek45.java +64 -64
- package/experimental/bidirectional/Bidi.ff +88 -88
- package/experimental/random/Index.ff +53 -53
- package/experimental/random/Process.ff +120 -120
- package/experimental/random/Scrape.ff +51 -51
- package/experimental/random/Symbols.ff +73 -73
- package/experimental/random/Tensor.ff +52 -52
- package/experimental/random/Units.ff +36 -36
- package/experimental/s3/S3TestAuthorizationHeader.ff +39 -39
- package/experimental/s3/S3TestPut.ff +16 -16
- package/experimental/tests/TestJson.ff +26 -26
- package/firefly.sh +0 -0
- package/fireflysite/.firefly/package.ff +4 -4
- package/fireflysite/CommunityOverview.ff +20 -20
- package/fireflysite/CountingButtonDemo.ff +58 -58
- package/fireflysite/DocumentParser.ff +331 -217
- package/fireflysite/ExamplesOverview.ff +40 -40
- package/fireflysite/FrontPage.ff +344 -360
- package/fireflysite/{GuideIntroduction.ff → GettingStarted.ff} +45 -52
- package/fireflysite/Guide.ff +442 -411
- package/fireflysite/Main.ff +151 -137
- package/fireflysite/MatchingPasswordsDemo.ff +82 -82
- package/fireflysite/PackagesOverview.ff +49 -49
- package/fireflysite/PostgresqlDemo.ff +34 -34
- package/fireflysite/ReferenceAll.ff +18 -0
- package/fireflysite/ReferenceIntroduction.ff +11 -0
- package/fireflysite/Styles.ff +567 -495
- package/fireflysite/Test.ff +46 -0
- package/fireflysite/assets/markdown/reference/BaseTypes.md +209 -0
- package/fireflysite/assets/markdown/reference/EmittedJavascript.md +66 -0
- package/fireflysite/assets/markdown/reference/Exceptions.md +101 -0
- package/fireflysite/assets/markdown/reference/FunctionsAndMethods.md +338 -0
- package/fireflysite/assets/markdown/reference/JavascriptInterop.md +134 -0
- package/fireflysite/assets/markdown/reference/ModulesAndPackages.md +162 -0
- package/fireflysite/assets/markdown/reference/OldStructuredConcurrency.md +48 -0
- package/fireflysite/assets/markdown/reference/PatternMatching.md +224 -0
- package/fireflysite/assets/markdown/reference/StatementsAndExpressions.md +86 -0
- package/fireflysite/assets/markdown/reference/StructuredConcurrency.md +99 -0
- package/fireflysite/assets/markdown/reference/TraitsAndInstances.md +100 -0
- package/fireflysite/assets/markdown/reference/UserDefinedTypes.md +184 -0
- package/fireflysite/assets/markdown/{ControlFlow.md → scratch/ControlFlow.md} +136 -136
- package/fireflysite/assets/markdown/scratch/Toc.md +41 -0
- package/lsp/.firefly/package.ff +1 -1
- package/lsp/CompletionHandler.ff +828 -828
- package/lsp/Handler.ff +714 -714
- package/lsp/HoverHandler.ff +79 -79
- package/lsp/LanguageServer.ff +272 -272
- package/lsp/SignatureHelpHandler.ff +55 -55
- package/lsp/SymbolHandler.ff +181 -181
- package/lsp/TestReferences.ff +17 -17
- package/lsp/TestReferencesCase.ff +7 -7
- package/lsp/stderr.txt +1 -1
- package/lsp/stdout.txt +34 -34
- package/lux/.firefly/package.ff +1 -1
- package/lux/Css.ff +648 -648
- package/lux/CssTest.ff +48 -48
- package/lux/Lux.ff +593 -487
- package/lux/LuxEvent.ff +116 -116
- package/lux/Main.ff +123 -123
- package/lux/Main2.ff +143 -143
- package/lux/TestDry.ff +27 -0
- package/output/js/ff/compiler/Builder.mjs +47 -47
- package/output/js/ff/compiler/Dependencies.mjs +3 -3
- package/output/js/ff/compiler/Inference.mjs +2 -2
- package/output/js/ff/compiler/JsEmitter.mjs +18 -72
- package/output/js/ff/compiler/Main.mjs +4 -4
- package/output/js/ff/compiler/ModuleCache.mjs +4 -4
- package/output/js/ff/core/Array.mjs +59 -59
- package/output/js/ff/core/Atomic.mjs +36 -36
- package/output/js/ff/core/BrowserSystem.mjs +11 -11
- package/output/js/ff/core/BuildSystem.mjs +30 -30
- package/output/js/ff/core/Crypto.mjs +40 -40
- package/output/js/ff/core/Float.mjs +50 -0
- package/output/js/ff/core/HttpClient.mjs +56 -56
- package/output/js/ff/core/Json.mjs +147 -147
- package/output/js/ff/core/List.mjs +50 -50
- package/output/js/ff/core/Lock.mjs +97 -97
- package/output/js/ff/core/NodeSystem.mjs +87 -87
- package/output/js/ff/core/Ordering.mjs +8 -8
- package/output/js/ff/core/Path.mjs +231 -231
- package/output/js/ff/core/Random.mjs +56 -56
- package/output/js/ff/core/Task.mjs +71 -39
- package/output/js/ff/core/Try.mjs +98 -4
- package/package.json +1 -1
- package/postgresql/Pg.ff +1 -1
- package/rpc/.firefly/package.ff +1 -1
- package/rpc/Rpc.ff +70 -70
- package/s3/.firefly/package.ff +1 -1
- package/s3/S3.ff +94 -94
- package/unsafejs/UnsafeJs.ff +19 -19
- package/vscode/LICENSE.txt +21 -21
- package/vscode/Prepublish.ff +15 -15
- package/vscode/README.md +16 -16
- package/vscode/client/package.json +22 -22
- package/vscode/client/src/extension.ts +104 -104
- package/vscode/icons/firefly-icon.svg +10 -10
- package/vscode/language-configuration.json +61 -61
- package/vscode/package-lock.json +3623 -3623
- package/vscode/package.json +1 -1
- package/vscode/snippets.json +241 -241
- package/vscode/syntaxes/firefly-markdown-injection.json +45 -45
- package/webserver/.firefly/include/package-lock.json +22 -22
- package/webserver/.firefly/include/package.json +5 -5
- package/webserver/.firefly/package.ff +2 -2
- package/webserver/WebServer.ff +685 -685
- package/websocket/.firefly/package.ff +1 -1
- package/websocket/WebSocket.ff +131 -131
- package/fireflysite/GuideAll.ff +0 -21
- package/fireflysite/GuideBaseTypes.ff +0 -168
- package/fireflysite/GuideControlFlow.ff +0 -212
- package/fireflysite/assets/markdown/Example.md +0 -78
- /package/fireflysite/assets/{NotoSansMono-Regular.ttf → font/NotoSansMono-Regular.ttf} +0 -0
- /package/fireflysite/assets/{NunitoSans-VariableFont_YTLC,opsz,wdth,wght.ttf → font/NunitoSans-VariableFont_YTLC,opsz,wdth,wght.ttf} +0 -0
- /package/fireflysite/assets/{autocomplete-small.png → image/autocomplete-small.png} +0 -0
- /package/fireflysite/assets/{autocomplete.png → image/autocomplete.png} +0 -0
- /package/fireflysite/assets/{edit-time-error.png → image/edit-time-error.png} +0 -0
- /package/fireflysite/assets/{firefly-logo-notext.png → image/firefly-logo-notext.png} +0 -0
- /package/fireflysite/assets/{firefly-logo-yellow.png → image/firefly-logo-yellow.png} +0 -0
|
@@ -1,218 +1,332 @@
|
|
|
1
|
-
import WebServer from ff:webserver // This is required to run the file.
|
|
2
|
-
import Guide
|
|
3
|
-
|
|
4
|
-
nodeMain(system: NodeSystem) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
let
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
let
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
} {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
i.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
1
|
+
import WebServer from ff:webserver // This is required to run the file.
|
|
2
|
+
import Guide
|
|
3
|
+
|
|
4
|
+
nodeMain(system: NodeSystem) {
|
|
5
|
+
|
|
6
|
+
function logDuration[T](label: String, body: () => T): T {
|
|
7
|
+
let started = system.mainTask().elapsed()
|
|
8
|
+
let result = body()
|
|
9
|
+
Log.debug(label + ": " + Show.show(Duration(system.mainTask().elapsed().seconds - started.seconds)))
|
|
10
|
+
result
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let file = system.path("assets/markdown/reference/FunctionsAndMethods.md")
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
logDuration("parse " + file.base()) {
|
|
17
|
+
mutable i = 0
|
|
18
|
+
while {i < 10000} {
|
|
19
|
+
parse(file)
|
|
20
|
+
i += 1
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
*/
|
|
24
|
+
let document = parse(file)
|
|
25
|
+
printSections(system, document)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
parse(file: Path): List[Section] {
|
|
31
|
+
let content = file.readText()
|
|
32
|
+
let lines = content.split('\n')
|
|
33
|
+
let parser = DocumentParser(file.absolute(), lines, 0)
|
|
34
|
+
parser.parseDocument()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
class DocumentParser(
|
|
38
|
+
fileName: String
|
|
39
|
+
lines: List[String]
|
|
40
|
+
mutable i: Int
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
extend self: DocumentParser {
|
|
44
|
+
|
|
45
|
+
parseDocument(): List[Section] {
|
|
46
|
+
iterate {self.parseSection()}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
parseSection(): Option[Section] {
|
|
50
|
+
self.skipWhile {_.trim() == ""}
|
|
51
|
+
self.first().{
|
|
52
|
+
| Some(line) {line.trim().removeFirst("#") | Some(heading)} =>
|
|
53
|
+
self.skip(1)
|
|
54
|
+
let blocks = iterate {self.parseBlock()}
|
|
55
|
+
Some(Section(heading.trim(), blocks))
|
|
56
|
+
| _ => None
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
parseBlock(): Option[Block] {
|
|
61
|
+
self.skipWhile {_.trim() == ""}
|
|
62
|
+
let first = self.first().map {_.trimStart()}
|
|
63
|
+
first.{
|
|
64
|
+
| Some(line) {line.removeFirst("```") | Some(l)} =>
|
|
65
|
+
self.skip(1)
|
|
66
|
+
let isFirefly = l.startsWith("firefly")
|
|
67
|
+
let block = self.parseRemainingCodeBlock(isFirefly)
|
|
68
|
+
Some(block)
|
|
69
|
+
| Some(line) {line.removeFirst("* ") | Some(l)} =>
|
|
70
|
+
self.skip(1)
|
|
71
|
+
Some(Bullets(self.parseBullets(l)))
|
|
72
|
+
| Some(line) {line.first().any {_ != '#'}} =>
|
|
73
|
+
Some(self.parseParagraph())
|
|
74
|
+
| _ => None
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
parseParagraph(): Block {
|
|
79
|
+
let lines = self.consumeWhile {_.trim() != ""}
|
|
80
|
+
Paragraph(self.parseInlines(lines))
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
parseInlines(lines: List[String]): List[Inline] {
|
|
84
|
+
let parser = InlineParser(self.fileName, lines.join("\n"), 0)
|
|
85
|
+
let inlines = parser.parseInlines()
|
|
86
|
+
inlines
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
parseBullets(firstLine: String): List[List[Inline]] {
|
|
90
|
+
let pair = self.consumeToSome {line =>
|
|
91
|
+
let trimmed = line.trim()
|
|
92
|
+
let endWithNextLine = trimmed.{
|
|
93
|
+
| "" => Some(None)
|
|
94
|
+
| t {t.removeFirst("* ") | Some(nextLine)} => Some(Some(nextLine))
|
|
95
|
+
| _ => None
|
|
96
|
+
}
|
|
97
|
+
endWithNextLine
|
|
98
|
+
}
|
|
99
|
+
let bulletLines = [firstLine, ...pair.first]
|
|
100
|
+
let bullet = self.parseInlines(bulletLines)
|
|
101
|
+
pair.second.{
|
|
102
|
+
| None => [bullet]
|
|
103
|
+
| Some(None) => [bullet]
|
|
104
|
+
| Some(Some(nextLine)) => [bullet, ...self.parseBullets(nextLine)]
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
parseRemainingCodeBlock(isFirefly: Bool): Block {
|
|
109
|
+
let code = self.consumeWhile {!_.trimStart().startsWith("```")}
|
|
110
|
+
self.skip(1)
|
|
111
|
+
CodeBlock(code.join("\n"), isFirefly)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
first(): Option[String] {
|
|
115
|
+
if(self.i < self.lines.size()) {
|
|
116
|
+
self.lines.grab(self.i)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
skip(count: Int): Unit {
|
|
121
|
+
self.i += count
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
skipWhile(body: String => Bool): Unit {
|
|
125
|
+
while {self.i < self.lines.size() && body(self.lines.grab(self.i))} {
|
|
126
|
+
self.i += 1
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
consumeWhile(body: String => Bool): List[String] {
|
|
131
|
+
let oldI = self.i
|
|
132
|
+
self.skipWhile(body)
|
|
133
|
+
self.lines.slice(oldI, self.i)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
consumeToSome[T](body: String => Option[T]): Pair[List[String], Option[T]] {
|
|
137
|
+
let oldI = self.i
|
|
138
|
+
mutable end = None
|
|
139
|
+
while {self.i < self.lines.size() && end.isEmpty()} {
|
|
140
|
+
end = body(self.lines.grab(self.i))
|
|
141
|
+
self.i += 1
|
|
142
|
+
}
|
|
143
|
+
let endI = if(end.isEmpty()) {self.i} else {self.i - 1}
|
|
144
|
+
Pair(self.lines.slice(oldI, endI), end)
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
class InlineParser(
|
|
149
|
+
fileName: String
|
|
150
|
+
line: String
|
|
151
|
+
mutable i: Int
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
extend self: InlineParser {
|
|
155
|
+
|
|
156
|
+
parseInlines(): List[Inline] {
|
|
157
|
+
iterateLists {self.parseInline()}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
parseInline(): List[Inline] {
|
|
161
|
+
mutable inline = []
|
|
162
|
+
mutable j = 0
|
|
163
|
+
|
|
164
|
+
doWhile {
|
|
165
|
+
let remaining = self.size() - j
|
|
166
|
+
if(remaining >= 3) {
|
|
167
|
+
self.grab(j).{
|
|
168
|
+
| '_' => inline = self.parseNextInline(j, {self.parseItalic()})
|
|
169
|
+
| '`' => inline = self.parseNextInline(j, {self.parseCode()})
|
|
170
|
+
| '[' => inline = self.parseNextInline(j, {self.parseLink()})
|
|
171
|
+
| '*' {self.grab(j + 1) == '*'} => inline = self.parseNextInline(j, {self.parseBold()})
|
|
172
|
+
| _ =>
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
j += 1
|
|
176
|
+
remaining > 0 && inline.isEmpty()
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
inline.{
|
|
180
|
+
| [] {j == 1} => []
|
|
181
|
+
| [] => [Text(self.consume(j - 1))]
|
|
182
|
+
| inlines => inlines
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
parseNextInline(offset: Int, parseNext: () => Option[Inline]): List[Inline] {
|
|
187
|
+
if(offset == 0) {parseNext().toList()} else:
|
|
188
|
+
|
|
189
|
+
let oldI = self.i
|
|
190
|
+
self.i += offset
|
|
191
|
+
parseNext().{
|
|
192
|
+
| None =>
|
|
193
|
+
self.i = oldI
|
|
194
|
+
[]
|
|
195
|
+
| Some(nextInline) =>
|
|
196
|
+
let text = self.line.slice(oldI, oldI + offset)
|
|
197
|
+
let textInline = Text(text)
|
|
198
|
+
[textInline, nextInline]
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
parseLink(): Option[Inline] {
|
|
203
|
+
let oldI = self.i
|
|
204
|
+
self.parseEnclosed("[", "]").flatMap {text =>
|
|
205
|
+
self.parseEnclosed("(", ")").{
|
|
206
|
+
| None =>
|
|
207
|
+
self.i = oldI
|
|
208
|
+
None
|
|
209
|
+
| Some(url) => Some(Link(text, url))
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
parseBold(): Option[Inline] {
|
|
215
|
+
self.parseEnclosed("**", "**").map {Bold(_)}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
parseItalic(): Option[Inline] {
|
|
219
|
+
self.parseEnclosed("_", "_").map {Italic(_)}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
parseCode(): Option[Inline] {
|
|
223
|
+
self.parseEnclosed("`", "`").map {Code(_)}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
parseEnclosed(left: String, right: String): Option[String] {
|
|
227
|
+
if(self.startsWith(left)) {
|
|
228
|
+
indexOf(self.line, right, self.i + left.size()).map {end =>
|
|
229
|
+
let text = self.line.slice(self.i + left.size(), end)
|
|
230
|
+
self.i = end + right.size()
|
|
231
|
+
text
|
|
232
|
+
}
|
|
233
|
+
}.flatten()
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
grab(index: Int): Char {
|
|
237
|
+
self.line.grab(self.i + index)
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
size(): Int {
|
|
241
|
+
self.line.size() - self.i
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
startsWith(text: String): Bool {
|
|
245
|
+
self.size() >= text.size() && self.line.slice(self.i, self.i + text.size()) == text
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
consume(count: Int): String {
|
|
249
|
+
let text = self.line.slice(self.i, self.i + count)
|
|
250
|
+
self.i += count
|
|
251
|
+
text
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
iterate[T](body: () => Option[T]): List[T] {
|
|
256
|
+
let array = Array.new()
|
|
257
|
+
doWhile {
|
|
258
|
+
body().{
|
|
259
|
+
| None => False
|
|
260
|
+
| Some(s) =>
|
|
261
|
+
array.push(s)
|
|
262
|
+
True
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
array.drain()
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
iterateLists[T](body: () => List[T]): List[T] {
|
|
269
|
+
let array = Array.new()
|
|
270
|
+
doWhile {
|
|
271
|
+
body().{
|
|
272
|
+
| [] => False
|
|
273
|
+
| list =>
|
|
274
|
+
array.pushList(list)
|
|
275
|
+
True
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
array.drain()
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
indexOf(string: String, searchString: String, position: Int = 0): Option[Int]
|
|
282
|
+
target js sync """
|
|
283
|
+
const i = string_.indexOf(searchString_, position_);
|
|
284
|
+
return i == -1 ? ff_core_Option.None() : ff_core_Option.Some(i);
|
|
285
|
+
"""
|
|
286
|
+
|
|
287
|
+
printSections(system: NodeSystem, sections: List[Section]) {
|
|
288
|
+
sections.each {
|
|
289
|
+
| Section(heading, blocks) =>
|
|
290
|
+
system.writeLine("# " + heading)
|
|
291
|
+
blocks.each {
|
|
292
|
+
| Bullets(items) =>
|
|
293
|
+
system.writeLine(" Bullets:")
|
|
294
|
+
system.writeLine(" " + Show.show(items))
|
|
295
|
+
| CodeBlock(code, True) =>
|
|
296
|
+
system.writeLine(" Code (Firefly):")
|
|
297
|
+
system.writeLine(" " + Show.show(code))
|
|
298
|
+
| CodeBlock(code, False) =>
|
|
299
|
+
system.writeLine(" Code:")
|
|
300
|
+
system.writeLine(" " + Show.show(code))
|
|
301
|
+
| Image(url) =>
|
|
302
|
+
system.writeLine(" Image:")
|
|
303
|
+
system.writeLine(" " + Show.show(url))
|
|
304
|
+
| LuxDemo(demo) =>
|
|
305
|
+
system.writeLine(" Lux:")
|
|
306
|
+
system.writeLine(" " + Show.show(demo))
|
|
307
|
+
| Paragraph(inlines) =>
|
|
308
|
+
system.writeLine(" Paragraph:")
|
|
309
|
+
inlines.each {
|
|
310
|
+
| Anchor(heading, title) =>
|
|
311
|
+
system.writeLine(" Anchor: " + Show.show(heading) + ", " + Show.show(title))
|
|
312
|
+
| Bold(text) =>
|
|
313
|
+
system.writeLine(" Bold: " + Show.show(text))
|
|
314
|
+
| Code(code, True) =>
|
|
315
|
+
system.writeLine(" Code (firefly): " + Show.show(code))
|
|
316
|
+
| Code(code, False) =>
|
|
317
|
+
system.writeLine(" Code: " + Show.show(code))
|
|
318
|
+
| Italic(text) =>
|
|
319
|
+
system.writeLine(" Italic: " + Show.show(text))
|
|
320
|
+
| Link(text, url) =>
|
|
321
|
+
system.writeLine(" Link: " + Show.show(text) + ", " + Show.show(url))
|
|
322
|
+
| Text(text) =>
|
|
323
|
+
system.writeLine(" Text: " + Show.show(text))
|
|
324
|
+
}
|
|
325
|
+
| Video(url) =>
|
|
326
|
+
system.writeLine(" Video:")
|
|
327
|
+
system.writeLine(" " + Show.show(url))
|
|
328
|
+
}
|
|
329
|
+
| SplitSection(heading, first, second) =>
|
|
330
|
+
system.writeLine("SPLIT")
|
|
331
|
+
}
|
|
218
332
|
}
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import Guide
|
|
2
|
-
import CountingButtonDemo
|
|
3
|
-
import MatchingPasswordsDemo
|
|
4
|
-
import PostgresqlDemo
|
|
5
|
-
|
|
6
|
-
mock(): List[Document] {
|
|
7
|
-
[
|
|
8
|
-
new()
|
|
9
|
-
CountingButtonDemo.newDocument()
|
|
10
|
-
MatchingPasswordsDemo.newDocument()
|
|
11
|
-
PostgresqlDemo.newDocument()
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
demos(): List[Demo] {
|
|
16
|
-
[
|
|
17
|
-
CountingButtonDemo.new()
|
|
18
|
-
MatchingPasswordsDemo.new()
|
|
19
|
-
]
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
new(): Document {
|
|
23
|
-
ReadyDocument([
|
|
24
|
-
Section("Examples", [
|
|
25
|
-
Paragraph([
|
|
26
|
-
Text("Here you'll find examples that demonstrate what you can do with Firefly.")
|
|
27
|
-
Text("In fact, you're looking at an example right now - this site is")
|
|
28
|
-
Link("written in Firefly", "https://github.com/Ahnfelt/firefly-boot/tree/master/fireflysite")
|
|
29
|
-
Text("and so is the")
|
|
30
|
-
Link("Firefly compiler", "https://github.com/Ahnfelt/firefly-boot/tree/master/compiler")
|
|
31
|
-
Text("and")
|
|
32
|
-
Link("language server", "https://github.com/Ahnfelt/firefly-boot/tree/master/lsp")
|
|
33
|
-
Text(".")
|
|
34
|
-
])
|
|
35
|
-
Paragraph([
|
|
36
|
-
Text("Check the list here for examples and demos.")
|
|
37
|
-
])
|
|
38
|
-
])
|
|
39
|
-
])
|
|
40
|
-
}
|
|
1
|
+
import Guide
|
|
2
|
+
import CountingButtonDemo
|
|
3
|
+
import MatchingPasswordsDemo
|
|
4
|
+
import PostgresqlDemo
|
|
5
|
+
|
|
6
|
+
mock(): List[Document] {
|
|
7
|
+
[
|
|
8
|
+
new()
|
|
9
|
+
CountingButtonDemo.newDocument()
|
|
10
|
+
MatchingPasswordsDemo.newDocument()
|
|
11
|
+
PostgresqlDemo.newDocument()
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
demos(): List[Demo] {
|
|
16
|
+
[
|
|
17
|
+
CountingButtonDemo.new()
|
|
18
|
+
MatchingPasswordsDemo.new()
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
new(): Document {
|
|
23
|
+
ReadyDocument([
|
|
24
|
+
Section("Examples", [
|
|
25
|
+
Paragraph([
|
|
26
|
+
Text("Here you'll find examples that demonstrate what you can do with Firefly.")
|
|
27
|
+
Text("In fact, you're looking at an example right now - this site is")
|
|
28
|
+
Link("written in Firefly", "https://github.com/Ahnfelt/firefly-boot/tree/master/fireflysite")
|
|
29
|
+
Text("and so is the")
|
|
30
|
+
Link("Firefly compiler", "https://github.com/Ahnfelt/firefly-boot/tree/master/compiler")
|
|
31
|
+
Text("and")
|
|
32
|
+
Link("language server", "https://github.com/Ahnfelt/firefly-boot/tree/master/lsp")
|
|
33
|
+
Text(".")
|
|
34
|
+
])
|
|
35
|
+
Paragraph([
|
|
36
|
+
Text("Check the list here for examples and demos.")
|
|
37
|
+
])
|
|
38
|
+
])
|
|
39
|
+
])
|
|
40
|
+
}
|