-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version 1.2.0: shrinks, nbb/shadow-cljs, cleanups
All: - Implements a number of miscellaneous shrinks across all three implementations. - Change "ARGS" command line parameter variable to "argv" - Remove "load" definition and use "slurp -> read -> eval" instead (more efficient compressing) - Update copyrights to 2024. cljs: - Drop lumo support and use nbb instead. - Switch cljs full compilation mode to use shadow-cljs. - Add cljs/shadow-cljs.edn with builds for all steps. - By default use release mode in the Makefile which compiles into a standalone *.js file (although it's quite slow to build). - add babashka vs shadow-cljs reader macros for core ns hoisting. During shrinking (which is only for nbb mode) sed out the regular :cljs reader macro. - use nbb from cljs/node_modules (and 'npm install' during build if needed) js: - Remove JS jscrush rules (regpack is sufficient) - Fix regpack node_module make dep
- Loading branch information
Showing
58 changed files
with
1,178 additions
and
1,055 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,6 @@ notes | |
*.pyc | ||
*.pyz | ||
*-minipy.py | ||
cljs/.shadow-cljs | ||
cljs/build | ||
cljs/src-min |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"dependencies": { | ||
"nbb": "^0.1.9" | ||
}, | ||
"devDependencies": { | ||
"shadow-cljs": "^2.27.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#!/bin/bash | ||
STEP=${STEP:-stepA_miniMAL} | ||
exec lumo -c $(dirname $0)/src -m miniMAL.${STEP//_/-} "${@}" | ||
exec $(dirname $0)/node_modules/.bin/nbb -cp $(dirname $0)/src -m miniMAL.${STEP//_/-} "${@}" | ||
#exec $(dirname $0)/node_modules/.bin/nbb -cp $(dirname $0)/src-min -m miniMAL.${STEP//_/-} "${@}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
;; shadow-cljs configuration | ||
{:source-paths | ||
["src/"] | ||
|
||
:build-defaults {:output-dir "build/" | ||
;; Don't try and connect back to shadow-cljs process | ||
:devtools {:enabled false :console-support false} | ||
:compiler-options | ||
{:optimizations :simple | ||
:source-map-use-fs-paths true}} | ||
|
||
:builds | ||
{:step0_repl {:target :node-script :main miniMAL.step0-repl/-main :output-to "build/step0_repl.js"} | ||
:step1_read_print {:target :node-script :main miniMAL.step1-read-print/-main :output-to "build/step1_read_print.js"} | ||
:step2_eval {:target :node-script :main miniMAL.step2-eval/-main :output-to "build/step2_eval.js"} | ||
:step3_env {:target :node-script :main miniMAL.step3-env/-main :output-to "build/step3_env.js"} | ||
:step4_if_fn_do {:target :node-script :main miniMAL.step4-if-fn-do/-main :output-to "build/step4_if_fn_do.js"} | ||
:step5_tco {:target :node-script :main miniMAL.step5-tco/-main :output-to "build/step5_tco.js"} | ||
:step6_file {:target :node-script :main miniMAL.step6-file/-main :output-to "build/step6_file.js"} | ||
:step7_interop {:target :node-script :main miniMAL.step7-interop/-main :output-to "build/step7_interop.js"} | ||
:step8_macros {:target :node-script :main miniMAL.step8-macros/-main :output-to "build/step8_macros.js"} | ||
:step9_try {:target :node-script :main miniMAL.step9-try/-main :output-to "build/step9_try.js"} | ||
:stepA_miniMAL {:target :node-script :main miniMAL.stepA-miniMAL/-main :output-to "build/stepA_miniMAL.js"} | ||
:miniMAL {:target :node-script :main miniMAL.stepA-miniMAL/-main :output-to "miniMAL.js"}} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
(ns miniMAL.step1-read-print) | ||
|
||
(defn EVAL [ast env] | ||
ast) | ||
ast) | ||
|
||
(defn -main [& args] | ||
(let [efn #(%4 nil (js/JSON.stringify (EVAL (js/JSON.parse %1) {})))] | ||
(.start | ||
(js/require "repl") | ||
(clj->js {:eval efn :writer identity :terminal 0})))) | ||
(.start | ||
(js/require "repl") | ||
(clj->js {:eval #(%4 0 (EVAL (js->clj (js/JSON.parse %1)) {})) | ||
:writer #(js/JSON.stringify (clj->js %))})) | ||
nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,34 @@ | ||
(ns miniMAL.step2-eval) | ||
|
||
(declare EVAL) | ||
(defn EVAL [ast env & [sq]] | ||
;;(prn :EVAL :ast ast :sq sq) | ||
(cond | ||
sq | ||
(map #(EVAL % env) ast) | ||
|
||
(defn eval-ast [ast env] | ||
(cond (array? ast) (map #(EVAL % env) ast) | ||
(and (string? ast) (contains? env ast)) (get env ast) | ||
(string? ast) (throw (str ast " not found")) | ||
:else ast)) | ||
(and (string? ast) (contains? env ast)) | ||
(env ast) | ||
|
||
(defn EVAL [ast env] | ||
;(prn :EVAL :ast ast) | ||
(if (not (or (array? ast) (seq? ast))) | ||
(eval-ast ast env) | ||
(let [[f & el] (eval-ast ast env)] | ||
(apply f el)))) | ||
(string? ast) | ||
(throw (str ast " not found")) | ||
|
||
(def E {"+" + | ||
"-" - | ||
"*" * | ||
"/" /}) | ||
(sequential? ast) | ||
(let [[f & el] (EVAL ast env 1)] | ||
(apply f el)) | ||
|
||
:else | ||
ast)) | ||
|
||
(def E | ||
{"+" + | ||
"-" - | ||
"*" * | ||
"/" / | ||
}) | ||
|
||
(defn -main [& args] | ||
(let [efn #(%4 nil (js/JSON.stringify (EVAL (js/JSON.parse %1) E)))] | ||
(.start | ||
(js/require "repl") | ||
(clj->js {:eval efn :writer identity :terminal 0})))) | ||
(.start | ||
(js/require "repl") | ||
(clj->js {:eval #(%4 0 (EVAL (js->clj (js/JSON.parse %1)) E)) | ||
:writer #(js/JSON.stringify (clj->js %))})) | ||
nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.