diff --git a/backend/src/langs.ts b/backend/src/langs.ts index d419488..dfdb03f 100644 --- a/backend/src/langs.ts +++ b/backend/src/langs.ts @@ -2385,6 +2385,15 @@ END `, skip: ["lsp"], }, + tabloid: { + name: "Tabloid", + main: "main.tabloid", + run: "node /opt/tabloid/run.js main.tabloid", + hello: "HELLO, WORLD!", + template: `YOU WON'T WANT TO MISS "Hello, world" +PLEASE LIKE AND SUBSCRIBE +`, + }, tcl: { aliases: ["tclsh", "tclshrc"], name: "Tcl", diff --git a/scripts/docker-install-phase6.bash b/scripts/docker-install-phase6.bash index 318d7f0..d415d08 100755 --- a/scripts/docker-install-phase6.bash +++ b/scripts/docker-install-phase6.bash @@ -104,6 +104,15 @@ mv snobol4 /usr/local/bin/snobol4 popd >/dev/null rm -rf snobol4-* +# Tabloid +mkdir /opt/tabloid +pushd /opt/tabloid >/dev/null +wget -nv https://github.com/thesephist/tabloid/raw/master/static/js/lang.js +cat <<"EOF" >> lang.js +module.exports = { tokenize, Parser, Environment }; +EOF +popd >/dev/null + # Thue wget -nv "$(curl -sSL https://catseye.tc/distribution/Thue_distribution | grep -Eo 'https://catseye.tc/distfiles/thue-[^"]+\.zip' | head -n1)" unzip thue-*.zip diff --git a/scripts/docker-install-phase7.bash b/scripts/docker-install-phase7.bash index 3067935..742e467 100755 --- a/scripts/docker-install-phase7.bash +++ b/scripts/docker-install-phase7.bash @@ -216,6 +216,27 @@ if (program !== null) { repl.start({prompt: "قلب> ", eval: (cmd, context, filename, callback) => callback(null, Qlb.execute(cmd))}); EOF +# Tabloid +tee /opt/tabloid/run.js >/dev/null <<"EOF" +const fs = require("fs"); + +const args = process.argv.slice(2); +if (args.length !== 1) { + console.error("usage: run.js FILE"); + process.exit(1); +} + +const lang = require("./lang"); + +const program = fs.readFileSync(args[0], "utf-8"); +const tokens = lang.tokenize(program); +const parser = new lang.Parser(tokens); +const ast = parser.parse(); +const runtime = { print: (s) => console.log(s.toString().toUpperCase() + "!") }; +const env = new lang.Environment(runtime); +env.run(ast); +EOF + # Unlambda tee /usr/local/bin/unlambda-repl >/dev/null <<"EOF" #!/usr/bin/env python3