Skip to content

Commit 269ff68

Browse files
committed
Add initial Nim support
Still needs syntax highlighting and a new version build from source but it works, which is a start :-) Updates #86
1 parent 0fc53fd commit 269ff68

File tree

11 files changed

+33
-12
lines changed

11 files changed

+33
-12
lines changed

assets/common.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ tr.me { background: #5cf }
205205
.julia { background: svg(julia#000) center right 7px / 26px no-repeat }
206206
.lisp { background: svg(lisp#000) center right 7px / 26px no-repeat }
207207
.lua { background: svg(lua#000) center right 7px / 26px no-repeat }
208+
.nim { background: svg(nim#000) center right 7px / 26px no-repeat }
208209
.perl { background: svg(perl#000) center right 7px / 26px no-repeat }
209210
.perl6 { background: svg(perl6#000) center right 7px / 26px no-repeat }
210211
.php { background: svg(php#000) center right 7px / 26px no-repeat }

assets/hole.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ main nav a:nth-child(3):before {
258258
#tabs {
259259
clear: both;
260260
display: grid;
261-
grid-template-columns: repeat(14, 1fr);
261+
grid-template-columns: repeat(15, 1fr);
262262
position: relative;
263263
-moz-user-select: none;
264264
-ms-user-select: none;
@@ -295,6 +295,7 @@ main nav a:nth-child(3):before {
295295
#tabs a[href="#julia"] { background-image: svg(julia#fff) }
296296
#tabs a[href="#lisp"] { background-image: svg(lisp#fff) }
297297
#tabs a[href="#lua"] { background-image: svg(lua#fff) }
298+
#tabs a[href="#nim"] { background-image: svg(nim#fff) }
298299
#tabs a[href="#perl"] { background-image: svg(perl#fff) }
299300
#tabs a[href="#perl6"] { background-image: svg(perl6#fff) }
300301
#tabs a[href="#php"] { background-image: svg(php#fff) }
@@ -303,4 +304,4 @@ main nav a:nth-child(3):before {
303304

304305
@keyframes spin { 100% { transform: rotate(1turn) } }
305306

306-
@media(max-width: 450px) { #tabs { grid-template-columns: repeat(7, 1fr) } }
307+
@media(max-width: 500px) { #tabs { grid-template-columns: repeat(5, 1fr) } }

assets/hole.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ onload = function() {
5050
let editors = [];
5151

5252
for (let langName of [
53-
'Bash', 'Brainfuck', 'C', 'Haskell', 'J', 'JavaScript', 'Julia', 'Lisp', 'Lua',
54-
'Perl', 'Perl 6', 'PHP', 'Python', 'Ruby',
53+
'Bash', 'Brainfuck', 'C', 'Haskell', 'J', 'JavaScript', 'Julia',
54+
'Lisp', 'Lua', 'Nim', 'Perl', 'Perl 6', 'PHP', 'Python', 'Ruby',
5555
]) {
5656
let lang = langName.replace(/ /, '').toLowerCase();
5757

@@ -94,7 +94,7 @@ onload = function() {
9494

9595
( onhashchange = function() {
9696
// Kick 'em to Perl 6 if we don't know the chosen language.
97-
if (!/^#(?:bash|brainfuck|c|haskell|j|javascript|julia|lisp|lua|perl6?|php|python|ruby)$/.exec(location.hash))
97+
if (!/^#(?:bash|brainfuck|c|haskell|j|javascript|julia|lisp|lua|nim|perl6?|php|python|ruby)$/.exec(location.hash))
9898
location.hash = 'perl6';
9999

100100
let lang = location.hash.slice(1);

assets/includes/nim.svg

Lines changed: 1 addition & 0 deletions
Loading

assets/user.css

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,12 @@ tr {
109109
#matrix tr:first-child th:nth-child(8) { background-image: svg(julia#222) }
110110
#matrix tr:first-child th:nth-child(9) { background-image: svg(lisp#222) }
111111
#matrix tr:first-child th:nth-child(10) { background-image: svg(lua#222) }
112-
#matrix tr:first-child th:nth-child(11) { background-image: svg(perl#222) }
113-
#matrix tr:first-child th:nth-child(12) { background-image: svg(perl6#222) }
114-
#matrix tr:first-child th:nth-child(13) { background-image: svg(php#222) }
115-
#matrix tr:first-child th:nth-child(14) { background-image: svg(python#222) }
116-
#matrix tr:first-child th:nth-child(15) { background-image: svg(ruby#222) }
112+
#matrix tr:first-child th:nth-child(11) { background-image: svg(nim#222) }
113+
#matrix tr:first-child th:nth-child(12) { background-image: svg(perl#222) }
114+
#matrix tr:first-child th:nth-child(13) { background-image: svg(perl6#222) }
115+
#matrix tr:first-child th:nth-child(14) { background-image: svg(php#222) }
116+
#matrix tr:first-child th:nth-child(15) { background-image: svg(python#222) }
117+
#matrix tr:first-child th:nth-child(16) { background-image: svg(ruby#222) }
117118

118119
#matrix,
119120
#trophies {

build-langs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ declare -A urls=(
1010
["julia"]="//julialang.org"
1111
["lisp"]="//clisp.sourceforge.io"
1212
["lua"]="//www.lua.org"
13+
["nim"]="//nim-lang.org"
1314
["perl"]="//www.perl.org"
1415
["perl6"]="//perl6.org"
1516
["php"]="//secure.php.net"
@@ -21,7 +22,7 @@ docker pull alpine:edge
2122

2223
cd langs
2324

24-
for name in Bash Brainfuck C Haskell J JavaScript Julia Lisp Lua Perl Perl\ 6 PHP Python Ruby; do
25+
for name in Bash Brainfuck C Haskell J JavaScript Julia Lisp Lua Nim Perl Perl\ 6 PHP Python Ruby; do
2526
lang=${name,,} # lowercase
2627
lang=${lang// /} # trim space
2728

@@ -30,14 +31,16 @@ for name in Bash Brainfuck C Haskell J JavaScript Julia Lisp Lua Perl Perl\ 6 PH
3031
mkdir $lang/rootfs
3132

3233
# Tag the builder stage so "docker system prune" won't remove it.
33-
if [ $lang != haskell ]; then
34+
if [ $lang != haskell -a $lang != nim ]; then
3435
docker build --target builder -t quay.io/jraspass/$lang-builder $lang
3536
fi
3637

3738
docker build -t code-golf-$lang $lang
3839

3940
if [ $lang = j ]; then
4041
ver=`echo echo JLIB | docker run --rm --tmpfs /tmp -i code-golf-j`
42+
elif [ $lang = nim ]; then
43+
ver=`echo echo NimVersion | docker run --rm --tmpfs /tmp -i code-golf-nim`
4144
else
4245
ver=`docker run --rm code-golf-$lang`
4346
fi

db.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ CREATE TYPE public.lang AS ENUM (
7272
'julia',
7373
'lisp',
7474
'lua',
75+
'nim',
7576
'perl',
7677
'perl6',
7778
'php',

langs/nim/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM alpine:edge
2+
3+
RUN apk add -X http://dl-cdn.alpinelinux.org/alpine/edge/testing --no-cache \
4+
musl-dev nim tcc
5+
6+
ENTRYPOINT ["/usr/bin/nim", "--cc:tcc", "--verbosity:0", "-r", "c", "-"]

routes/solution.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ func runCode(hole, lang, code string, args []string, userID int) (string, string
222222
cmd.Args = []string{"/usr/bin/j", "/tmp/code.ijs"}
223223
case "julia":
224224
cmd.Args = []string{"/usr/bin/run-julia", "/tmp/code.jl"}
225+
case "nim":
226+
cmd.Args = []string{
227+
"/usr/bin/nim", "--cc:tcc", "--hint[Processing]:off",
228+
"--nimcache:/tmp", "--verbosity:0", "-o:/tmp/code", "-r", "c", "-",
229+
}
225230
case "perl6":
226231
cmd.Args = []string{
227232
"/usr/bin/moar",

routes/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ var langs = []Lang{
2121
{"julia", "Julia"},
2222
{"lisp", "Lisp"},
2323
{"lua", "Lua"},
24+
{"nim", "Nim"},
2425
{"perl", "Perl"},
2526
{"perl6", "Perl 6"},
2627
{"php", "PHP"},

0 commit comments

Comments
 (0)