New language: Qalb (and swap phases 6&7)

This commit is contained in:
Radon Rosborough 2020-07-19 09:39:25 -06:00
parent 221f09bb2d
commit 76eab72b81
3 changed files with 258 additions and 214 deletions

View File

@ -1256,6 +1256,15 @@ main = do
}, },
}, },
template: `print("Hello, world!") 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: { r: {

View File

@ -5,172 +5,83 @@ set -o pipefail
set -x set -x
pushd /tmp >/dev/null pushd /tmp >/dev/null
# PureScript # Beatnik
mkdir project-template git clone https://github.com/catseye/Beatnik.git
pushd project-template >/dev/null sed -i 's#env python#env python2#' Beatnik/script/beatnik.py
spago init -C mv Beatnik/script/beatnik.py /usr/bin/beatnik
rm -rf .gitignore test rm -rf Beatnik
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 # Binary Lambda Calculus
tee /usr/bin/binary-to-text >/dev/null <<"EOF" wget -nv https://www.ioccc.org/2012/tromp/tromp.c
#!/usr/bin/env python3 clang tromp.c -Wno-everything -DInt=long -DX=8 -DA=500000 -o /usr/bin/tromp
rm tromp.c
import re # Erlang
import sys 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()) # Hexagony
out = [] git clone https://github.com/m-ender/hexagony.git /opt/hexagony
for m in re.finditer(r"([01]{8})", text): # Kalyn
out += chr(int(m.group(0), 2)) 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="") # LOLCODE
EOF git clone https://github.com/justinmeza/lci.git
chmod +x /usr/bin/binary-to-text pushd lci >/dev/null
python3 install.py --prefix=/usr
popd >/dev/null
rm -rf lci
# BrainF # Malbolge
tee /usr/bin/brainf-repl >/dev/null <<"EOF" git clone https://github.com/bipinu/malbolge.git
#!/usr/bin/env python3 clang malbolge/malbolge.c -o /usr/bin/malbolge
import argparse rm -rf malbolge
import readline
import subprocess
import tempfile
parser = argparse.ArgumentParser() # Rapira
parser.add_argument("file", nargs="?") git clone https://github.com/freeduke33/rerap2.git
args = parser.parse_args() pushd rerap2 >/dev/null
make
mv rapira /usr/bin/rapira
popd >/dev/null
rm -rf rerap2
if args.file: # Qalb
subprocess.run(["beef", args.file]) git clone https://github.com/nasser/---.git qalb
while True: pushd qalb >/dev/null
try: mkdir -p /opt/qalb
code = input("bf> ") mv public/qlb/*.js /opt/qalb/
except KeyboardInterrupt: popd >/dev/null
print("^C") rm -rf qalb
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
# Elm # Thue
mkdir /opt/elm wget -nv https://catseye.tc/distfiles/thue-1.5-2015.0827.zip
tee /opt/elm/elm.json >/dev/null <<"EOF" unzip thue-*.zip
{ rm thue-*.zip
"type": "application", pushd thue-* >/dev/null
"source-directories": [ ./build.sh
"." mv bin/thue /usr/bin/thue
], popd >/dev/null
"elm-version": "0.19.1", rm -rf thue-*
"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 # Zot
mkdir -p /opt/haskell git clone https://github.com/manyoso/zot.git
tee /opt/haskell/hie.yaml >/dev/null <<"EOF" pushd zot >/dev/null
cradle: ./build.sh
direct: mv build/bin/zot /usr/bin/zot
arguments: [] popd >/dev/null
EOF rm -rf zot
# 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 popd >/dev/null
rm "$0" rm "$0"

View File

@ -5,75 +5,199 @@ set -o pipefail
set -x set -x
pushd /tmp >/dev/null pushd /tmp >/dev/null
# Beatnik # PureScript
git clone https://github.com/catseye/Beatnik.git mkdir project-template
sed -i 's#env python#env python2#' Beatnik/script/beatnik.py pushd project-template >/dev/null
mv Beatnik/script/beatnik.py /usr/bin/beatnik spago init -C
rm -rf Beatnik 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 # Binary Lambda Calculus
wget -nv https://www.ioccc.org/2012/tromp/tromp.c tee /usr/bin/binary-to-text >/dev/null <<"EOF"
clang tromp.c -Wno-everything -DInt=long -DX=8 -DA=500000 -o /usr/bin/tromp #!/usr/bin/env python3
rm tromp.c
# Erlang import re
git clone https://github.com/erlang-ls/erlang_ls.git import sys
pushd erlang_ls >/dev/null
make
mv _build/default/bin/erlang_ls /usr/bin/erlang_ls
popd >/dev/null
rm -rf erlang_ls
# Hexagony text = re.sub(r"[^01]", "", sys.stdin.read())
git clone https://github.com/m-ender/hexagony.git /opt/hexagony out = []
# Kalyn for m in re.finditer(r"([01]{8})", text):
git clone https://github.com/raxod502/kalyn.git out += chr(int(m.group(0), 2))
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
# LOLCODE print("".join(out), end="")
git clone https://github.com/justinmeza/lci.git EOF
pushd lci >/dev/null chmod +x /usr/bin/binary-to-text
python3 install.py --prefix=/usr
popd >/dev/null
rm -rf lci
# Malbolge # BrainF
git clone https://github.com/bipinu/malbolge.git tee /usr/bin/brainf-repl >/dev/null <<"EOF"
clang malbolge/malbolge.c -o /usr/bin/malbolge #!/usr/bin/env python3
rm -rf malbolge import argparse
import readline
import subprocess
import tempfile
# Rapira parser = argparse.ArgumentParser()
git clone https://github.com/freeduke33/rerap2.git parser.add_argument("file", nargs="?")
pushd rerap2 >/dev/null args = parser.parse_args()
make
mv rapira /usr/bin/rapira
popd >/dev/null
rm -rf rerap2
# Thue if args.file:
wget -nv https://catseye.tc/distfiles/thue-1.5-2015.0827.zip subprocess.run(["beef", args.file])
unzip thue-*.zip while True:
rm thue-*.zip try:
pushd thue-* >/dev/null code = input("bf> ")
./build.sh except KeyboardInterrupt:
mv bin/thue /usr/bin/thue print("^C")
popd >/dev/null continue
rm -rf thue-* 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 # Elm
git clone https://github.com/manyoso/zot.git mkdir /opt/elm
pushd zot >/dev/null tee /opt/elm/elm.json >/dev/null <<"EOF"
./build.sh {
mv build/bin/zot /usr/bin/zot "type": "application",
popd >/dev/null "source-directories": [
rm -rf zot "."
],
"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 popd >/dev/null
rm "$0" rm "$0"