From 76eab72b8105a4d07fa5e411d37f4bf4efabb21b Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Sun, 19 Jul 2020 09:39:25 -0600 Subject: [PATCH] New language: Qalb (and swap phases 6&7) --- backend/src/langs.ts | 9 ++ scripts/docker-install-phase6.bash | 221 ++++++++------------------ scripts/docker-install-phase7.bash | 242 ++++++++++++++++++++++------- 3 files changed, 258 insertions(+), 214 deletions(-) diff --git a/backend/src/langs.ts b/backend/src/langs.ts index 3723a5d..3dde5b7 100644 --- a/backend/src/langs.ts +++ b/backend/src/langs.ts @@ -1256,6 +1256,15 @@ main = do }, }, template: `print("Hello, world!") +`, + }, + قلب: { + aliases: ["qalb"], + name: "قلب", + repl: "node /opt/qalb/repl.js", + main: "main.qalb", + run: "node /opt/qalb/repl.js main.qalb", + template: `(قول "مرحبا يا عالم") `, }, r: { diff --git a/scripts/docker-install-phase6.bash b/scripts/docker-install-phase6.bash index 4efb86b..765d58d 100755 --- a/scripts/docker-install-phase6.bash +++ b/scripts/docker-install-phase6.bash @@ -5,172 +5,83 @@ set -o pipefail set -x pushd /tmp >/dev/null -# PureScript -mkdir project-template -pushd project-template >/dev/null -spago init -C -rm -rf .gitignore test -sed -i 's#, "test/\*\*/\*\.purs"##' spago.dhall -cat <<"EOF" > src/Main.spago -import Prelude - -import Effect (Effect) - -main :: Effect Unit -main = pure unit -EOF -spago build -spago repl < /dev/null -rm -rf src -popd >/dev/null -mkdir /opt/purescript -mv project-template /opt/purescript/ - -# Befunge -tee /usr/bin/befunge-repl >/dev/null <<"EOF" -#!/usr/bin/env -S NODE_PATH=/usr/lib/node_modules node -const fs = require("fs"); - -const Befunge = require("befunge93"); -const prompt = require("prompt-sync")(); - -const befunge = new Befunge(); -befunge.onInput = prompt; -befunge.onOutput = (output) => { - if (typeof output === "string") { - process.stdout.write(output); - } else { - process.stdout.write(output + " "); - } -}; - -const args = process.argv.slice(2); -if (args.length !== 1) { - console.error("usage: befunge-repl FILE"); - process.exit(1); -} - -befunge.run(fs.readFileSync(args[0], { encoding: "utf-8" })).catch((err) => { - console.error(err); - process.exit(1); -}); -EOF -chmod +x /usr/bin/befunge-repl +# Beatnik +git clone https://github.com/catseye/Beatnik.git +sed -i 's#env python#env python2#' Beatnik/script/beatnik.py +mv Beatnik/script/beatnik.py /usr/bin/beatnik +rm -rf Beatnik # Binary Lambda Calculus -tee /usr/bin/binary-to-text >/dev/null <<"EOF" -#!/usr/bin/env python3 +wget -nv https://www.ioccc.org/2012/tromp/tromp.c +clang tromp.c -Wno-everything -DInt=long -DX=8 -DA=500000 -o /usr/bin/tromp +rm tromp.c -import re -import sys +# Erlang +git clone https://github.com/erlang-ls/erlang_ls.git +pushd erlang_ls >/dev/null +make +mv _build/default/bin/erlang_ls /usr/bin/erlang_ls +popd >/dev/null +rm -rf erlang_ls -text = re.sub(r"[^01]", "", sys.stdin.read()) -out = [] +# Hexagony +git clone https://github.com/m-ender/hexagony.git /opt/hexagony -for m in re.finditer(r"([01]{8})", text): - out += chr(int(m.group(0), 2)) +# Kalyn +git clone https://github.com/raxod502/kalyn.git +pushd kalyn >/dev/null +stack build kalyn +mv "$(stack exec which kalyn)" /usr/bin/kalyn +mkdir /opt/kalyn +cp -R src-kalyn/Stdlib src-kalyn/Stdlib.kalyn /opt/kalyn/ +popd >/dev/null +rm -rf kalyn -print("".join(out), end="") -EOF -chmod +x /usr/bin/binary-to-text +# LOLCODE +git clone https://github.com/justinmeza/lci.git +pushd lci >/dev/null +python3 install.py --prefix=/usr +popd >/dev/null +rm -rf lci -# BrainF -tee /usr/bin/brainf-repl >/dev/null <<"EOF" -#!/usr/bin/env python3 -import argparse -import readline -import subprocess -import tempfile +# Malbolge +git clone https://github.com/bipinu/malbolge.git +clang malbolge/malbolge.c -o /usr/bin/malbolge +rm -rf malbolge -parser = argparse.ArgumentParser() -parser.add_argument("file", nargs="?") -args = parser.parse_args() +# Rapira +git clone https://github.com/freeduke33/rerap2.git +pushd rerap2 >/dev/null +make +mv rapira /usr/bin/rapira +popd >/dev/null +rm -rf rerap2 -if args.file: - subprocess.run(["beef", args.file]) -while True: - try: - code = input("bf> ") - except KeyboardInterrupt: - print("^C") - continue - except EOFError: - print("^D") - break - if not code: - continue - with tempfile.NamedTemporaryFile(mode="w") as f: - f.write(code) - f.flush() - subprocess.run(["beef", f.name]) -EOF -chmod +x /usr/bin/brainf-repl +# Qalb +git clone https://github.com/nasser/---.git qalb +pushd qalb >/dev/null +mkdir -p /opt/qalb +mv public/qlb/*.js /opt/qalb/ +popd >/dev/null +rm -rf qalb -# Elm -mkdir /opt/elm -tee /opt/elm/elm.json >/dev/null <<"EOF" -{ - "type": "application", - "source-directories": [ - "." - ], - "elm-version": "0.19.1", - "dependencies": { - "direct": { - "elm/browser": "1.0.2", - "elm/core": "1.0.5", - "elm/html": "1.0.0" - }, - "indirect": { - "elm/json": "1.1.3", - "elm/time": "1.0.0", - "elm/url": "1.0.0", - "elm/virtual-dom": "1.0.2" - } - }, - "test-dependencies": { - "direct": {}, - "indirect": {} - } -} -EOF +# Thue +wget -nv https://catseye.tc/distfiles/thue-1.5-2015.0827.zip +unzip thue-*.zip +rm thue-*.zip +pushd thue-* >/dev/null +./build.sh +mv bin/thue /usr/bin/thue +popd >/dev/null +rm -rf thue-* -# Haskell -mkdir -p /opt/haskell -tee /opt/haskell/hie.yaml >/dev/null <<"EOF" -cradle: - direct: - arguments: [] -EOF - -# Unlambda -tee /usr/bin/unlambda-repl >/dev/null <<"EOF" -#!/usr/bin/env python3 -import argparse -import readline -import subprocess - -parser = argparse.ArgumentParser() -parser.add_argument("file", nargs="?") -args = parser.parse_args() - -if args.file: - with open(args.file) as f: - subprocess.run(["unlambda"], input=f.read(), encoding="utf-8") -while True: - try: - code = input("λ> ") - except KeyboardInterrupt: - print("^C") - continue - except EOFError: - print("^D") - break - if not code: - continue - subprocess.run(["unlambda"], input=code, encoding="utf-8") -EOF -chmod +x /usr/bin/unlambda-repl +# Zot +git clone https://github.com/manyoso/zot.git +pushd zot >/dev/null +./build.sh +mv build/bin/zot /usr/bin/zot +popd >/dev/null +rm -rf zot popd >/dev/null rm "$0" diff --git a/scripts/docker-install-phase7.bash b/scripts/docker-install-phase7.bash index a6e21cc..ce49026 100755 --- a/scripts/docker-install-phase7.bash +++ b/scripts/docker-install-phase7.bash @@ -5,75 +5,199 @@ set -o pipefail set -x pushd /tmp >/dev/null -# Beatnik -git clone https://github.com/catseye/Beatnik.git -sed -i 's#env python#env python2#' Beatnik/script/beatnik.py -mv Beatnik/script/beatnik.py /usr/bin/beatnik -rm -rf Beatnik +# PureScript +mkdir project-template +pushd project-template >/dev/null +spago init -C +rm -rf .gitignore test +sed -i 's#, "test/\*\*/\*\.purs"##' spago.dhall +cat <<"EOF" > src/Main.spago +import Prelude + +import Effect (Effect) + +main :: Effect Unit +main = pure unit +EOF +spago build +spago repl < /dev/null +rm -rf src +popd >/dev/null +mkdir /opt/purescript +mv project-template /opt/purescript/ + +# Befunge +tee /usr/bin/befunge-repl >/dev/null <<"EOF" +#!/usr/bin/env -S NODE_PATH=/usr/lib/node_modules node +const fs = require("fs"); + +const Befunge = require("befunge93"); +const prompt = require("prompt-sync")(); + +const befunge = new Befunge(); +befunge.onInput = prompt; +befunge.onOutput = (output) => { + if (typeof output === "string") { + process.stdout.write(output); + } else { + process.stdout.write(output + " "); + } +}; + +const args = process.argv.slice(2); +if (args.length !== 1) { + console.error("usage: befunge-repl FILE"); + process.exit(1); +} + +befunge.run(fs.readFileSync(args[0], { encoding: "utf-8" })).catch((err) => { + console.error(err); + process.exit(1); +}); +EOF +chmod +x /usr/bin/befunge-repl # Binary Lambda Calculus -wget -nv https://www.ioccc.org/2012/tromp/tromp.c -clang tromp.c -Wno-everything -DInt=long -DX=8 -DA=500000 -o /usr/bin/tromp -rm tromp.c +tee /usr/bin/binary-to-text >/dev/null <<"EOF" +#!/usr/bin/env python3 -# Erlang -git clone https://github.com/erlang-ls/erlang_ls.git -pushd erlang_ls >/dev/null -make -mv _build/default/bin/erlang_ls /usr/bin/erlang_ls -popd >/dev/null -rm -rf erlang_ls +import re +import sys -# Hexagony -git clone https://github.com/m-ender/hexagony.git /opt/hexagony +text = re.sub(r"[^01]", "", sys.stdin.read()) +out = [] -# Kalyn -git clone https://github.com/raxod502/kalyn.git -pushd kalyn >/dev/null -stack build kalyn -mv "$(stack exec which kalyn)" /usr/bin/kalyn -mkdir /opt/kalyn -cp -R src-kalyn/Stdlib src-kalyn/Stdlib.kalyn /opt/kalyn/ -popd >/dev/null -rm -rf kalyn +for m in re.finditer(r"([01]{8})", text): + out += chr(int(m.group(0), 2)) -# LOLCODE -git clone https://github.com/justinmeza/lci.git -pushd lci >/dev/null -python3 install.py --prefix=/usr -popd >/dev/null -rm -rf lci +print("".join(out), end="") +EOF +chmod +x /usr/bin/binary-to-text -# Malbolge -git clone https://github.com/bipinu/malbolge.git -clang malbolge/malbolge.c -o /usr/bin/malbolge -rm -rf malbolge +# BrainF +tee /usr/bin/brainf-repl >/dev/null <<"EOF" +#!/usr/bin/env python3 +import argparse +import readline +import subprocess +import tempfile -# Rapira -git clone https://github.com/freeduke33/rerap2.git -pushd rerap2 >/dev/null -make -mv rapira /usr/bin/rapira -popd >/dev/null -rm -rf rerap2 +parser = argparse.ArgumentParser() +parser.add_argument("file", nargs="?") +args = parser.parse_args() -# Thue -wget -nv https://catseye.tc/distfiles/thue-1.5-2015.0827.zip -unzip thue-*.zip -rm thue-*.zip -pushd thue-* >/dev/null -./build.sh -mv bin/thue /usr/bin/thue -popd >/dev/null -rm -rf thue-* +if args.file: + subprocess.run(["beef", args.file]) +while True: + try: + code = input("bf> ") + except KeyboardInterrupt: + print("^C") + continue + except EOFError: + print("^D") + break + if not code: + continue + with tempfile.NamedTemporaryFile(mode="w") as f: + f.write(code) + f.flush() + subprocess.run(["beef", f.name]) +EOF +chmod +x /usr/bin/brainf-repl -# Zot -git clone https://github.com/manyoso/zot.git -pushd zot >/dev/null -./build.sh -mv build/bin/zot /usr/bin/zot -popd >/dev/null -rm -rf zot +# Elm +mkdir /opt/elm +tee /opt/elm/elm.json >/dev/null <<"EOF" +{ + "type": "application", + "source-directories": [ + "." + ], + "elm-version": "0.19.1", + "dependencies": { + "direct": { + "elm/browser": "1.0.2", + "elm/core": "1.0.5", + "elm/html": "1.0.0" + }, + "indirect": { + "elm/json": "1.1.3", + "elm/time": "1.0.0", + "elm/url": "1.0.0", + "elm/virtual-dom": "1.0.2" + } + }, + "test-dependencies": { + "direct": {}, + "indirect": {} + } +} +EOF + +# Haskell +mkdir -p /opt/haskell +tee /opt/haskell/hie.yaml >/dev/null <<"EOF" +cradle: + direct: + arguments: [] +EOF + +# Qalb +mkdir -p /opt/qalb +tee /opt/qalb/repl.js >/dev/null <<"EOF" +const fs = require("fs"); +const repl = require("repl"); + +const args = process.argv.slice(2); +if (args.length > 1) { + console.error("usage: repl.js [FILE]"); + process.exit(1); +} + +const program = args.length === 1 ? fs.readFileSync(args[0]) : null; + +eval(fs.readFileSync("public/qlb/qlb.js", "utf-8")); +eval(fs.readFileSync("public/qlb/parser.js", "utf-8")); +eval(fs.readFileSync("public/qlb/primitives.js", "utf-8")); + +Qlb.init({console}); + +if (program !== null) { + Qlb.execute(program); +} + +repl.start({prompt: "قلب> ", eval: (cmd, context, filename, callback) => callback(null, Qlb.execute(cmd))}); +EOF + +# Unlambda +tee /usr/bin/unlambda-repl >/dev/null <<"EOF" +#!/usr/bin/env python3 +import argparse +import readline +import subprocess + +parser = argparse.ArgumentParser() +parser.add_argument("file", nargs="?") +args = parser.parse_args() + +if args.file: + with open(args.file) as f: + subprocess.run(["unlambda"], input=f.read(), encoding="utf-8") +while True: + try: + code = input("λ> ") + except KeyboardInterrupt: + print("^C") + continue + except EOFError: + print("^D") + break + if not code: + continue + subprocess.run(["unlambda"], input=code, encoding="utf-8") +EOF +chmod +x /usr/bin/unlambda-repl popd >/dev/null rm "$0"