Skip to content

Commit

Permalink
miniMAL: update to miniMAL-1.2.2
Browse files Browse the repository at this point in the history
- Update to ubuntu 24.04 Dockerfile and add labels.
- update to working version of ffi-napi
- Remove from miniMAL-core.json the things that overlap with the builtin
  core functionality that miniMAL now provides in 1.2.2.
- Update ARGS variable to argv to align with how 1.2.2 now does command
  line parameters.
  • Loading branch information
kanaka committed Aug 2, 2024
1 parent ef2e1dd commit b0488d5
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 146 deletions.
16 changes: 7 additions & 9 deletions impls/miniMAL/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM ubuntu:18.04
FROM ubuntu:24.04
MAINTAINER Joel Martin <github@martintribe.org>
LABEL org.opencontainers.image.source=https://github.com/kanaka/mal
LABEL org.opencontainers.image.description="mal test container: miniMAL"

##########################################################
# General requirements for testing or common across many
Expand All @@ -9,7 +11,8 @@ MAINTAINER Joel Martin <github@martintribe.org>
RUN apt-get -y update

# Required for running tests
RUN apt-get -y install make python
RUN apt-get -y install make python3
RUN ln -sf /usr/bin/python3 /usr/bin/python

# Some typical implementation and test requirements
RUN apt-get -y install curl libreadline-dev libedit-dev
Expand All @@ -24,14 +27,9 @@ WORKDIR /mal
# For building node modules
RUN apt-get -y install g++

# Add nodesource apt repo config for 10.x stable
RUN apt-get -y install gnupg
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -

# Install nodejs
RUN apt-get -y install nodejs
RUN apt-get -y install nodejs npm

ENV NPM_CONFIG_CACHE /mal/.npm

# install miniMAL
RUN npm install -g minimal-lisp
RUN npm install -g minimal-lisp@1.2.2
10 changes: 8 additions & 2 deletions impls/miniMAL/core.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
["and", ["string?", "s"],
["not", ["=", ["`", "\u029e"], ["get", "s", 0]]]]]],

["def", "_function?", ["fn", ["a"],
["isa", "a", "Function"]]],

["def", "_number?", ["fn", ["a"],
["=", ["`", "[object Number]"], ["classOf", "a"]]]],

["def", "div", ["fn", ["a", "b"], ["parseInt", ["/", "a", "b"]]]],

["def", "time-ms", ["fn", [],
Expand Down Expand Up @@ -121,9 +127,9 @@
["`", "symbol?"], "symbol?",
["`", "keyword"], "keyword",
["`", "keyword?"], "keyword?",
["`", "number?"], "number?",
["`", "number?"], "_number?",
["`", "fn?"], ["fn", ["a"],
["or", ["function?", "a"],
["or", ["_function?", "a"],
["and", ["malfunc?", "a"],
["not", ["get", "a", ["`", "macro?"]]]]]],
["`", "macro?"], ["fn", ["a"],
Expand Down
119 changes: 0 additions & 119 deletions impls/miniMAL/miniMAL-core.json
Original file line number Diff line number Diff line change
@@ -1,124 +1,5 @@
["do",

["def", "new", ["fn", ["a", "&", "b"],
[".", "Reflect", ["`", "construct"], "a", "b"]]],
["def", "del", ["fn", ["a", "b"],
[".", "Reflect", ["`", "deleteProperty"], "a", "b"]]],
["def", "map", ["fn", ["a", "b"],
[".", "b", ["`", "map"], ["fn", ["x"], ["a", "x"]]]]],
["def", "list", ["fn", ["&", "a"], "a"]],
["def", ">=", ["fn", ["a", "b"],
["if", ["<", "a", "b"], false, true]]],
["def", ">", ["fn", ["a", "b"],
["if", [">=", "a", "b"],
["if", ["=", "a", "b"], false, true],
false]]],
["def", "<=", ["fn", ["a", "b"],
["if", [">", "a", "b"], false, true]]],

["def", "classOf", ["fn", ["a"],
[".", [".-", [".-", "Object", ["`", "prototype"]], ["`", "toString"]],
["`", "call"], "a"]]],

["def", "not", ["fn", ["a"], ["if", "a", false, true]]],

["def", "null?", ["fn", ["a"], ["=", null, "a"]]],
["def", "true?", ["fn", ["a"], ["=", true, "a"]]],
["def", "false?", ["fn", ["a"], ["=", false, "a"]]],
["def", "string?", ["fn", ["a"],
["if", ["=", "a", null],
false,
["=", ["`", "String"],
[".-", [".-", "a", ["`", "constructor"]],
["`", "name"]]]]]],
["def", "number?", ["fn", ["a"],
["=", ["`", "[object Number]"], ["classOf", "a"]]]],
["def", "function?", ["fn", ["a"],
["isa", "a", "Function"]]],

["def", "pr-list*", ["fn", ["a", "b", "c"],
[".", ["map", ["fn", ["x"],
["if", "c",
[".", "JSON", ["`", "stringify"], "x"],
["if", ["string?", "x"],
"x",
[".", "JSON", ["`", "stringify"], "x"]]]],
"a"],
["`", "join"], "b"]]],
["def", "pr-str", ["fn", ["&", "a"],
["pr-list*", "a", ["`", " "], true]]],
["def", "str", ["fn", ["&", "a"],
["pr-list*", "a", ["`", ""], false]]],
["def", "prn", ["fn", ["&", "a"],
["do", [".", "console", ["`", "log"],
["pr-list*", "a", ["`", " "], true]], null]]],
["def", "println", ["fn", ["&", "a"],
["do", [".", "console", ["`", "log"],
["pr-list*", "a", ["`", " "], false]], null]]],

["def", "list?", ["fn", ["a"],
[".", "Array", ["`", "isArray"], "a"]]],
["def", "contains?", ["fn", ["a", "b"],
[".", "a", ["`", "hasOwnProperty"], "b"]]],
["def", "get", ["fn", ["a", "b"],
["if", ["contains?", "a", "b"], [".-", "a", "b"], null]]],
["def", "set", ["fn", ["a", "b", "c"],
["do", [".-", "a", "b", "c"], "a"]]],
["def", "keys", ["fn", ["a"],
[".", "Object", ["`", "keys"], "a"]]],
["def", "vals", ["fn", ["a"],
["map",["fn", ["k"], ["get", "a", "k"]], ["keys", "a"]]]],

["def", "cons", ["fn", ["a", "b"],
[".", ["`", []],
["`", "concat"], ["list", "a"], "b"]]],
["def", "concat", ["fn", ["&", "a"],
[".", [".-", ["list"], ["`", "concat"]],
["`", "apply"], ["list"], "a"]]],
["def", "nth", "get"],
["def", "first", ["fn", ["a"],
["if", [">", [".-", "a", ["`", "length"]], 0],
["nth", "a", 0],
null]]],
["def", "last", ["fn", ["a"],
["nth", "a", ["-", [".-", "a", ["`", "length"]], 1]]]],
["def", "count", ["fn", ["a"],
[".-", "a", ["`", "length"]]]],
["def", "empty?", ["fn", ["a"],
["if", ["list?", "a"],
["if", ["=", 0, [".-", "a", ["`", "length"]]], true, false],
["=", "a", null]]]],
["def", "slice", ["fn", ["a", "b", "&", "end"],
[".", "a", ["`", "slice"], "b",
["if", [">", ["count", "end"], 0],
["get", "end", 0],
[".-", "a", ["`", "length"]]]]]],
["def", "rest", ["fn", ["a"], ["slice", "a", 1]]],

["def", "apply", ["fn", ["f", "&", "b"],
[".", "f", ["`", "apply"], "f",
["concat", ["slice", "b", 0, -1], ["last", "b"]]]]],

["def", "and", ["~", ["fn", ["&", "xs"],
["if", ["empty?", "xs"],
true,
["if", ["=", 1, ["count", "xs"]],
["first", "xs"],
["list", ["`", "let"], ["list", ["`", "and_FIXME"], ["first", "xs"]],
["list", ["`", "if"], ["`", "and_FIXME"],
["concat", ["`", ["and"]], ["rest", "xs"]],
["`", "and_FIXME"]]]]]]]],

["def", "or", ["~", ["fn", ["&", "xs"],
["if", ["empty?", "xs"],
null,
["if", ["=", 1, ["count", "xs"]],
["first", "xs"],
["list", ["`", "let"], ["list", ["`", "or_FIXME"], ["first", "xs"]],
["list", ["`", "if"], ["`", "or_FIXME"],
["`", "or_FIXME"],
["concat", ["`", ["or"]], ["rest", "xs"]]]]]]]]],

["def", "repl", ["fn",["prompt", "rep"],
["let", ["readline", ["require", ["`", "readline"]],
"opts", ["new", "Object"],
Expand Down
2 changes: 1 addition & 1 deletion impls/miniMAL/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"description": "Make a Lisp (mal) language implemented in miniMAL",
"dependencies": {
"minimal-lisp": "1.0.2",
"ffi-napi": "2.4.x"
"ffi-napi": "4.0.3"
}
}
6 changes: 3 additions & 3 deletions impls/miniMAL/step6_file.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@
["env-set", "repl-env", ["symbol", ["`", "eval"]],
["fn", ["ast"], ["EVAL", "ast", "repl-env"]]],
["env-set", "repl-env", ["symbol", ["`", "*ARGV*"]],
["slice", "ARGS", 1]],
["slice", "argv", 1]],

["`", "core.mal: defined using mal itself"],
["rep", ["`", "(def! not (fn* (a) (if a false true)))"]],
["rep", ["`", "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"]],

["if", ["not", ["empty?", "ARGS"]],
["rep", ["str", ["`", "(load-file \""], ["get", "ARGS", 0], ["`", "\")"]]],
["if", ["not", ["empty?", "argv"]],
["rep", ["str", ["`", "(load-file \""], ["get", "argv", 0], ["`", "\")"]]],
["repl", ["`", "user> "], "rep"]],

null
Expand Down
6 changes: 3 additions & 3 deletions impls/miniMAL/step7_quote.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@
["env-set", "repl-env", ["symbol", ["`", "eval"]],
["fn", ["ast"], ["EVAL", "ast", "repl-env"]]],
["env-set", "repl-env", ["symbol", ["`", "*ARGV*"]],
["slice", "ARGS", 1]],
["slice", "argv", 1]],

["`", "core.mal: defined using mal itself"],
["rep", ["`", "(def! not (fn* (a) (if a false true)))"]],
["rep", ["`", "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"]],

["if", ["not", ["empty?", "ARGS"]],
["rep", ["str", ["`", "(load-file \""], ["get", "ARGS", 0], ["`", "\")"]]],
["if", ["not", ["empty?", "argv"]],
["rep", ["str", ["`", "(load-file \""], ["get", "argv", 0], ["`", "\")"]]],
["repl", ["`", "user> "], "rep"]],

null
Expand Down
6 changes: 3 additions & 3 deletions impls/miniMAL/step8_macros.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@
["env-set", "repl-env", ["symbol", ["`", "eval"]],
["fn", ["ast"], ["EVAL", "ast", "repl-env"]]],
["env-set", "repl-env", ["symbol", ["`", "*ARGV*"]],
["slice", "ARGS", 1]],
["slice", "argv", 1]],

["`", "core.mal: defined using mal itself"],
["rep", ["`", "(def! not (fn* (a) (if a false true)))"]],
["rep", ["`", "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"]],
["rep", ["`", "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))"]],

["if", ["not", ["empty?", "ARGS"]],
["rep", ["str", ["`", "(load-file \""], ["get", "ARGS", 0], ["`", "\")"]]],
["if", ["not", ["empty?", "argv"]],
["rep", ["str", ["`", "(load-file \""], ["get", "argv", 0], ["`", "\")"]]],
["repl", ["`", "user> "], "rep"]],

null
Expand Down
6 changes: 3 additions & 3 deletions impls/miniMAL/step9_try.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@
["env-set", "repl-env", ["symbol", ["`", "eval"]],
["fn", ["ast"], ["EVAL", "ast", "repl-env"]]],
["env-set", "repl-env", ["symbol", ["`", "*ARGV*"]],
["slice", "ARGS", 1]],
["slice", "argv", 1]],

["`", "core.mal: defined using mal itself"],
["rep", ["`", "(def! not (fn* (a) (if a false true)))"]],
["rep", ["`", "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"]],
["rep", ["`", "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))"]],

["if", ["not", ["empty?", "ARGS"]],
["rep", ["str", ["`", "(load-file \""], ["get", "ARGS", 0], ["`", "\")"]]],
["if", ["not", ["empty?", "argv"]],
["rep", ["str", ["`", "(load-file \""], ["get", "argv", 0], ["`", "\")"]]],
["repl", ["`", "user> "], "rep"]],

null
Expand Down
6 changes: 3 additions & 3 deletions impls/miniMAL/stepA_mal.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,16 @@
["env-set", "repl-env", ["symbol", ["`", "eval"]],
["fn", ["ast"], ["EVAL", "ast", "repl-env"]]],
["env-set", "repl-env", ["symbol", ["`", "*ARGV*"]],
["slice", "ARGS", 1]],
["slice", "argv", 1]],

["`", "core.mal: defined using mal itself"],
["rep", ["`", "(def! *host-language* \"miniMAL\")"]],
["rep", ["`", "(def! not (fn* (a) (if a false true)))"]],
["rep", ["`", "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"]],
["rep", ["`", "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))"]],

["if", ["not", ["empty?", "ARGS"]],
["rep", ["str", ["`", "(load-file \""], ["get", "ARGS", 0], ["`", "\")"]]],
["if", ["not", ["empty?", "argv"]],
["rep", ["str", ["`", "(load-file \""], ["get", "argv", 0], ["`", "\")"]]],
["do",
["rep", ["`", "(println (str \"Mal [\" *host-language* \"]\"))"]],
["repl", ["`", "user> "], "rep"]]],
Expand Down

0 comments on commit b0488d5

Please sign in to comment.