@effekt-lang/effekt 0.18.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/effekt +0 -0
- package/libraries/common/buffer.effekt +3 -3
- package/libraries/common/bytearray.effekt +64 -1
- package/libraries/common/effekt.effekt +45 -10
- package/libraries/common/heap.effekt +103 -0
- package/libraries/common/io/filesystem.effekt +49 -66
- package/libraries/common/io/network.effekt +8 -5
- package/libraries/common/json.effekt +30 -22
- package/libraries/common/map.effekt +992 -0
- package/libraries/common/regex.effekt +64 -0
- package/libraries/common/resizable_array.effekt +235 -0
- package/libraries/common/set.effekt +234 -0
- package/libraries/common/stream.effekt +47 -2
- package/libraries/common/string.effekt +7 -0
- package/libraries/common/stringbuffer.effekt +65 -0
- package/libraries/common/union_find.effekt +113 -0
- package/libraries/llvm/bytearray.c +36 -7
- package/libraries/llvm/forward-declare-c.ll +2 -0
- package/libraries/llvm/io.c +17 -43
- package/libraries/llvm/main.c +2 -1
- package/libraries/llvm/panic.c +20 -0
- package/libraries/llvm/rts.ll +141 -142
- package/licenses/eclipse public license, version 2.0 - epl-2.0.html +4 -4
- package/licenses/mit license - mit-license.html +82 -18
- package/licenses/the bsd license - bsd-license.html +81 -17
- package/licenses/the mit license - mit.html +81 -17
- package/package.json +1 -1
- package/libraries/chez/common/text/regex.effekt +0 -31
- package/libraries/js/text/regex.effekt +0 -33
- package/libraries/llvm/hole.c +0 -11
|
@@ -62,7 +62,7 @@ def encodeJsonObject[R]{ body: => R / JsonObjectBuilder }: R / emit[String] = {
|
|
|
62
62
|
do emit("{")
|
|
63
63
|
def c(k: String) = {
|
|
64
64
|
if (not(first)) { do emit(",") }
|
|
65
|
-
do emit(escape(k)); do emit(":")
|
|
65
|
+
do emit(escape(k)); do emit(":")
|
|
66
66
|
first = false
|
|
67
67
|
}
|
|
68
68
|
val r = encodeJson {
|
|
@@ -76,7 +76,7 @@ def encodeJsonObject[R]{ body: => R / JsonObjectBuilder }: R / emit[String] = {
|
|
|
76
76
|
/// Main entry point for encoding json.
|
|
77
77
|
/// Emits individual tokens of the resulting json.
|
|
78
78
|
def encodeJson[R]{ body: => R / JsonBuilder }: R / emit[String] = {
|
|
79
|
-
try body() with JsonBuilder {
|
|
79
|
+
try body() with JsonBuilder {
|
|
80
80
|
def null() = { resume(do emit("null")) }
|
|
81
81
|
def bool(v) = { resume(do emit( if(v){ "true" } else { "false" } )) }
|
|
82
82
|
def number(n) = { resume(do emit(show(n))) }
|
|
@@ -112,7 +112,7 @@ def readDouble(): Double / Scan[Char] = {
|
|
|
112
112
|
if (optionally { readIf('.') }) {
|
|
113
113
|
var b = 0.1
|
|
114
114
|
var r = pre.toDouble
|
|
115
|
-
while (optionally[Int] { readDigit() } is Some(d)) {
|
|
115
|
+
while (returning::optionally[Int] { readDigit() } is Some(d)) {
|
|
116
116
|
r = r + b * d.toDouble
|
|
117
117
|
b = b * 0.1
|
|
118
118
|
}
|
|
@@ -126,14 +126,14 @@ def readDouble(): Double / Scan[Char] = {
|
|
|
126
126
|
|
|
127
127
|
def expectString(string: String): Unit / { Scan[Char], Exception[WrongFormat] } =
|
|
128
128
|
for[Char] { string.each } { char =>
|
|
129
|
-
expect
|
|
129
|
+
expect("Expected " ++ string) { readIf(char) }
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
/// Read and unescape a string in ""
|
|
133
133
|
def readQuotedString(): Unit / { Scan[Char], emit[Char], Exception[WrongFormat] } = {
|
|
134
134
|
try {
|
|
135
135
|
skipWhitespace()
|
|
136
|
-
expect
|
|
136
|
+
expect("Expected \"") { readIf('"') }
|
|
137
137
|
while(read[Char]() is c and c != '"') {
|
|
138
138
|
c match {
|
|
139
139
|
case '\\' => read[Char]() match {
|
|
@@ -191,7 +191,7 @@ def decodeJsonObject(): Unit / {Scan[Char], JsonObjectBuilder, Exception[WrongFo
|
|
|
191
191
|
}
|
|
192
192
|
do skip[Char]()
|
|
193
193
|
}
|
|
194
|
-
def decodeJsonList(): Unit / {Scan[Char], JsonBuilder, Exception[WrongFormat]} = {
|
|
194
|
+
def decodeJsonList(): Unit / {Scan[Char], JsonBuilder, Exception[WrongFormat]} = {
|
|
195
195
|
var first = true
|
|
196
196
|
expectString("[")
|
|
197
197
|
with boundary
|
|
@@ -278,7 +278,7 @@ def build[R](){ body: => R / JsonBuilder }: (R, JsonValue) = {
|
|
|
278
278
|
}
|
|
279
279
|
(x, r)
|
|
280
280
|
}
|
|
281
|
-
def buildList[R](){ body: => R / JsonBuilder }: (R, List[JsonValue]) = collectList[JsonValue, R] {
|
|
281
|
+
def buildList[R](){ body: => R / JsonBuilder }: (R, List[JsonValue]) = returning::collectList[JsonValue, R] {
|
|
282
282
|
try body() with JsonBuilder {
|
|
283
283
|
def number(n) = { do emit(Number(n)); resume(()) }
|
|
284
284
|
def bool(b) = { do emit(Bool(b)); resume(()) }
|
|
@@ -296,7 +296,7 @@ def buildList[R](){ body: => R / JsonBuilder }: (R, List[JsonValue]) = collectLi
|
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
|
-
def buildDict[R](){ body: => R / JsonObjectBuilder }: (R, List[(String, JsonValue)]) = collectList[(String, JsonValue), R] {
|
|
299
|
+
def buildDict[R](){ body: => R / JsonObjectBuilder }: (R, List[(String, JsonValue)]) = returning::collectList[(String, JsonValue), R] {
|
|
300
300
|
try body() with JsonObjectBuilder {
|
|
301
301
|
def field(k) = resume { {v} =>
|
|
302
302
|
val x = build{v}
|
|
@@ -315,10 +315,12 @@ namespace test {
|
|
|
315
315
|
|
|
316
316
|
// Read quoted string
|
|
317
317
|
feed("\"\ta\n\ra\"") {
|
|
318
|
-
with scanner[Char
|
|
318
|
+
with scanner[Char]
|
|
319
319
|
println(collectString { readQuotedString() })
|
|
320
320
|
}
|
|
321
321
|
|
|
322
|
+
println("")
|
|
323
|
+
|
|
322
324
|
// Parse example
|
|
323
325
|
feed("""{ "a": null, "b": [true,false,false,true], "f": 12.532 }"""){
|
|
324
326
|
with scanner[Char]
|
|
@@ -336,8 +338,10 @@ namespace test {
|
|
|
336
338
|
}
|
|
337
339
|
handleJsonBuilder{d}{ decodeJson() }
|
|
338
340
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
+
|
|
342
|
+
println("")
|
|
343
|
+
|
|
344
|
+
try {
|
|
341
345
|
// Encode example
|
|
342
346
|
encodeJson {
|
|
343
347
|
do dict{
|
|
@@ -352,13 +356,15 @@ namespace test {
|
|
|
352
356
|
}
|
|
353
357
|
}
|
|
354
358
|
}
|
|
355
|
-
|
|
359
|
+
|
|
360
|
+
println("")
|
|
361
|
+
|
|
356
362
|
// format with intermediate value
|
|
357
|
-
val j = feed("""{
|
|
358
|
-
"a": null,
|
|
359
|
-
"b": [true, false, false, true], "f": 12.532
|
|
363
|
+
val j = feed[JsonValue]("""{
|
|
364
|
+
"a": null,
|
|
365
|
+
"b": [true, false, false, true], "f": 12.532
|
|
360
366
|
} """){
|
|
361
|
-
with scanner[Char, JsonValue]
|
|
367
|
+
with returning::scanner[Char, JsonValue]
|
|
362
368
|
build {
|
|
363
369
|
decodeJson()
|
|
364
370
|
}.second
|
|
@@ -366,18 +372,20 @@ namespace test {
|
|
|
366
372
|
encodeJson{
|
|
367
373
|
unbuild(j)
|
|
368
374
|
}
|
|
369
|
-
|
|
375
|
+
|
|
376
|
+
println("")
|
|
377
|
+
|
|
370
378
|
// format (minify) example
|
|
371
379
|
encodeJson{
|
|
372
|
-
feed("""{
|
|
373
|
-
"a": null,
|
|
374
|
-
"b": [true, false, false, true], "f": 12.532
|
|
380
|
+
feed("""{
|
|
381
|
+
"a": null,
|
|
382
|
+
"b": [true, false, false, true], "f": 12.532
|
|
375
383
|
} """){
|
|
376
|
-
with scanner[Char
|
|
384
|
+
with scanner[Char]
|
|
377
385
|
decodeJson()
|
|
378
386
|
}
|
|
379
387
|
}
|
|
380
|
-
|
|
388
|
+
|
|
381
389
|
} with emit[String] { e =>
|
|
382
390
|
resume(println(e))
|
|
383
391
|
}
|