Skip to content

Commit

Permalink
Merge pull request #39 from kanaka/misc-since-jan-2022
Browse files Browse the repository at this point in the history
Misc since jan 2022
  • Loading branch information
kanaka authored Mar 19, 2024
2 parents 61caa82 + ca48dff commit e693223
Show file tree
Hide file tree
Showing 84 changed files with 3,742 additions and 1,232 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Push (compose tests)

on:
push: {}
pull_request:
branches: [ master ]
workflow_dispatch: {}

jobs:
tests-and-stats:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Install JavaScript and ClojureScript node modules
run: |
( cd js && npm install )
( cd cljs && npm install )
- name: JavaScript Step Tests
run: make test^js

- name: JavaScript Regression Tests
run: make REGRESS=1 test^js

- name: Python Step Tests
run: make test^python

- name: Python Regression Tests
run: make REGRESS=1 test^python

- name: ClojureScript Step Tests
run: make test^cljs

- name: ClojureScript Regression Tests
run: make REGRESS=1 test^cljs

- name: Generate stats
run: |
make stats # Build compressed artifacts
make stats # Without the build noise
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ notes
*.pyc
*.pyz
*-minipy.py
cljs/.shadow-cljs
cljs/build
cljs/src-min
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "python/minipy"]
path = python/minipy
url = https://github.com/kanaka/minipy
[submodule "js/regpack"]
path = js/regpack
url = https://github.com/siorki/regpack
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (C) 2017 Joel Martin <[email protected]>
Copyright (C) 2024 Joel Martin <[email protected]>

miniMAL is licensed under the MPL 2.0 (Mozilla Public License 2.0).
The text of the MPL 2.0 license is included below and can be found at
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ argv_STEP = step7_interop
# Map of step (e.g. "step8") to executable file for that step
js_STEP_TO_PROG = js/$($(1)).js
python_STEP_TO_PROG = python/$($(1)).py
cljs_STEP_TO_PROG = cljs/src/miniMAL/$($(1)).cljs
cljs_STEP_TO_PROG = cljs/src/miniMAL/$($(1)).cljc

##########################################################
# Most of the rest of this file comes from mal/Makefile
Expand Down
97 changes: 67 additions & 30 deletions cljs/Makefile
Original file line number Diff line number Diff line change
@@ -1,47 +1,84 @@
STEPS = step1_read_print step2_eval step3_env step4_if_fn_do \
step5_tco step6_file step7_interop step8_macros \
step9_try stepA_miniMAL
STEPS = step0_repl step1_read_print step2_eval step3_env \
step4_if_fn_do step5_tco step6_file step7_interop \
step8_macros step9_try stepA_miniMAL

MIN_FILES = src/miniMAL/miniMAL.cljs miniMAL
MIN_FILES = $(foreach S,$(STEPS),src-min/miniMAL/$(S).cljc) miniMAL
BUILD_FILES = $(foreach S,$(STEPS),build/$(S).js) miniMAL.js

all: $(MIN_FILES)
.SECONDARY:

src/miniMAL/miniMAL.cljs: src/miniMAL/stepA_miniMAL.cljs
all: $(MIN_FILES) $(BUILD_FILES)

#
# Compressed
#
src-min/miniMAL/%.cljc: src/miniMAL/%.cljc
@echo "Compressing $@"
@mkdir -p src-min/miniMAL/
@cat $< \
| egrep -v "^ *$$|^ *;" \
| sed 's/^ *//' \
| tr '\n' ' ' \
| sed 's/ *(/(/g' \
| sed 's/) */)/g' \
| sed 's/ *"/"/g' \
| sed 's/ *\[/[/g' \
| sed 's/] */]/g' \
| sed 's/" *\([^n]\)/"\1/g' \
| sed 's/\<ast\>/A/g' \
| sed 's/\<env\>/E/g' \
| sed 's/\<a0\>/a/g' \
| sed 's/\<a1\>/b/g' \
| sed 's/\<a2\>/c/g' \
| sed 's/\<a3\>/d/g' \
| sed 's/stepA-miniMAL/miniMAL/' \
| sed 's/\<EVAL\>/X/g' \
| sed 's/\<eval-ast\>/Y/g' \
| sed 's/\<new-env\>/Z/g' \
| sed \
-e 's/ *(/(/g' \
-e 's/) */)/g' \
-e 's/ *"/"/g' \
-e 's/ *\[/[/g' \
-e 's/] */]/g' \
-e 's/ *{/{/g' \
-e 's/" *\([^n]\)/"\1/g' \
-e 's/\<new-env\>/Y/g' \
-e 's/\([^-]\)\<env\>/\1E/g' \
-e 's/\<ast\>/A/g' \
-e 's/\<EVAL\>/X/g' \
-e 's/\<a0\>/a/g' \
-e 's/\<a1\>/b/g' \
-e 's/\<a2\>/c/g' \
-e 's/\<a3\>/d/g' \
-e 's/\<rest\>/R/g' \
-e 's/\((ns [^)]*)\)/\1(def R rest)/' \
-e 's/\<js\/JSON.parse\>/P/g' \
-e 's/\((ns [^)]*)\)/\1(def P js\/JSON.parse)/' \
-e 's/ *#?(:org.babashka\/nbb *\(.*\) *#_nbb-end */\1/' \
-e 's/ *:cljs *\(.*\)) *#_cljs-end *//' \
> $@

miniMAL: src/miniMAL/miniMAL.cljs
@echo "#!/usr/bin/lumo -q" > $@
@cat $< \
| sed "s/(ns.*:require\([^)]*)\))/(require \'\1/" \
| sed 's/defn -main\[& args\]/let [args (seq (.slice js\/process.argv 4))]/' \
miniMAL: src-min/miniMAL/stepA_miniMAL.cljc
echo "Compressing $@"
echo "#!/usr/bin/env nbb" > $@
cat $< \
| sed "s/(ns [^)]*)//" \
| sed 's/defn -main\[& args\]/let [args (seq (.slice js\/process.argv 3))]/' \
>> $@
@chmod +x $@
chmod +x $@

node_modules/.bin/shadow-cljs:
npm install

# Full ClojureScript Compiled
build/%.js: node_modules/.bin/shadow-cljs src/miniMAL/%.cljc
node_modules/.bin/shadow-cljs release $*
chmod +x $@

.PHONY: clean
miniMAL.js: node_modules/shadow-cljs src/miniMAL/stepA_miniMAL.cljc
node_modules/.bin/shadow-cljs release miniMAL
chmod +x $@

stats: $(foreach S,$(STEPS),src/miniMAL/$(S).cljs) $(MIN_FILES)
#
# Stats
#
stats^%: src/miniMAL/%.cljc src-min/miniMAL/%.cljc
@wc $^ | grep -v "total"


.PHONY: clean stats

stats: $(foreach s,$(STEPS),stats^$(s)) miniMAL core.json
@wc miniMAL core.json | grep -v "total"

clean:
rm -f $(MIN_FILES)
rm -f $(BUILD_FILES)
rm -fr build/cljs-runtime
rmdir -p build || true
rmdir -p src-min/miniMAL || true
6 changes: 3 additions & 3 deletions cljs/core.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
["interpose", "b",
["map", ["fn", ["x"],
["if", "c",
["print", "x"],
["pr*", "x"],
["if", ["string?", "x"],
"x",
["print", "x"]]]],
["pr*", "x"]]]],
"a"]]]]],
["def", "pr-str", ["fn", ["&", "a"],
["pr-list*", "a", ["`", " "], true]]],
Expand All @@ -47,7 +47,7 @@
["do", ["clj-println", ["pr-list*", "a", ["`", " "], false]], null]]],

["def", "list?", ["fn", ["a"],
["if", ["clj-list?", "a"], true, ["array?", "a"]]]],
["if", ["sequential?", "a"], true, ["array?", "a"]]]],
["def", "contains?", ["fn", ["a", "b"],
["if", ["object?", "a"],
["not", ["undefined?", ["aget", "a", "b"]]],
Expand Down
Loading

0 comments on commit e693223

Please sign in to comment.