[#24] New language: Tabloid

This commit is contained in:
Radon Rosborough 2020-09-26 07:19:07 -07:00
parent 8222937a06
commit 28029e045d
3 changed files with 39 additions and 0 deletions

View File

@ -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",

View File

@ -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

View File

@ -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