~tim/malcc

3a60e494df979be1435e181cab2bc16e2f6bd0e0 — Tim Morgan 5 years ago ba50487
Update mal impl and tests from offical mal repo
9 files changed, 192 insertions(+), 607 deletions(-)

M Makefile
D mal/.gitignore
M mal/Makefile
M mal/README.md
D mal/mal.html
M mal/mal/Makefile
M mal/mal/step9_try.mal
M mal/mal/stepA_mal.mal
M mal/tests/step9_try.mal
M Makefile => Makefile +6 -0
@@ 136,3 136,9 @@ docker-test-supplemental: docker-build

docker-watch: docker-build
	$(RUN_DOCKER_CMD) bash -c "ls *.c *.h Makefile | entr -c -s 'make test'"

update-mal-directory:
	rm -rf /tmp/mal mal
	mkdir mal
	git clone https://github.com/kanaka/mal.git /tmp/mal
	cp -r /tmp/mal/LICENSE /tmp/mal/Makefile /tmp/mal/README.md /tmp/mal/core.mal /tmp/mal/mal /tmp/mal/perf.mal /tmp/mal/run_argv_test.sh /tmp/mal/runtest.py /tmp/mal/tests mal/

D mal/.gitignore => mal/.gitignore +0 -148
@@ 1,148 0,0 @@
.bash_history
.cache
.cargo
.config
.mal-history
.crystal
.lein
.m2
.ivy2
.sbt
.npm
.node-gyp
package-lock.json
.elm
*/experiments
*/node_modules
*.o
*.pyc
*/step0_repl
*/step1_read_print
*/step2_eval
*/step3_env
*/step4_if_fn_do
*/step5_tco
*/step6_file
*/step7_quote
*/step8_macros
*/step9_try
*/stepA_mal
*/mal
*/notes

logs
old

ada/obj/
awk/mal.awk
bash/mal.sh
clojure/mal.jar
clojure/target
clojure/.lein-repl-history
coffee/mal.coffee
cs/*.exe
cs/*.dll
cs/*.mdb
d/*.o
elixir/_build
elixir/deps
elixir/erl_crash.dump
elixir/*.ez
erlang/ebin
erlang/.rebar
erlang/src/*.beam
es6/mal.js
es6/.esm-cache
factor/mal.factor
fantom/lib
forth/mal.fs
fsharp/*.exe
fsharp/*.dll
fsharp/*.mdb
go/step*
groovy/*.class
groovy/mal.jar
haskell/*.hi
haskell/*.o
haxe/*.n
haxe/*.py
haxe/cpp/
haxe/*.js
java/mal.jar
java/target/
java/dependency-reduced-pom.xml
.npm/
.node-gyp/
js/mal.js
js/web/mal.js
kotlin/*.jar
kotlin/.idea
kotlin/*.iml
lua/lib
lua/linenoise.so
lua/mal.lua
make/mal.mk
mal/mal.mal
matlab/octave-workspace
miniMAL/mal.json
nim/nimcache*
objc/*.d
ocaml/*.cmi
ocaml/*.cmo
ocaml/*.swp
ocaml/*.cmx
ocaml/*.o
ocaml/mal_lib.*
objpascal/*.o
objpascal/*.ppu
objpascal/pas-readline
objpascal/regexpr/Source/RegExpr.ppu
perl/mal.pl
perl6/.precomp/
php/mal.php
php/mal-web.php
ps/mal.ps
python/mal.pyz
r/mal.r
ruby/mal.rb
.cargo/
rust/target/
rust/Cargo.lock
rust/.cargo
r/lib
scala/mal.jar
scala/target
scala/project
skew/*.js
tcl/mal.tcl
vb/*.exe
vb/*.dll
vimscript/mal.vim
clisp/*.fas
clisp/*.lib
basic/step0_repl.bas
basic/step1_read_print.bas
basic/step2_eval.bas
basic/step3_env.bas
basic/step4_if_fn_do.bas
basic/step5_tco.bas
basic/step6_file.bas
basic/step7_quote.bas
basic/step8_macros.bas
basic/step9_try.bas
basic/stepA_mal.bas
basic/*.prg
common-lisp/*.fasl
common-lisp/*.lib
common-lisp/images/*
common-lisp/hist/*
livescript/*.js
!livescript/node_readline.js
livescript/node_modules
elm/node_modules
elm/elm-stuff
elm/*.js
!elm/node_readline.js
!elm/bootstrap.js
wasm/*.wat
wasm/*.wasm

M mal/Makefile => mal/Makefile +38 -19
@@ 62,6 62,9 @@ scheme_MODE = chibi
# js wace_libc wace_fooboot
wasm_MODE = wace_libc

# Path to loccount for counting LOC stats
LOCCOUNT = loccount

# Extra options to pass to runtest.py
TEST_OPTS =



@@ 81,12 84,12 @@ DOCKERIZE =
# Implementation specific settings
#

IMPLS = ada awk bash basic c chuck clojure coffee common-lisp cpp crystal cs d dart \
IMPLS = ada ada.2 awk bash basic c chuck clojure coffee common-lisp cpp crystal cs d dart \
	elisp elixir elm erlang es6 factor fantom forth fsharp go groovy gnu-smalltalk \
	guile haskell haxe hy io java js julia kotlin livescript logo lua make mal \
	matlab miniMAL nasm nim objc objpascal ocaml perl perl6 php picolisp plpgsql \
	plsql powershell ps python r racket rexx rpython ruby rust scala scheme skew \
	swift swift3 tcl ts vb vhdl vimscript wasm yorick
	swift swift3 swift4 tcl ts vb vhdl vimscript wasm yorick

EXTENSION = .mal



@@ 117,16 120,16 @@ regress_step8 = $(regress_step7) step8
regress_step9 = $(regress_step8) step9
regress_stepA = $(regress_step9) stepA

test_EXCLUDES += test^bash^step5   # never completes at 10,000
test_EXCLUDES += test^basic^step5  # too slow, and limited to ints of 2^16
test_EXCLUDES += test^logo^step5   # too slow for 10,000
test_EXCLUDES += test^make^step5   # no TCO capability (iteration or recursion)
test_EXCLUDES += test^mal^step5    # host impl dependent
test_EXCLUDES += test^matlab^step5 # never completes at 10,000
test_EXCLUDES += test^plpgsql^step5 # too slow for 10,000
test_EXCLUDES += test^plsql^step5  # too slow for 10,000
test_EXCLUDES += test^powershell^step5  # too slow for 10,000
test_EXCLUDES += $(if $(filter cpp,$(haxe_MODE)),test^haxe^step5,) # cpp finishes 10,000, segfaults at 100,000
step5_EXCLUDES += bash        # never completes at 10,000
step5_EXCLUDES += basic       # too slow, and limited to ints of 2^16
step5_EXCLUDES += logo        # too slow for 10,000
step5_EXCLUDES += make        # no TCO capability (iteration or recursion)
step5_EXCLUDES += mal         # host impl dependent
step5_EXCLUDES += matlab      # never completes at 10,000
step5_EXCLUDES += plpgsql     # too slow for 10,000
step5_EXCLUDES += plsql       # too slow for 10,000
step5_EXCLUDES += powershell  # too slow for 10,000
step5_EXCLUDES += $(if $(filter cpp,$(haxe_MODE)),haxe,) # cpp finishes 10,000, segfaults at 100,000

dist_EXCLUDES += mal
# TODO: still need to implement dist


@@ 173,6 176,7 @@ scheme_STEP_TO_PROG_foment      = scheme/$($(1)).scm

# Map of step (e.g. "step8") to executable file for that step
ada_STEP_TO_PROG =     ada/$($(1))
ada.2_STEP_TO_PROG =   ada.2/$($(1))
awk_STEP_TO_PROG =     awk/$($(1)).awk
bash_STEP_TO_PROG =    bash/$($(1)).sh
basic_STEP_TO_PROG =   $(basic_STEP_TO_PROG_$(basic_MODE))


@@ 239,6 243,7 @@ scheme_STEP_TO_PROG =  $(scheme_STEP_TO_PROG_$(scheme_MODE))
skew_STEP_TO_PROG =    skew/$($(1)).js
swift_STEP_TO_PROG =   swift/$($(1))
swift3_STEP_TO_PROG =  swift3/$($(1))
swift4_STEP_TO_PROG =  swift4/$($(1))
tcl_STEP_TO_PROG =     tcl/$($(1)).tcl
ts_STEP_TO_PROG =      ts/$($(1)).js
vb_STEP_TO_PROG =      vb/$($(1)).exe


@@ 265,7 270,10 @@ opt_OPTIONAL        = $(if $(strip $(OPTIONAL)),$(if $(filter t true T True TRUE
# test files will include step 2 tests through tests for the step
# being tested.
STEP_TEST_FILES = $(strip $(wildcard \
		    $(foreach s,$(if $(strip $(REGRESS)),$(regress_$(2)),$(2)),\
		    $(foreach s,$(if $(strip $(REGRESS)),\
			$(filter-out $(if $(filter $(1),$(step5_EXCLUDES)),step5,),\
			  $(regress_$(2)))\
			,$(2)),\
		      $(1)/tests/$($(s))$(EXTENSION) tests/$($(s))$(EXTENSION))))

# DOCKERIZE utility functions


@@ 318,11 326,11 @@ get_runtest_cmd = $(call get_run_prefix,$(1),$(2),$(if $(filter cs fsharp tcl vb
get_argvtest_cmd = $(call get_run_prefix,$(1),$(2)) ../run_argv_test.sh

# Derived lists
STEPS = $(sort $(filter step%,$(.VARIABLES)))
STEPS = $(sort $(filter-out %_EXCLUDES,$(filter step%,$(.VARIABLES))))
DO_IMPLS = $(filter-out $(SKIP_IMPLS),$(IMPLS))
IMPL_TESTS = $(foreach impl,$(DO_IMPLS),test^$(impl))
STEP_TESTS = $(foreach step,$(STEPS),test^$(step))
ALL_TESTS = $(filter-out $(test_EXCLUDES),\
ALL_TESTS = $(filter-out $(foreach e,$(step5_EXCLUDES),test^$(e)^step5),\
              $(strip $(sort \
                $(foreach impl,$(DO_IMPLS),\
                  $(foreach step,$(STEPS),test^$(impl)^$(step))))))


@@ 333,6 341,8 @@ DOCKER_SHELL = $(foreach impl,$(DO_IMPLS),docker-shell^$(impl))

IMPL_PERF = $(foreach impl,$(filter-out $(perf_EXCLUDES),$(DO_IMPLS)),perf^$(impl))

IMPL_STATS = $(foreach impl,$(DO_IMPLS),stats^$(impl))

IMPL_REPL = $(foreach impl,$(DO_IMPLS),repl^$(impl))
ALL_REPL = $(strip $(sort \
             $(foreach impl,$(DO_IMPLS),\


@@ 450,6 460,19 @@ $(ALL_REPL): $$(call $$(word 2,$$(subst ^, ,$$(@)))_STEP_TO_PROG,$$(word 3,$$(su
$(IMPL_REPL): $$@^stepA

#
# Stats test rules
#

# For a concise summary:
#   make stats | egrep -A1 "^Stats for|^all" | egrep -v "^all|^--"
stats: $(IMPL_STATS)

$(IMPL_STATS):
	@$(foreach impl,$(word 2,$(subst ^, ,$(@))),\
	  echo "Stats for $(impl):"; \
	  $(LOCCOUNT) -x "Makefile|node_modules" $(impl))

#
# Utility functions
#
print-%:


@@ 477,9 500,5 @@ recur_impls_ = $(filter-out $(foreach impl,$($(1)_EXCLUDES),$(1)^$(impl)),$(fore
# recursive clean
$(eval $(call recur_template,clean,$(call recur_impls_,clean)))

# recursive stats
$(eval $(call recur_template,stats,$(call recur_impls_,stats)))
$(eval $(call recur_template,stats-lisp,$(call recur_impls_,stats-lisp)))

# recursive dist
$(eval $(call recur_template,dist,$(call recur_impls_,dist)))

M mal/README.md => mal/README.md +138 -111
@@ 6,82 6,86 @@

**1. Mal is a Clojure inspired Lisp interpreter**

**2. Mal is implemented in 74 languages**

* **Ada** - *created by [Chris Moore](https://github.com/zmower)*
* **GNU awk** - *created by [Miutsuru Kariya](https://github.com/kariya-mitsuru)*
* **Bash 4**
* **BASIC** (C64 and QBasic)
* **C**
* **C++** - *created by [Stephen Thirlwall](https://github.com/sdt)*
* **C#**
* **ChucK** - *created by [Vasilij Schneidermann](https://github.com/wasamasa)*
* **Common Lisp** - *created by [Iqbal Ansari](https://github.com/iqbalansari)*
* **Clojure** (Clojure and ClojureScript)
* **CoffeeScript**
* **Crystal** - *created by [Linda_pp](https://github.com/rhysd)*
* **D** - *created by [Dov Murik](https://github.com/dubek)*
* **Dart** - *created by [Harry Terkelsen](https://github.com/hterkelsen)*
* **Elixir** - *created by [Martin Ek](https://github.com/ekmartin)*
* **Elm** - *created by [Jos van Bakel](https://github.com/c0deaddict)*
* **Emacs Lisp** - *created by [Vasilij Schneidermann](https://github.com/wasamasa)*
* **Erlang** - *created by [Nathan Fiedler](https://github.com/nlfiedler)*
* **ES6** (ECMAScript 6 / ECMAScript 2015)
* **F#** - *created by [Peter Stephens](https://github.com/pstephens)*
* **Factor** - *created by [Jordan Lewis](https://github.com/jordanlewis)*
* **Fantom** - *created by [Dov Murik](https://github.com/dubek)*
* **Forth** - *created by [Chris Houser](https://github.com/chouser)*
* **Go**
* **Groovy**
* **GNU Guile** - *created by [Mu Lei](https://github.com/NalaGinrut).*
* **GNU Smalltalk** - *created by [Vasilij Schneidermann](https://github.com/wasamasa)*
* **Haskell**
* **Haxe** (Neko, Python, C++ and JavaScript)
* **Hy**
* **Io** - *created by [Dov Murik](https://github.com/dubek)*
* **Java**
* **JavaScript** ([Online Demo](http://kanaka.github.io/mal))
* **Julia**
* **Kotlin** - *created by [Javier Fernandez-Ivern](https://github.com/ivern)*
* **LiveScript** - *created by [Jos van Bakel](https://github.com/c0deaddict)*
* **Logo** - *created by [Dov Murik](https://github.com/dubek)*
* **Lua**
* **GNU Make**
* **mal itself**
* **Matlab** (GNU Octave and MATLAB)
* **[miniMAL](https://github.com/kanaka/miniMAL)**
* **NASM** - *created by [Ben Dudson](https://github.com/bendudson)*
* **Nim** - *created by [Dennis Felsing](https://github.com/def-)*
* **Object Pascal**
* **Objective C**
* **OCaml** - *created by [Chris Houser](https://github.com/chouser)*
* **Perl**
* **Perl 6** - *created by [Hinrik Örn Sigurðsson](https://github.com/hinrik)*
* **PHP**
* **Picolisp** - *created by [Vasilij Schneidermann](https://github.com/wasamasa)*
* **PL/pgSQL** (Postgres)
* **PL/SQL** (Oracle)
* **Postscript**
* **PowerShell**
* **Python** (2.X and 3.X)
* **RPython**
* **R**
* **Racket**
* **Rexx** - *created by [Dov Murik](https://github.com/dubek)*
* **Ruby**
* **Rust**
* **Scala**
* **Scheme (R7RS)** - *created by [Vasilij Schneidermann](https://github.com/wasamasa)*
* **Skew** - *created by [Dov Murik](https://github.com/dubek)*
* **Swift** - *created by [Keith Rollin](https://github.com/keith-rollin)*
* **Swift 3**
* **Tcl** - *created by [Dov Murik](https://github.com/dubek)*
* **TypeScript** - *created by [Masahiro Wakame](https://github.com/vvakame)*
* **VHDL** - *created by [Dov Murik](https://github.com/dubek)*
* **Vimscript** - *created by [Dov Murik](https://github.com/dubek)*
* **Visual Basic.NET**
* **WebAssembly** (wasm)
* **Yorick** - *created by [Dov Murik](https://github.com/dubek)*
**2. Mal is implemented in 75 languages (76 implementations total)**

| Language | Creator |
| -------- | ------- |
| [Ada](#ada) | [Chris Moore](https://github.com/zmower) |
| [Ada #2](#ada2) | [Nicolas Boulenguez](https://github.com/asarhaddon) |
| [GNU Awk](#gnu-awk) | [Miutsuru Kariya](https://github.com/kariya-mitsuru) |
| [Bash 4](#bash-4) | [Joel Martin](https://github.com/kanaka)  |
| [BASIC](#basic-c64-and-qbasic) (C64 & QBasic) | [Joel Martin](https://github.com/kanaka) |
| [C](#c) | [Joel Martin](https://github.com/kanaka)  |
| [C++](#c-1) | [Stephen Thirlwall](https://github.com/sdt) |
| [C#](#c-2) | [Joel Martin](https://github.com/kanaka)  |
| [ChucK](#chuck) | [Vasilij Schneidermann](https://github.com/wasamasa) |
| [Clojure](#clojure) (Clojure & ClojureScript) | [Joel Martin](https://github.com/kanaka) |
| [CoffeeScript](#coffeescript) | [Joel Martin](https://github.com/kanaka)  |
| [Common Lisp](#common-lisp) | [Iqbal Ansari](https://github.com/iqbalansari) |
| [Crystal](#crystal) | [Linda_pp](https://github.com/rhysd) |
| [D](#d) | [Dov Murik](https://github.com/dubek) |
| [Dart](#dart) | [Harry Terkelsen](https://github.com/hterkelsen) |
| [Elixir](#elixir) | [Martin Ek](https://github.com/ekmartin) |
| [Elm](#elm) | [Jos van Bakel](https://github.com/c0deaddict) |
| [Emacs Lisp](#emacs-lisp) | [Vasilij Schneidermann](https://github.com/wasamasa) |
| [Erlang](#erlang) | [Nathan Fiedler](https://github.com/nlfiedler) |
| [ES6](#es6-ecmascript-2015) (ECMAScript 2015) | [Joel Martin](https://github.com/kanaka) |
| [F#](#f) | [Peter Stephens](https://github.com/pstephens) |
| [Factor](#factor) | [Jordan Lewis](https://github.com/jordanlewis) |
| [Fantom](#fantom) | [Dov Murik](https://github.com/dubek) |
| [Forth](#forth) | [Chris Houser](https://github.com/chouser) |
| [GNU Guile](#gnu-guile-21) | [Mu Lei](https://github.com/NalaGinrut) |
| [GNU Smalltalk](#gnu-smalltalk) | [Vasilij Schneidermann](https://github.com/wasamasa) |
| [Go](#go) | [Joel Martin](https://github.com/kanaka)  |
| [Groovy](#groovy) | [Joel Martin](https://github.com/kanaka)  |
| [Haskell](#haskell) | [Joel Martin](https://github.com/kanaka)  |
| [Haxe](#haxe-neko-python-c-and-javascript) (Neko, Python, C++, & JS) | [Joel Martin](https://github.com/kanaka) |
| [Hy](#hy) | [Joel Martin](https://github.com/kanaka)  |
| [Io](#io) | [Dov Murik](https://github.com/dubek) |
| [Java](#java-17) | [Joel Martin](https://github.com/kanaka)  |
| [JavaScript](#javascriptnode) ([Demo](http://kanaka.github.io/mal)) | [Joel Martin](https://github.com/kanaka) |
| [Julia](#julia) | [Joel Martin](https://github.com/kanaka)  |
| [Kotlin](#kotlin) | [Javier Fernandez-Ivern](https://github.com/ivern) |
| [LiveScript](#livescript) | [Jos van Bakel](https://github.com/c0deaddict) |
| [Logo](#logo) | [Dov Murik](https://github.com/dubek) |
| [Lua](#lua) | [Joel Martin](https://github.com/kanaka)  |
| [GNU Make](#gnu-make-381) | [Joel Martin](https://github.com/kanaka)  |
| [mal itself](#mal) | [Joel Martin](https://github.com/kanaka)  |
| [MATLAB](#matlab-gnu-octave-and-matlab) (GNU Octave & MATLAB) | [Joel Martin](https://github.com/kanaka) |
| [miniMAL](#minimal) ([Repo](https://github.com/kanaka/miniMAL), [Demo](https://kanaka.github.io/miniMAL/)) | [Joel Martin](https://github.com/kanaka) |
| [NASM](#nasm) | [Ben Dudson](https://github.com/bendudson) |
| [Nim](#nim-0170) | [Dennis Felsing](https://github.com/def-) |
| [Object Pascal](#object-pascal) | [Joel Martin](https://github.com/kanaka)  |
| [Objective C](#objective-c) | [Joel Martin](https://github.com/kanaka)  |
| [OCaml](#ocaml-4010) | [Chris Houser](https://github.com/chouser) |
| [Perl](#perl-58) | [Joel Martin](https://github.com/kanaka)  |
| [Perl 6](#perl-6) | [Hinrik Örn Sigurðsson](https://github.com/hinrik) |
| [PHP](#php-53) | [Joel Martin](https://github.com/kanaka)  |
| [Picolisp](#picolisp) | [Vasilij Schneidermann](https://github.com/wasamasa) |
| [PL/pgSQL](#plpgsql-postgres-sql-procedural-language) (Postgres) | [Joel Martin](https://github.com/kanaka) |
| [PL/SQL](#plsql-oracle-sql-procedural-language) (Oracle) | [Joel Martin](https://github.com/kanaka) |
| [PostScript](#postscript-level-23) | [Joel Martin](https://github.com/kanaka)  |
| [PowerShell](#powershell) | [Joel Martin](https://github.com/kanaka)  |
| [Python](#python-2x-and-3x) (2.X & 3.X) | [Joel Martin](https://github.com/kanaka) |
| [RPython](#rpython) | [Joel Martin](https://github.com/kanaka)  |
| [R](#r) | [Joel Martin](https://github.com/kanaka)  |
| [Racket](#racket-53) | [Joel Martin](https://github.com/kanaka)  |
| [Rexx](#rexx) | [Dov Murik](https://github.com/dubek) |
| [Ruby](#ruby-19) | [Joel Martin](https://github.com/kanaka)  |
| [Rust](#rust-100-nightly) | [Joel Martin](https://github.com/kanaka)  |
| [Scala](#scala) | [Joel Martin](https://github.com/kanaka)  |
| [Scheme (R7RS)](#scheme-r7rs) | [Vasilij Schneidermann](https://github.com/wasamasa) |
| [Skew](#skew) | [Dov Murik](https://github.com/dubek) |
| [Swift 2](#swift) | [Keith Rollin](https://github.com/keith-rollin) |
| [Swift 3](#swift-3) | [Joel Martin](https://github.com/kanaka)  |
| [Swift 4](#swift-4) | [陆遥](https://github.com/LispLY)  |
| [Tcl](#tcl-86) | [Dov Murik](https://github.com/dubek) |
| [TypeScript](#typescript) | [Masahiro Wakame](https://github.com/vvakame) |
| [VHDL](#vhdl) | [Dov Murik](https://github.com/dubek) |
| [Vimscript](#vimscript) | [Dov Murik](https://github.com/dubek) |
| [Visual Basic.NET](#visual-basicnet) | [Joel Martin](https://github.com/kanaka)  |
| [WebAssembly](#webassembly-wasm) (wasm) | [Joel Martin](https://github.com/kanaka) |
| [Yorick](#yorick) | [Dov Murik](https://github.com/dubek) |


**3. Mal is a learning tool**


@@ 167,6 171,17 @@ make
./stepX_YYY
```

### Ada.2

The second Ada implementation was developed with GNAT 8 and links with
the GNU readline library.

```
cd ada
make
./stepX_YYY
```

### GNU awk

The GNU awk implementation of mal has been tested with GNU awk 4.1.1.


@@ 260,19 275,6 @@ cd chuck
./run
```

### Common Lisp

The implementation has been tested with SBCL, CCL, CMUCL, GNU CLISP, ECL and
Allegro CL on Ubuntu 16.04 and Ubuntu 12.04, see
the [README](common-lisp/README.org) for more details. Provided you have the
dependencies mentioned installed, do the following to run the implementation

```
cd common-lisp
make
./run
```

### Clojure

For the most part the Clojure implementation requires Clojure 1.5,


@@ 291,6 293,19 @@ cd coffee
coffee ./stepX_YYY
```

### Common Lisp

The implementation has been tested with SBCL, CCL, CMUCL, GNU CLISP, ECL and
Allegro CL on Ubuntu 16.04 and Ubuntu 12.04, see
the [README](common-lisp/README.org) for more details. Provided you have the
dependencies mentioned installed, do the following to run the implementation

```
cd common-lisp
make
./run
```

### Crystal

The Crystal implementation of mal has been tested with Crystal 0.26.1.


@@ 371,11 386,11 @@ MAL_STEP=stepX_YYY rebar compile escriptize # build individual step
./stepX_YYY
```

### ES6 (ECMAScript 6 / ECMAScript 2015)
### ES6 (ECMAScript 2015)

The ES6 implementation uses the [babel](https://babeljs.io) compiler
to generate ES5 compatible JavaScript. The generated code has been
tested with Node 0.12.4.
The ES6 / ECMAScript 2015 implementation uses the
[babel](https://babeljs.io) compiler to generate ES5 compatible
JavaScript. The generated code has been tested with Node 0.12.4.

```
cd es6


@@ 424,6 439,22 @@ cd forth
gforth stepX_YYY.fs
```

### GNU Guile 2.1+

```
cd guile
guile -L ./ stepX_YYY.scm
```

### GNU Smalltalk

The Smalltalk implementation of mal has been tested with GNU Smalltalk 3.2.91.

```
cd gnu-smalltalk
./run
```

### Go

The Go implementation of mal requires that go is installed on on the


@@ 447,22 478,6 @@ make
groovy ./stepX_YYY.groovy
```

### GNU Guile 2.1+

```
cd guile
guile -L ./ stepX_YYY.scm
```

### GNU Smalltalk

The Smalltalk implementation of mal has been tested with GNU Smalltalk 3.2.91.

```
cd gnu-smalltalk
./run
```

### Haskell

The Haskell implementation requires the ghc compiler version 7.10.1 or


@@ 657,7 672,7 @@ make
./stepX_YYY
```

### MatLab (GNU Octave and MATLAB)
### MATLAB (GNU Octave and MATLAB)

The MatLab implementation has been tested with GNU Octave 4.2.1.
It has also been tested with MATLAB version R2014a on Linux. Note that


@@ 928,6 943,17 @@ make
./stepX_YYY
```

### Swift 4

The Swift 4 implementation of mal requires the Swift 4.0 compiler. It
has been tested with Swift 4.2.3 release.

```
cd swift4
make
./stepX_YYY
```

### Tcl 8.6

The Tcl implementation of mal requires Tcl 8.6 to run.  For readline line


@@ 1194,9 1220,10 @@ The following implementations are maintained as separate projects:
* [by vi](https://github.com/vi/mal-rust-vi) - using [Pest](https://pest.rs/) grammar, not using typical Mal infrastructure (cargo-ized steps and built-in converted tests).


## Projects using mal
## Other mal Projects

 * [malc](https://github.com/dubek/malc) - Mal (Make A Lisp) compiler. Compiles a Mal program to LLVM assembly language, then binary.
 * [malcc](https://git.sr.ht/~tim/malcc) (@seven1m) - malcc is an incremental compiler implementation for the Mal language. It uses the Tiny C Compiler as the compiler backend and has full support for the Mal language, including macros, tail-call elimination, and even run-time eval. ["I Built a Lisp Compiler"](https://mpov.timmorgan.org/i-built-a-lisp-compiler/) post about the process.
 * [frock](https://github.com/chr15m/frock) - Clojure-flavoured PHP. Uses mal/php to run programs.

## License

D mal/mal.html => mal/mal.html +0 -297
@@ 1,297 0,0 @@
<!DOCTYPE html>
<!--
Copyright (c) 2014 Joel Martin
Copyright (c) 2012 Fogus, Jen Myers and Relevance Inc.
All rights reserved. The use and distribution terms for this software
are covered by the Eclipse Public License 1.0
(http://opensource.org/licenses/eclipse-1.0.php) which can be found in
the file COPYING the root of this distribution.  By using this
software in any fashion, you are agreeing to be bound by the terms of
this license.  You must not remove this notice, or any other, from
this software.
-->

<html>
<head>
  <meta charset="UTF-8" />
  <link rel="stylesheet" type="text/css" href="js/web/base.css" />
  <link rel="stylesheet" type="text/css" href="js/web/layout.css" />
  <link rel="stylesheet" type="text/css" href="js/web/skeleton.css" />
  <link rel="stylesheet" type="text/css" href="js/web/himera.css" />
  <link rel="stylesheet" type="text/css" href="js/web/ansi.css" />
  <link rel="stylesheet" type="text/css" href="js/web/console.css" />
  <style type="text/css" media="screen">
  </style>
  <title>Mal Web REPL</title>
</head>
<body>
  <div class="container">
    <h1 id="title"><a href="https://github.com/kanaka/mal"/>Mal</a></h1>
    
    <h2>Mal Web REPL</h2>

    <!--
    <div id="editor-container" class="sixteen columns">
    <div id="tiny-note" class="tiny-note"></div>
    <textarea class="editor" id="editor">;; Develop your Mal program here.
;; Ctrl+E/Cmd+E evaluates file in the REPL.</textarea>
    </div>
    -->
    
    <div id="console-container" class="sixteen columns">
    <div class="console" id="console"></div>
    </div>
    <div class="eight columns">
    <!--
    <h3><span style="cursor: pointer" class="doc-link" id="toggle-editor">Show file editor</span></h3>
    -->
    <h3><span style="cursor: pointer" class="doc-link">&nbsp;</span></h3>
    </div>
    <div class="eight columns">
    <div class="source">
      <a href="http://github.com/kanaka/mal">View source on Github <img src="js/web/github-icon.png" /></a></p>
    </div><!-- /source -->
    </div>
    
    <div class="rule sixteen columns"></div>

	  <div class="sixteen columns">
    <h3>Mal at a glance</h3>
    </div>
    
    <div class="cheat-box-container eight columns">
      <div class="cheat-box">
        <h4>Datatypes</h4>
        <table>
          <tr class="row-one">
            <td class="row-label">Maps</td>
            <td>{"key1" "val1", "key2" 123}</td>
          </tr>
          <tr>
            <td class="row-label">Lists</td>
            <td>(1 2 3 "four")</td>
          </tr>
          <tr class="row-one">
            <td class="row-label">Vectors</td>
            <td>[1 2 3 4 "a" "b" "c" 1 2]</td>
          </tr>
          <tr>
            <td class="row-label">Scalars</td>
            <td>a-symbol, "a string", :a_keyword, 123, nil, true, false</td>
          </tr>
        </table>
      </div><!-- /cheat-box -->
      <div class="cheat-box">
        <h4>Functions</h4>
        <table>
          <tr class="row-one">
            <td class="row-label">Calling</td>
            <td>(<span class="ebnf">&lt;function&gt;</span>
	         <span class="ebnf">&lt;args*&gt;</span>)</td>
          </tr>
          <tr>
            <td class="row-label">Defining named functions</td>
            <td>(def! <span class="ebnf">&lt;name&gt;</span> 
                  (fn*
                  [<span class="ebnf">&lt;args*&gt;</span>]
                  <span class="ebnf">&lt;action&gt;</span>))</td>
          </tr>
          <tr class="row-one">
            <td class="row-label">Anonymous function</td>
            <td>(fn*
                  [<span class="ebnf">&lt;args*&gt;</span>]
                  <span class="ebnf">&lt;action&gt;</span>)</td>
          </tr>
        </table>
      </div><!-- /cheat-box -->
      <div class="cheat-box">
        <h4>Useful Macros and Special Forms</h4>
        <table>
          <tr class="row-one">
            <td class="row-label">Conditionals</td>
            <td>if cond or</td>
          </tr>
          <!--
          <tr>
            <td class="row-label">Nesting, chaining, and Interop</td>
            <td>-> ->> doto .. .</td>
          </tr>
          -->
          <tr>
            <td class="row-label">Multiple Actions (side-effects)</td>
            <td>(do 
                  <span class="ebnf">&lt;action*&gt;</span>...)</td>
          </tr>
          <tr class="row-one">
            <td class="row-label">Defining things</td>
            <td>def! defmacro! let*</td>
          </tr>
          <tr>
            <td class="row-label">Quoting</td>
            <td>' ` ~ ~@</td>
          </tr>
          <tr class="row-one">
            <td class="row-label">Examining macros</td>
            <td>macroexpand</td>
          </tr>
	</table>
      </div>
    </div><!-- /cheat-box-container -->

    <div class="cheat-box-container eight columns">
      <div class="cheat-box">
        <h4>Useful Functions</h4>
        <table>
          <tr class="row-one">
            <td class="row-label">Math</td>
            <td>+ - * /</td>
          </tr>
          <tr>
            <td class="row-label">Comparison/Boolean</td>
            <td>= < > <= >= not</td>
          </tr>
          <tr class="row-one">
            <td class="row-label">Predicates</td>
            <td>nil? true? false? symbol? keyword? string? list? vector? map? sequential?</td>
          </tr>
          <tr>
            <td class="row-label">Data processing</td>
            <td>map apply</td>
          </tr>
          <tr class="row-one">
            <td class="row-label">Data create</td>
            <td>list vector hash-map</td>
          </tr>
          <tr>
            <td class="row-label">Data inspection</td>
            <td>first rest get keys vals count get nth contains? empty?</td>
          </tr>
          <tr class="row-one">
            <td class="row-label">Data manipulation</td>
            <td>conj cons concat assoc dissoc</td>
          </tr>
          <tr>
            <td class="row-label">Lists and Vectors</td>
            <td>first rest nth seq</td></td>
          </tr>
          <tr class="row-one">
            <td class="row-label">Hash Maps</td>
            <td>get keys vals contains?</td></td>
          </tr>
          <tr>
            <td class="row-label">Strings</td>
            <td>str pr-str seq</td></td>
          </tr>
          <tr class="row-one">
            <td class="row-label">Atoms</td>
            <td>atom atom? deref[@] reset! swap!</td></td>
          </tr>
          <tr>
            <td class="row-label">Meta</td>
            <td>meta with-meta[^]</td></td>
          </tr>
          <tr class="row-one">
            <td class="row-label">Output</td>
            <td>println prn</td></td>
          </tr>
        </table>
      </div><!-- /cheat-box -->
      <div class="cheat-box">
        <h4>JavaScript Interop</h4>
        <table>
          <tr class="row-one">
            <td class="row-label">Evaluate JavaScript</td>
            <td>(js-eval "JS string to eval")</td>
          </tr>
          <tr>
            <td class="row-label">Method call/access</td>
            <td>(. js-fn arg...)</td>
          </tr>
	</table>
      </div>
    </div><!-- /cheat-box-container -->
        
    <div class="rule sixteen columns"></div>
    
    <div class="column footer-logo">
        <div>Mal &copy; 2013 Joel Martin</div>
        <div>Himera design &copy; 2012-2013 <a ref="http://www.fogus.me">Fogus</a>, <a href="http://jenmyers.net/">Jen Myers</a> and <a href="http://www.thinkrelevance.com">Relevance Inc.</a></div>
    </div>
    
  </div><!-- / container -->
  <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
  <script type="text/javascript" src="js/web/jqconsole.min.js"></script>
  <script type="text/javascript" src="js/web/mal.js"></script>
  <script>
    $(function() {
      // Creating the console.
      window.jqconsole = $('#console').jqconsole(null, 'user> ');

      printer.println = function () {
        var str = Array.prototype.join.call(arguments, " ")
        jqconsole.Write(str + "\n", 'jqconsole-output');
      }

      rep("(println (str \"Mal [\" *host-language* \"]\"))");

      jq_load_history(jqconsole);

      // Abort prompt on Ctrl+C.
      jqconsole.RegisterShortcut('C', function() {
        jqconsole.AbortPrompt();
        handler();
      });
      // Move to line start Ctrl+A.
      jqconsole.RegisterShortcut('A', function() {
        jqconsole.MoveToStart();
        handler();
      });
      // Move to line end Ctrl+E.
      jqconsole.RegisterShortcut('E', function() {
        jqconsole.MoveToEnd();
        handler();
      });
      jqconsole.RegisterMatching('{', '}', 'brace');
      jqconsole.RegisterMatching('(', ')', 'paren');
      jqconsole.RegisterMatching('[', ']', 'bracket');
      jqconsole.RegisterMatching('"', '"', 'dquote');
      // Handle a command.
      var handler = function(line) {
        if (line) {
          try {
            jqconsole.Write(rep(line) + '\n', 'jqconsole-return');
          } catch (exc) {
            if (exc instanceof reader.BlankException) { return; }
            if (exc.stack) {
              jqconsole.Write(exc.stack + '\n', 'jqconsole-error');
            } else {
              jqconsole.Write(exc + '\n', 'jqconsole-error');
            }
          }
          jq_save_history(jqconsole);
        }
        jqconsole.Prompt(true, handler);
        /*
        jqconsole.Prompt(true, handler, function(command) {
          // Continue line if can't compile the command.
          try {
            Function(command);
          } catch (e) {
            if (/[\[\{\(]$/.test(command)) {
              return 1;
            } else {
              return 0;
            }
          }
          return false;
        });
      */
      };

      // Initiate the first prompt.
      handler();
    });
  </script>

</body>
</html>

M mal/mal/Makefile => mal/mal/Makefile +0 -23
@@ 1,10 1,3 @@

TESTS =

SOURCES_BASE =
SOURCES_LISP = env.mal core.mal stepA_mal.mal
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)

all: mal.mal

mal.mal: stepA_mal.mal


@@ 12,19 5,3 @@ mal.mal: stepA_mal.mal

clean:
	rm -f mal.mal

#.PHONY: stats tests $(TESTS)
.PHONY: stats

stats: $(SOURCES)
	@wc $^
	@printf "%5s %5s %5s %s\n" `grep -E "^[[:space:]]*;|^[[:space:]]*$$" $^ | wc` "[comments/blanks]"
stats-lisp: $(SOURCES_LISP)
	@wc $^
	@printf "%5s %5s %5s %s\n" `grep -E "^[[:space:]]*;|^[[:space:]]*$$" $^ | wc` "[comments/blanks]"

#tests: $(TESTS)
#
#$(TESTS):
#	@echo "Running $@"; \
#	python $@ || exit 1; \

M mal/mal/step9_try.mal => mal/mal/step9_try.mal +4 -3
@@ 110,15 110,16 @@
              (MACROEXPAND a1 env))

            (= 'try* a0)
            (if (= 'catch* (nth (nth ast 2) 0))
            (if (or (< (count ast) 3)
                    (not (= 'catch* (nth (nth ast 2) 0))))
              (EVAL (nth ast 1) env)
              (try*
                (EVAL (nth ast 1) env)
                (catch* exc
                  (EVAL (nth (nth ast 2) 2)
                        (new-env env
                                 [(nth (nth ast 2)1)]
                                 [exc]))))
              (EVAL (nth ast 1) env))
                                 [exc])))))

            (= 'do a0)
            (let* [el (eval-ast (rest ast) env)]

M mal/mal/stepA_mal.mal => mal/mal/stepA_mal.mal +4 -3
@@ 110,15 110,16 @@
              (MACROEXPAND a1 env))

            (= 'try* a0)
            (if (= 'catch* (nth (nth ast 2) 0))
            (if (or (< (count ast) 3)
                    (not (= 'catch* (nth (nth ast 2) 0))))
              (EVAL (nth ast 1) env)
              (try*
                (EVAL (nth ast 1) env)
                (catch* exc
                  (EVAL (nth (nth ast 2) 2)
                        (new-env env
                                 [(nth (nth ast 2)1)]
                                 [exc]))))
              (EVAL (nth ast 1) env))
                                 [exc])))))

            (= 'do a0)
            (let* [el (eval-ast (rest ast) env)]

M mal/tests/step9_try.mal => mal/tests/step9_try.mal +2 -3
@@ 319,9 319,8 @@

;;
;; Testing try* without catch*
;; Disabled 2018-02-18 by Tim Morgan due to bug in the mal implementation. See: https://git.io/fhd3D
;;(try* xyz)
;;;/.*\'?xyz\'? not found.*
(try* xyz)
;/.*\'?xyz\'? not found.*

;;
;; Testing throwing non-strings