A lot more languages

This commit is contained in:
Radon Rosborough 2020-06-09 12:58:21 -06:00
parent 1ae424f328
commit c34ccf26e8
2 changed files with 660 additions and 9 deletions

View File

@ -4,16 +4,70 @@ export interface LangConfig {
name: string;
monacoLang: string;
repl?: string;
main?: string;
main: string;
prefix?: string;
suffix?: string;
compile?: string;
run?: string;
template?: string;
run: string;
template: string;
hacks?: "ghci-config"[];
}
export const langs: { [key: string]: LangConfig } = {
ada: {
name: "Ada",
monacoLang: "plaintext",
main: "main.adb",
compile: "x86_64-linux-gnu-gnatmake-9 main.adb",
run: "./main",
template: `with Ada.Text_IO;
procedure Main is
begin
Ada.Text_IO.Put_Line("Hello, world!");
end Main;
`,
},
algol: {
name: "ALGOL 68",
monacoLang: "plaintext",
main: "main.alg",
run: "a68g main.alg",
template: `print(("Hello, world!",new line))
`,
},
arm: {
name: "ARM",
monacoLang: "plaintext",
main: "main.S",
compile: "arm-linux-gnueabihf-gcc main.S -o main -static",
run: "qemu-arm-static main",
template: ` .text
.globl main
main:
mov r7, #4
mov r0, #1
ldr r1, =message
mov r2, #14
swi 0
mov r7, #1
mov r0, #0
swi 0
.data
message:
.string "Hello, world!\\n"
`,
},
ats: {
name: "ATS",
monacoLang: "postiats",
main: "main.dats",
compile: "patscc main.dats -o main",
run: "./main",
template: `val _ = print ("Hello, world!\\n")
implement main0 () = ()
`,
},
bash: {
name: "Bash",
monacoLang: "shell",
@ -30,6 +84,14 @@ export const langs: { [key: string]: LangConfig } = {
main: "main.bas",
run: "bwbasic main.bas",
template: `PRINT "Hello, world!"
`,
},
befunge: {
name: "Befunge",
monacoLang: "plaintext",
main: "main.be",
run: "befunge-repl main.be",
template: `64+"!dlrow ,olleH">:#,_@
`,
},
brainf: {
@ -80,6 +142,24 @@ int main() {
printf("Hello, world!\\n");
return 0;
}
`,
},
cmd: {
name: "Cmd",
monacoLang: "bat",
repl: "wine cmd",
main: "main.bat",
run: `pkill wineserver64; while pgrep wineserver64 >/dev/null; do sleep 0.05; done; wine cmd /k main.bat`,
template: `echo "Hello, world!"
`,
},
commonlisp: {
name: "Common Lisp",
monacoLang: "plaintext",
repl: "rlwrap sbcl",
main: "main.lisp",
run: "rlwrap sbcl --userinit main.lisp",
template: `(format t "Hello, world!")
`,
},
cpp: {
@ -124,6 +204,28 @@ int main() {
main: "main.clj",
run: "clojure -i main.clj -r",
template: `(println "Hello, world!")
`,
},
clojurescript: {
name: "ClojureScript",
monacoLang: "clojure",
repl: "lumo -r",
main: "main.cljs",
run: "lumo -i main.cljs -r",
template: `(println "Hello, world!")
`,
},
cobol: {
name: "COBOL",
monacoLang: "plaintext",
main: "main.cbl",
compile: "cobc -free -x main.cbl -o main",
run: "./main",
template: `IDENTIFICATION DIVISION.
PROGRAM-ID. MAIN.
PROCEDURE DIVISION.
DISPLAY "Hello, world!".
STOP RUN.
`,
},
coffeescript: {
@ -137,6 +239,19 @@ eval.apply(this, [require("fs").readFileSync("main.js", {encoding: "utf-8"})])
require("/usr/lib/node_modules/coffeescript/repl").start()
'`,
template: `console.log "Hello, world!"
`,
},
d: {
name: "D",
monacoLang: "plaintext",
main: "main.d",
compile: "dmd main.d",
run: "./main",
template: `import std.stdio;
void main() {
writeln("Hello, world!");
}
`,
},
dart: {
@ -156,6 +271,18 @@ require("/usr/lib/node_modules/coffeescript/repl").start()
main: "main.exs",
run: "iex main.exs",
template: `IO.puts("Hello, world!")
`,
},
elm: {
name: "Elm",
monacoLang: "plaintext",
repl: "elm repl",
main: "Main.elm",
run: "cp /opt/elm/elm.json elm.json && run-elm Main.elm; elm repl",
template: `module Main exposing (..)
output : String
output = "Hello, world!"
`,
},
elvish: {
@ -187,7 +314,7 @@ require("/usr/lib/node_modules/coffeescript/repl").start()
-export([main/0]).
main() ->
io:fwrite("Hello, world!\n").
io:fwrite("Hello, world!\\n").
`,
},
fish: {
@ -256,6 +383,31 @@ main = putStrLn "Hello, world!"
`,
hacks: ["ghci-config"],
},
intercal: {
name: "INTERCAL",
monacoLang: "plaintext",
main: "main.i",
compile: "ick main.i",
run: "./main",
template: `DO ,1 <- #14
PLEASE DO ,1 SUB #1 <- #238
DO ,1 SUB #2 <- #108
DO ,1 SUB #3 <- #112
DO ,1 SUB #4 <- #0
DO ,1 SUB #5 <- #64
DO ,1 SUB #6 <- #194
DO ,1 SUB #7 <- #48
PLEASE DO ,1 SUB #8 <- #22
DO ,1 SUB #9 <- #248
DO ,1 SUB #10 <- #168
DO ,1 SUB #11 <- #24
DO ,1 SUB #12 <- #16
PLEASE DO ,1 SUB #13 <- #162
DO ,1 SUB #14 <- #52
PLEASE READ OUT ,1
PLEASE GIVE UP
`,
},
java: {
name: "Java",
monacoLang: "java",
@ -276,6 +428,18 @@ main = putStrLn "Hello, world!"
main: "main.jl",
run: "julia -L main.jl",
template: `println("Hello, world!")
`,
},
kalyn: {
name: "Kalyn",
monacoLang: "plaintext",
main: "src-kalyn/Main.kalyn",
compile: "kalyn",
run: "out-kalyn/Main",
template: `(import "/opt/kalyn/Stdlib.kalyn")
(public def main (IO Empty)
(print "Hello, world!\\n"))
`,
},
kotlin: {
@ -313,6 +477,47 @@ KTHXBYE
main: "main.lua",
run: "lua -i main.lua",
template: `print("Hello, world!")
`,
},
malbolge: {
name: "Malbolge",
monacoLang: "plaintext",
main: "main.mb",
run: "malbolge main.mb",
template:
" (=<`#9]~6ZY32Vx/4Rs+0No-&Jk)\"Fh}|Bcy?`=*z]Kw%oG4UUS0/@-ejc(:'8dc\n",
},
mips: {
name: "MIPS",
monacoLang: "mips",
main: "main.S",
compile: "mips64-linux-gnuabi64-gcc main.S -o main -static",
run: "qemu-mips64-static main",
template: ` .text
.global main
main:
li $v0, 5001
li $a0, 1
dla $a1, message
li $a2, 14
syscall
li $v0, 5058
li $a0, 0
syscall
.data
message:
.string "Hello, world!\\n"
`,
},
mumps: {
name: "MUMPS",
monacoLang: "plaintext",
main: "main.m",
run:
"gtm_dist=/usr/lib/x86_64-linux-gnu/fis-gtm/V6.3-007_x86_64 /usr/lib/x86_64-linux-gnu/fis-gtm/V6.3-007_x86_64/utf8/mumps -r main main.m",
template: `main()
write "Hello, world!",!
quit
`,
},
nim: {
@ -351,6 +556,27 @@ int main() {
[pool drain];
return 0;
}
`,
},
octave: {
name: "Octave",
monacoLang: "plaintext",
repl: "octave",
main: "main.m",
run: "octave --persist main.m",
template: `disp("Hello, world!")
`,
},
pascal: {
name: "Pascal",
monacoLang: "pascal",
main: "main.pas",
compile: "fpc main.pas",
run: "./main",
template: `program Main;
begin
writeln('Hello, world!');
end.
`,
},
perl: {
@ -380,6 +606,18 @@ echo "Hello, world!\\n";
main: "main.ps1",
run: "SHELL=/usr/bin/pwsh pwsh -NoExit main.ps1",
template: `Write-Host "Hello, world!"
`,
},
prolog: {
name: "Prolog",
monacoLang: "plaintext",
repl: "prolog",
main: "main.pl",
run: "prolog main.pl",
template: `:- initialization main.
main :-
write("Hello, world!"), nl.
`,
},
python: {
@ -398,6 +636,16 @@ echo "Hello, world!\\n";
main: ".Rprofile",
run: "R --no-save",
template: `print("Hello, world!")
`,
},
racket: {
name: "Racket",
monacoLang: "plaintext",
repl: "racket",
main: "main.rkt",
run: `racket -i -e '(enter! "main.rkt") (display "[ type (enter! \\"main.rkt\\") to access local variables ]\\n")'`,
template: `#lang racket/base
(display "Hello, world!\\n")
`,
},
reasonml: {
@ -407,6 +655,28 @@ echo "Hello, world!\\n";
compile: "bsc main.re > main.js",
run: "NODE_PATH=/usr/lib/node_modules node main.js",
template: `print_string("Hello, world!\\n")
`,
},
riscv: {
name: "RISC-V",
monacoLang: "plaintext",
main: "main.S",
compile: "riscv64-linux-gnu-gcc main.S -o main -static",
run: "qemu-riscv64-static main",
template: ` .text
.global main
main:
addi a7, x0, 64
addi a0, x0, 1
la a1, message
addi a2, x0, 14
ecall
addi a7, x0, 93
addi a0, x0, 0
ecall
.data
message:
.string "Hello, world!\\n"
`,
},
ruby: {
@ -463,6 +733,123 @@ binding_irb.run(IRB.conf)
main: ".profile",
run: "SHELL=/usr/bin/sh HOME=. posh -l",
template: `echo "Hello, world!"
`,
},
shakespeare: {
name: "Shakespeare",
monacoLang: "plaintext",
repl: "shakespeare console",
main: "main.spl",
suffix: "\n[A pause]",
run: "shakespeare debug main.spl",
template: `The Infamous Hello World Program.
Romeo, a young man with a remarkable patience.
Juliet, a likewise young woman of remarkable grace.
Ophelia, a remarkable woman much in dispute with Hamlet.
Hamlet, the flatterer of Andersen Insulting A/S.
Act I: Hamlet's insults and flattery.
Scene I: The insulting of Romeo.
[Enter Hamlet and Romeo]
Hamlet:
You lying stupid fatherless big smelly half-witted coward!
You are as stupid as the difference between a handsome rich brave
hero and thyself! Speak your mind!
You are as brave as the sum of your fat little stuffed misused dusty
old rotten codpiece and a beautiful fair warm peaceful sunny summer's
day. You are as healthy as the difference between the sum of the
sweetest reddest rose and my father and yourself! Speak your mind!
You are as cowardly as the sum of yourself and the difference
between a big mighty proud kingdom and a horse. Speak your mind.
Speak your mind!
[Exit Romeo]
Scene II: The praising of Juliet.
[Enter Juliet]
Hamlet:
Thou art as sweet as the sum of the sum of Romeo and his horse and his
black cat! Speak thy mind!
[Exit Juliet]
Scene III: The praising of Ophelia.
[Enter Ophelia]
Hamlet:
Thou art as lovely as the product of a large rural town and my amazing
bottomless embroidered purse. Speak thy mind!
Thou art as loving as the product of the bluest clearest sweetest sky
and the sum of a squirrel and a white horse. Thou art as beautiful as
the difference between Juliet and thyself. Speak thy mind!
[Exeunt Ophelia and Hamlet]
Act II: Behind Hamlet's back.
Scene I: Romeo and Juliet's conversation.
[Enter Romeo and Juliet]
Romeo:
Speak your mind. You are as worried as the sum of yourself and the
difference between my small smooth hamster and my nose. Speak your
mind!
Juliet:
Speak YOUR mind! You are as bad as Hamlet! You are as small as the
difference between the square of the difference between my little pony
and your big hairy hound and the cube of your sorry little
codpiece. Speak your mind!
[Exit Romeo]
Scene II: Juliet and Ophelia's conversation.
[Enter Ophelia]
Juliet:
Thou art as good as the quotient between Romeo and the sum of a small
furry animal and a leech. Speak your mind!
Ophelia:
Thou art as disgusting as the quotient between Romeo and twice the
difference between a mistletoe and an oozing infected blister! Speak
your mind!
[Exeunt]
`,
},
smalltalk: {
name: "Smalltalk",
monacoLang: "plaintext",
repl: "gst",
main: "main.st",
run: "gst main.st; gst",
template: `'Hello, world!' displayNl !
`,
},
snobol: {
name: "SNOBOL",
monacoLang: "plaintext",
repl: "snobol4",
main: "main.sno",
run: "snobol4 main.sno; snobol4",
template: ` OUTPUT = "Hello, world!"
END
`,
},
sqlite: {
@ -472,6 +859,15 @@ binding_irb.run(IRB.conf)
main: "main.sql",
run: `sqlite3 -cmd "$(< main.sql)"`,
template: `SELECT "Hello, world!"
`,
},
standardml: {
name: "Standard ML",
monacoLang: "plaintext",
repl: "rlwrap sml",
main: "main.sml",
run: "rlwrap sml main.sml",
template: `print "Hello, world!\\n";
`,
},
swift: {
@ -525,6 +921,57 @@ binding_irb.run(IRB.conf)
main: "main.vim",
run: `vim -c "$(< main.vim)"`,
template: `:echo "Hello, world!"
`,
},
visualbasic: {
name: "Visual Basic",
monacoLang: "vb",
main: "main.vb",
compile: "vbnc main.vb",
run: "mono main.exe",
template: `Module Main
Sub Main(args As String())
Console.WriteLine("Hello, world!")
End Sub
End Module
`,
},
whitespace: {
name: "Whitespace",
monacoLang: "plaintext",
main: "main.ws",
run: "whitespace main.ws",
template: `Hello, world! \t \t \n\t\n \t\t \t \t\n\t\n \t\t \t\t \n\t\n \t\t \t\t \n\t\n \t\t \t\t\t\t\n\t\n \t \t\t \n\t\n \t \n\t\n \t\t\t \t\t\t\n\t\n \t\t \t\t\t\t\n\t\n \t\t\t \t \n\t\n \t\t \t\t \n\t\n \t\t \t \n\t\n \n\n\n`,
},
wolframlanguage: {
name: "Wolfram Language",
monacoLang: "plaintext",
repl: "mathics",
main: "main.wls",
run: "mathics --persist main.wls",
template: `Print["Hello, world!"]
`,
},
x86: {
name: "x86",
monacoLang: "plaintext",
main: "main.S",
compile: "clang main.S -o main",
run: "./main",
template: ` .text
.globl main
main:
movq $1, %rax
movq $1, %rdi
leaq message(%rip), %rsi
movq $14, %rdx
syscall
movq $60, %rax
movq $0, %rdi
syscall
.data
message:
.string "Hello, world!\\n"
`,
},
zsh: {

View File

@ -10,9 +10,11 @@ fi
uid="$1"
dpkg --add-architecture i386
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y apt-transport-https curl gnupg lsb-release wget
apt-get install -y apt-transport-https curl gnupg lsb-release software-properties-common wget
rm -rf /var/lib/apt/lists/*
curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
@ -35,6 +37,8 @@ deb https://dl.yarnpkg.com/debian/ stable main
deb-src https://deb.nodesource.com/node_14.x focal main
EOF
add-apt-repository -y -n ppa:deadsnakes/ppa
packages="
# Needed for project infrastructure
@ -42,6 +46,7 @@ bash
git
make
nodejs
python3-pip
yarn
# Handy utilities
@ -49,6 +54,7 @@ bsdmainutils
curl
emacs-nox
git
htop
jq
lsof
make
@ -59,6 +65,19 @@ tmux
vim
wget
# Ada
gnat
# Algol
algol68g
# ARM
gcc-arm-linux-gnueabihf
qemu-system-static
# ATS
ats2-lang
# BASIC
bwbasic
@ -77,6 +96,17 @@ mono-mcs
# Clojure
clojure
# Cmd
wine
wine32
# COBOL
gnucobol
# Common Lisp
rlwrap
sbcl
# Crystal
crystal
@ -114,12 +144,18 @@ golang
cabal-install
ghc
# INTERCAL
intercal
# Java
default-jdk
# Julia
julia
# Kalyn
haskell-stack
# Ksh
ksh
@ -129,6 +165,13 @@ cmake
# Lua
lua5.3
# MIPS
gcc-mips64-linux-gnuabi64
qemu-system-static
# MUMPS
fis-gtm
# Nim
nim
@ -140,6 +183,12 @@ yarn
gcc
gnustep-devel
# Octave
octave
# Pascal
fpc
# Perl
perl
perlconsole
@ -147,6 +196,9 @@ perlconsole
# PHP
php
# Prolog
swi-prolog
# Python
python3
python3-pip
@ -155,6 +207,13 @@ python3-venv
# R
r-base
# Racket
racket
# RISC-V
gcc-riscv64-linux-gnu
qemu-system-static
# Ruby
ruby
@ -170,9 +229,19 @@ mit-scheme
# Sh
posh
# Smalltalk
gnu-smalltalk
# SNOBOL
m4
# SQLite
sqlite
# Standard ML
rlwrap
smlnj
# Swift
libpython2.7
@ -188,6 +257,15 @@ unlambda
# Vimscript
vim
# Visual Basic
mono-vbnc
# Wolfram Language
python3.7
# x86
clang
# Zsh
zsh
@ -198,17 +276,37 @@ apt-get update
apt-get install -y $(grep -v "^#" <<< "$packages")
rm -rf /var/lib/apt/lists/*
npm config set unsafe-perm true
# Befunge
npm install -g befunge93 prompt-sync
# ClojureScript
npm install -g lumo-cljs
# CoffeeScript
npm install -g coffeescript
# TypeScript
npm install -g ts-node typescript
# Elm
npm install -g run-elm
# Perl
cpan Devel::REPL
# ReasonML
npm install -g bs-platform
# Perl
cpan Devel::REPL
# Shakespeare
pip3 install shakespearelang
# TypeScript
npm install -g ts-node typescript
# Whitespace
pip3 install whitespace
# Wolfram Language
python3.7 -m pip install install mathics
# Needed for project infrastructure
cd /tmp
@ -216,6 +314,18 @@ wget -nv https://github.com/watchexec/watchexec/releases/download/1.13.1/watchex
dpkg -i watchexec-*.deb
rm watchexec-*.deb
# D
cd /tmp
wget -nv http://downloads.dlang.org/releases/2.x/2.092.0/dmd_2.092.0-0_amd64.deb
# Elm
cd /tmp
wget -nv https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz
gunzip binary-for-linux-64-bit.gz
chmod +x binary-for-linux-64-bit
mv binary-for-linux-64-bit /usr/bin/elm
rm binary-for-linux-64-bit.gz
# Kotlin
cd /tmp
wget -nv https://github.com/JetBrains/kotlin/releases/download/v1.3.72/kotlin-compiler-1.3.72.zip
@ -231,6 +341,16 @@ mkdir /opt/powershell
tar -xf powershell-*.tar.gz -C /opt/powershell
ln -s /opt/powershell/pwsh /usr/bin/pwsh
# SNOBOL
wget -nv ftp://ftp.snobol4.org/snobol/snobol4-2.0.tar.gz
tar -xf snobol4-*.tar.gz
rm snobol4-*.tar.gz
pushd snobol4-*
make || true
mv snobol4 /usr/bin/snobol4
popd
rm -rf snobol4-*
# Swift
cd /tmp
wget -nv https://swift.org/builds/swift-5.2.4-release/ubuntu2004/swift-5.2.4-RELEASE/swift-5.2.4-RELEASE-ubuntu20.04.tar.gz
@ -239,6 +359,17 @@ tar -xf swift-*.tar.gz -C /opt/swift --strip-components=2
ln -s /opt/swift/bin/swiftc /usr/bin/swiftc
rm swift-*.tar.gz
# Kalyn
cd /tmp
git clone https://github.com/raxod502/kalyn
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
rm -rf kalyn
# LOLCODE
cd /tmp
git clone https://github.com/justinmeza/lci.git
@ -247,6 +378,50 @@ python3 install.py --prefix=/usr
popd >/dev/null
rm -rf lci
# Malbolge
cd /tmp
git clone https://github.com/bipinu/malbolge.git
clang malbolge/malbolge.c -o /usr/bin/malbolge
rm -rf malbolge
# ActionScript
tee /usr/bin/amxmlc >/dev/null <<"EOF"
#!/bin/sh
exec /opt/actionscript/bin/amxmlc "$@"
EOF
chmod +x /usr/bin/amxmlc
# 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
# BrainF
tee /usr/bin/brainf-repl >/dev/null <<"EOF"
#!/usr/bin/env python3
@ -279,6 +454,35 @@ while True:
EOF
chmod +x /usr/bin/brainf-repl
# 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
# Unlambda
tee /usr/bin/unlambda-repl >/dev/null <<"EOF"
#!/usr/bin/env python3