This commit is contained in:
2026-06-29 15:56:30 +02:00
commit 6fe57399c4
152 changed files with 32122 additions and 0 deletions
+77
View File
@@ -0,0 +1,77 @@
import * as $json from "../gleam_json/gleam/json.mjs";
import * as $int from "../gleam_stdlib/gleam/int.mjs";
import * as $io from "../gleam_stdlib/gleam/io.mjs";
import * as $list from "../gleam_stdlib/gleam/list.mjs";
import * as $definition from "./definition.mjs";
import { toList } from "./gleam.mjs";
import * as $mode from "./mode.mjs";
import * as $parser from "./parser.mjs";
function inline_to_json(inline) {
if (inline instanceof $definition.Text) {
let text = inline[0];
return $json.object(
toList([["type", $json.string("text")], ["value", $json.string(text)]]),
);
} else if (inline instanceof $definition.Push) {
let feeling = inline[0];
if (feeling instanceof $definition.Hirachy) {
let level = feeling[0];
return $json.object(
toList([["type", $json.string("hirachy")], ["value", $json.int(level)]]),
);
} else if (feeling instanceof $definition.Truth) {
let level = feeling[0];
return $json.object(
toList([["type", $json.string("truth")], ["value", $json.int(level)]]),
);
} else if (feeling instanceof $definition.Marking) {
let level = feeling[0];
return $json.object(
toList([["type", $json.string("marking")], ["value", $json.int(level)]]),
);
} else {
let level = feeling[0];
return $json.object(
toList([["type", $json.string("quote")], ["value", $json.int(level)]]),
);
}
} else {
let text = inline[0];
return $json.object(
toList([
["type", $json.string("pop")],
[
"value",
(() => {
if (text instanceof $mode.Hirachy) {
return $json.string("Hirachy");
} else if (text instanceof $mode.Truth) {
return $json.string("Truth");
} else if (text instanceof $mode.Marking) {
return $json.string("Marking");
} else {
return $json.string("Quote");
}
})(),
],
]),
);
}
}
function line_to_json(line) {
let inlines = line[0];
let _pipe = $json.array(inlines, inline_to_json);
return $json.to_string(_pipe);
}
export function main() {
let input = "ljiosfgdjiosdfgj\n @2! A slightly important statement !1 I believe is wrong, !- quoted inside another quote.\n !3 A slightly important statement I believe is wrong, quoted inside another quote.\n #3!2@2 A slightly important statement I believe is wrong, quoted inside another quote.\n\n !2@3 important trusted but @- important !5 more important !- 2 important and !- normal";
$io.print(line_to_json($parser.handler(input)));
return undefined;
}
export function testing(input) {
return line_to_json($parser.handler(input));
}