From 548c1c11621c1680cdcd13b61cc2db4041e7c259 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Mon, 8 Jun 2020 12:24:58 -0600 Subject: [PATCH] repl.it superiority!! --- backend/src/langs.ts | 72 +++++++++++++++++++++++++++++++++ scripts/docker-install.bash | 81 ++++++++++++++++++++++++++++++++++++- 2 files changed, 152 insertions(+), 1 deletion(-) diff --git a/backend/src/langs.ts b/backend/src/langs.ts index ec50166..4061f60 100644 --- a/backend/src/langs.ts +++ b/backend/src/langs.ts @@ -21,6 +21,51 @@ export const langs: { [key: string]: LangConfig } = { main: "main.bash", run: "bash --rcfile main.bash", template: `echo "Hello, world!" +`, + }, + basic: { + name: "BASIC", + monacoLang: "plaintext", + repl: "bwbasic", + main: "main.bas", + run: "bwbasic main.bas", + template: `PRINT "Hello, world!" +`, + }, + brainf: { + name: "Brainf***", + monacoLang: "plaintext", + repl: "brainf-repl", + main: "main.bf", + run: "brainf-repl main.bf", + template: `++++++++ +[ + >++++ + [ + >++ + >+++ + >+++ + >+ + <<<<- + ] + >+ + >+ + >- + >>+ + [<] + + <- +] + +>>. +>---. ++++++++..+++. +>>. +<-. +<. ++++.------.--------. +>>+. +>++. `, }, c: { @@ -143,6 +188,15 @@ main() -> main: "main.fish", run: 'fish -C "$(< main.fish)"', template: `echo "Hello, world!" +`, + }, + forth: { + name: "Forth", + monacoLang: "plaintext", + repl: "gforth", + main: "main.fs", + run: "gforth main.fs", + template: `." Hello, world!" CR `, }, fsharp: { @@ -211,6 +265,16 @@ main = putStrLn "Hello, world!" main: "main.kts", run: "kotlinc -script main.kts; kotlinc", template: `println("Hello, world!") +`, + }, + lolcode: { + name: "LOLCODE", + monacoLang: "plaintext", + main: "main.lol", + run: "lci main.lol", + template: `HAI 1.2 + VISIBLE "Hello, world!" +KTHXBYE `, }, lua: { @@ -346,6 +410,14 @@ binding_irb.run(IRB.conf) template: `console.log("Hello, world!"); `, }, + unlambda: { + name: "Unlambda", + monacoLang: "plaintext", + repl: "unlambda-repl", + main: "main.unl", + run: "unlambda-repl main.unl", + template: "`.\n`.!`.d`.l`.r`.o`.w`. `.,`.o`.l`.l`.e`.Hi\n", + }, vim: { name: "Vimscript", monacoLang: "plaintext", diff --git a/scripts/docker-install.bash b/scripts/docker-install.bash index 43bcd4a..9087e1c 100755 --- a/scripts/docker-install.bash +++ b/scripts/docker-install.bash @@ -42,7 +42,6 @@ bash git make nodejs -npm yarn # Handy utilities @@ -60,9 +59,15 @@ tmux vim wget +# BASIC +bwbasic + # Bash bash +# BrainF +beef + # C/C++ clang @@ -93,6 +98,9 @@ fsharp # Fish fish +# Forth +gforth + # Go golang @@ -106,6 +114,9 @@ default-jdk # Julia julia +# LOLCODE +cmake + # Lua lua5.3 @@ -142,6 +153,9 @@ sqlite # Swift libpython2.7 +# Unlambda +unlambda + # Vimscript vim @@ -186,6 +200,71 @@ tar -xf swift-*.tar.gz -C /opt/swift --strip-components=2 ln -s /opt/swift/bin/swiftc /usr/bin/swiftc rm swift-*.tar.gz +# LOLCODE +cd /tmp +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 + +parser = argparse.ArgumentParser() +parser.add_argument("file", nargs="?") +args = parser.parse_args() + +if args.file: + subprocess.run(["beef", args.file]) +while True: + try: + code = input("bf> ") + except KeyboardInterrupt: + print("^C") + continue + except EOFError: + print("^D") + break + with tempfile.NamedTemporaryFile(mode="w") as f: + f.write(code) + f.flush() + subprocess.run(["beef", f.name]) +EOF +chmod +x /usr/bin/brainf-repl + +# 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 + subprocess.run(["unlambda"], input=code, encoding="utf-8") +EOF +chmod +x /usr/bin/unlambda-repl + if (( "$uid" != 0 )); then useradd --uid="$uid" --create-home --groups sudo docker passwd -d docker