mirror of
https://github.com/kanaka/mal.git
synced 2024-10-26 14:22:25 +03:00
Merge remote-tracking branch 'upstream/master' into r7rs-implementation
This commit is contained in:
commit
d209e68a49
12
.travis.yml
12
.travis.yml
@ -14,8 +14,8 @@ matrix:
|
||||
- {env: IMPL=coffee, services: [docker]}
|
||||
- {env: IMPL=cs, services: [docker]}
|
||||
- {env: IMPL=chuck, services: [docker]}
|
||||
- {env: IMPL=clojure CLJ_MODE=clj, services: [docker]}
|
||||
- {env: IMPL=clojure CLJ_MODE=cljs, services: [docker]}
|
||||
- {env: IMPL=clojure clojure_MODE=clj, services: [docker]}
|
||||
- {env: IMPL=clojure clojure_MODE=cljs, services: [docker]}
|
||||
- {env: IMPL=common-lisp, services: [docker]}
|
||||
- {env: IMPL=crystal, services: [docker]}
|
||||
- {env: IMPL=d, services: [docker]}
|
||||
@ -33,7 +33,10 @@ matrix:
|
||||
- {env: IMPL=gst, services: [docker]}
|
||||
- {env: IMPL=guile, services: [docker]}
|
||||
- {env: IMPL=haskell, services: [docker]}
|
||||
- {env: IMPL=haxe, services: [docker]}
|
||||
- {env: IMPL=haxe haxe_MODE=neko, services: [docker]}
|
||||
- {env: IMPL=haxe haxe_MODE=python, services: [docker]}
|
||||
- {env: IMPL=haxe haxe_MODE=cpp, services: [docker]}
|
||||
- {env: IMPL=haxe haxe_MODE=js, services: [docker]}
|
||||
- {env: IMPL=io, services: [docker]}
|
||||
- {env: IMPL=java, services: [docker]}
|
||||
- {env: IMPL=js, services: [docker]}
|
||||
@ -59,7 +62,8 @@ matrix:
|
||||
# - {env: IMPL=plsql, services: [docker]}
|
||||
- {env: IMPL=ps, services: [docker]}
|
||||
- {env: IMPL=powershell, services: [docker]}
|
||||
- {env: IMPL=python, services: [docker]}
|
||||
- {env: IMPL=python python_MODE=python2, services: [docker]}
|
||||
- {env: IMPL=python python_MODE=python3, services: [docker]}
|
||||
- {env: IMPL=r, services: [docker]}
|
||||
- {env: IMPL=racket, services: [docker]}
|
||||
- {env: IMPL=rexx, services: [docker]}
|
||||
|
@ -4,6 +4,9 @@ set -ex
|
||||
|
||||
BUILD_IMPL=${BUILD_IMPL:-${IMPL}}
|
||||
|
||||
mode_var=${IMPL}_MODE
|
||||
mode_val=${!mode_var}
|
||||
|
||||
# If NO_DOCKER is blank then launch use a docker image, otherwise
|
||||
# use the Travis image/tools directly.
|
||||
if [ -z "${NO_DOCKER}" ]; then
|
||||
@ -21,9 +24,9 @@ if [ -z "${NO_DOCKER}" ]; then
|
||||
make -C ${BUILD_IMPL} step9_try || true
|
||||
fi
|
||||
docker run -it -u $(id -u) -v `pwd`:/mal kanaka/mal-test-${img_impl} \
|
||||
make CLJ_MODE=${CLJ_MODE} \
|
||||
make ${mode_val:+${mode_var}=${mode_val}} \
|
||||
-C ${BUILD_IMPL}
|
||||
else
|
||||
make CLJ_MODE=${CLJ_MODE} \
|
||||
make ${mode_val:+${mode_var}=${mode_val}} \
|
||||
-C ${BUILD_IMPL}
|
||||
fi
|
||||
|
@ -6,6 +6,9 @@ ACTION=${1}
|
||||
IMPL=${2}
|
||||
MAL_IMPL=${3:-js}
|
||||
|
||||
mode_var=${IMPL}_MODE
|
||||
mode_val=${!mode_var}
|
||||
|
||||
echo "ACTION: ${ACTION}"
|
||||
echo "IMPL: ${IMPL}"
|
||||
echo "MAL_IMPL: ${MAL_IMPL}"
|
||||
@ -23,7 +26,7 @@ fi
|
||||
|
||||
${MAKE} TEST_OPTS="--debug-file ../${ACTION}.err" \
|
||||
MAL_IMPL=${MAL_IMPL} \
|
||||
CLJ_MODE=${CLJ_MODE} \
|
||||
${mode_val:+${mode_var}=${mode_val}} \
|
||||
${ACTION}^${IMPL}
|
||||
|
||||
# no failure so remove error log
|
||||
|
43
Makefile
43
Makefile
@ -44,12 +44,14 @@ all help:
|
||||
|
||||
MAL_IMPL = js
|
||||
|
||||
PYTHON = python
|
||||
USE_MATLAB =
|
||||
# python, js, cpp, or neko are currently supported
|
||||
HAXE_MODE = neko
|
||||
# clj or cljs are currently supported (Clojure vs ClojureScript/lumo)
|
||||
CLJ_MODE = clj
|
||||
# clj or cljs (Clojure vs ClojureScript/lumo)
|
||||
clojure_MODE = clj
|
||||
# python, js, cpp, or neko
|
||||
haxe_MODE = neko
|
||||
# octave or matlab
|
||||
matlab_MODE = octave
|
||||
# python, python2 or python3
|
||||
python_MODE = python
|
||||
|
||||
# Extra options to pass to runtest.py
|
||||
TEST_OPTS =
|
||||
@ -159,7 +161,7 @@ basic_STEP_TO_PROG = basic/$($(1)).bas
|
||||
c_STEP_TO_PROG = c/$($(1))
|
||||
d_STEP_TO_PROG = d/$($(1))
|
||||
chuck_STEP_TO_PROG = chuck/$($(1)).ck
|
||||
clojure_STEP_TO_PROG = $(clojure_STEP_TO_PROG_$(CLJ_MODE))
|
||||
clojure_STEP_TO_PROG = $(clojure_STEP_TO_PROG_$(clojure_MODE))
|
||||
coffee_STEP_TO_PROG = coffee/$($(1)).coffee
|
||||
common-lisp_STEP_TO_PROG = common-lisp/$($(1))
|
||||
cpp_STEP_TO_PROG = cpp/$($(1))
|
||||
@ -178,7 +180,7 @@ groovy_STEP_TO_PROG = groovy/$($(1)).groovy
|
||||
gst_STEP_TO_PROG = gst/$($(1)).st
|
||||
java_STEP_TO_PROG = java/target/classes/mal/$($(1)).class
|
||||
haskell_STEP_TO_PROG = haskell/$($(1))
|
||||
haxe_STEP_TO_PROG = $(haxe_STEP_TO_PROG_$(HAXE_MODE))
|
||||
haxe_STEP_TO_PROG = $(haxe_STEP_TO_PROG_$(haxe_MODE))
|
||||
io_STEP_TO_PROG = io/$($(1)).io
|
||||
julia_STEP_TO_PROG = julia/$($(1)).jl
|
||||
js_STEP_TO_PROG = js/$($(1)).js
|
||||
@ -238,15 +240,17 @@ actual_impl = $(if $(filter mal,$(1)),$(MAL_IMPL),$(1))
|
||||
# Returns nothing if DOCKERIZE is not set, otherwise returns the
|
||||
# docker prefix necessary to run make within the docker environment
|
||||
# for this impl
|
||||
get_build_prefix = $(strip $(if $(strip $(DOCKERIZE)),\
|
||||
get_build_command = $(strip $(if $(strip $(DOCKERIZE)),\
|
||||
docker run \
|
||||
-it --rm -u $(shell id -u) \
|
||||
-v $(dir $(abspath $(lastword $(MAKEFILE_LIST)))):/mal \
|
||||
-w /mal/$(1) \
|
||||
$(if $(filter clojure,$(1)),-e CLJ_MODE=$(CLJ_MODE),) \
|
||||
$(if $(strip $($(1)_MODE)),-e $(1)_MODE=$($(1)_MODE),) \
|
||||
$(if $(filter factor,$(1)),-e FACTOR_ROOTS=$(FACTOR_ROOTS),) \
|
||||
$(call impl_to_image,$(1)) \
|
||||
,))
|
||||
$(MAKE) $(if $(strip $($(1)_MODE)),$(1)_MODE=$($(1)_MODE),) \
|
||||
,\
|
||||
$(MAKE) $(if $(strip $($(1)_MODE)),$(1)_MODE=$($(1)_MODE),)))
|
||||
|
||||
# Takes impl and step arguments
|
||||
# Returns a command prefix (docker command and environment variables)
|
||||
@ -256,14 +260,13 @@ get_run_prefix = $(strip $(if $(strip $(DOCKERIZE)),\
|
||||
-it --rm -u $(shell id -u) \
|
||||
-v $(dir $(abspath $(lastword $(MAKEFILE_LIST)))):/mal \
|
||||
-w /mal/$(call actual_impl,$(1)) \
|
||||
$(if $(filter clojure,$(1)),-e CLJ_MODE=$(CLJ_MODE),) \
|
||||
$(if $(filter haxe,$(1)),-e HAXE_MODE=$(HAXE_MODE),) \
|
||||
$(if $(strip $($(1)_MODE)),-e $(1)_MODE=$($(1)_MODE),) \
|
||||
$(if $(filter factor,$(1)),-e FACTOR_ROOTS=$(FACTOR_ROOTS),) \
|
||||
$(foreach env,$(3),-e $(env)) \
|
||||
$(call impl_to_image,$(call actual_impl,$(1))) \
|
||||
,\
|
||||
env STEP=$($2) MAL_IMPL=$(MAL_IMPL) \
|
||||
$(if $(filter haxe,$(1)),HAXE_MODE=$(HAXE_MODE),) \
|
||||
$(if $(strip $($(1)_MODE)),$(1)_MODE=$($(1)_MODE),) \
|
||||
$(if $(filter factor,$(1)),FACTOR_ROOTS=$(FACTOR_ROOTS),) \
|
||||
$(3)))
|
||||
|
||||
@ -313,8 +316,8 @@ ALL_REPL = $(strip $(sort \
|
||||
$(foreach i,$(DO_IMPLS),$(foreach s,$(STEPS),$(call $(i)_STEP_TO_PROG,$(s)))):
|
||||
$(foreach impl,$(word 1,$(subst /, ,$(@))),\
|
||||
$(if $(DOCKERIZE), \
|
||||
$(call get_build_prefix,$(impl)) $(MAKE) $(patsubst $(impl)/%,%,$(@)), \
|
||||
$(MAKE) -C $(impl) $(subst $(impl)/,,$(@))))
|
||||
$(call get_build_command,$(impl)) $(patsubst $(impl)/%,%,$(@)), \
|
||||
$(call get_build_command,$(impl)) -C $(impl) $(subst $(impl)/,,$(@))))
|
||||
|
||||
# Allow IMPL, and IMPL^STEP
|
||||
.SECONDEXPANSION:
|
||||
@ -441,10 +444,10 @@ $(2):
|
||||
@echo "----------------------------------------------"; \
|
||||
$$(foreach impl,$$(word 2,$$(subst ^, ,$$(@))),\
|
||||
$$(if $$(DOCKERIZE), \
|
||||
echo "Running: $$(call get_build_prefix,$$(impl))$$(MAKE) --no-print-directory $(1)"; \
|
||||
$$(call get_build_prefix,$$(impl))$$(MAKE) --no-print-directory $(1), \
|
||||
echo "Running: $$(MAKE) --no-print-directory -C $$(impl) $(1)"; \
|
||||
$$(MAKE) --no-print-directory -C $$(impl) $(1)))
|
||||
echo "Running: $$(call get_build_command,$$(impl)) --no-print-directory $(1)"; \
|
||||
$$(call get_build_command,$$(impl)) --no-print-directory $(1), \
|
||||
echo "Running: $$(call get_build_command,$$(impl)) --no-print-directory -C $$(impl) $(1)"; \
|
||||
$$(call get_build_command,$$(impl)) --no-print-directory -C $$(impl) $(1)))
|
||||
endef
|
||||
|
||||
recur_impls_ = $(filter-out $(foreach impl,$($(1)_EXCLUDES),$(1)^$(impl)),$(foreach impl,$(IMPLS),$(1)^$(impl)))
|
||||
|
23
README.md
23
README.md
@ -17,7 +17,7 @@ Mal is implemented in 69 languages:
|
||||
* C#
|
||||
* ChucK
|
||||
* Common Lisp
|
||||
* Clojure
|
||||
* Clojure (Clojure and ClojureScript)
|
||||
* CoffeeScript
|
||||
* Crystal
|
||||
* D
|
||||
@ -35,7 +35,7 @@ Mal is implemented in 69 languages:
|
||||
* GNU Guile
|
||||
* GNU Smalltalk
|
||||
* Haskell
|
||||
* Haxe
|
||||
* Haxe (Neko, Python, C++ and JavaScript)
|
||||
* Io
|
||||
* Java
|
||||
* JavaScript ([Online Demo](http://kanaka.github.io/mal))
|
||||
@ -46,7 +46,7 @@ Mal is implemented in 69 languages:
|
||||
* Lua
|
||||
* GNU Make
|
||||
* mal itself
|
||||
* MATLAB
|
||||
* Matlab (GNU Octave and MATLAB)
|
||||
* [miniMAL](https://github.com/kanaka/miniMAL)
|
||||
* Nim
|
||||
* Object Pascal
|
||||
@ -60,7 +60,7 @@ Mal is implemented in 69 languages:
|
||||
* PL/SQL (Oracle)
|
||||
* Postscript
|
||||
* PowerShell
|
||||
* Python
|
||||
* Python (2.X and 3.X)
|
||||
* RPython
|
||||
* R
|
||||
* Racket
|
||||
@ -479,7 +479,7 @@ make
|
||||
./stepX_YYY
|
||||
```
|
||||
|
||||
### Haxe
|
||||
### Haxe (Neko, Python, C++ and JavaScript)
|
||||
|
||||
The Haxe implementation of mal requires Haxe version 3.2 to compile.
|
||||
Four different Haxe targets are supported: Neko, Python, C++, and
|
||||
@ -653,18 +653,19 @@ make
|
||||
./stepX_YYY
|
||||
```
|
||||
|
||||
### MATLAB
|
||||
### MatLab (GNU Octave and MATLAB)
|
||||
|
||||
The MATLAB implementation of mal has been tested with MATLAB version
|
||||
R2014a on Linux. Note that MATLAB is a commercial product. It should
|
||||
be fairly simple to support GNU Octave once it support classdef object
|
||||
syntax.
|
||||
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
|
||||
MATLAB is a commercial product.
|
||||
|
||||
```
|
||||
cd matlab
|
||||
./stepX_YYY
|
||||
octave -q --no-gui --no-history --eval "stepX_YYY();quit;"
|
||||
matlab -nodisplay -nosplash -nodesktop -nojvm -r "stepX_YYY();quit;"
|
||||
# OR with command line arguments
|
||||
octave -q --no-gui --no-history --eval "stepX_YYY('arg1','arg2');quit;"
|
||||
matlab -nodisplay -nosplash -nodesktop -nojvm -r "stepX_YYY('arg1','arg2');quit;"
|
||||
```
|
||||
|
||||
@ -785,7 +786,7 @@ cd powershell
|
||||
powershell ./stepX_YYY.ps1
|
||||
```
|
||||
|
||||
### Python (2.X or 3.X)
|
||||
### Python (2.X and 3.X)
|
||||
|
||||
```
|
||||
cd python
|
||||
|
@ -1,13 +1,13 @@
|
||||
CLJ_MODE ?= clj
|
||||
SOURCES_UTIL = src/mal/readline.$(CLJ_MODE)
|
||||
clojure_MODE ?= clj
|
||||
SOURCES_UTIL = src/mal/readline.$(clojure_MODE)
|
||||
SOURCES_BASE = $(SOURCES_UTIL) src/mal/printer.cljc
|
||||
SOURCES_LISP = src/mal/env.cljc src/mal/core.cljc src/mal/stepA_mal.cljc
|
||||
SRCS = $(SOURCES_BASE) src/mal/env.cljc src/mal/core.cljc
|
||||
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
|
||||
|
||||
DEPS = $(if $(filter cljs,$(CLJ_MODE)),node_modules,deps)
|
||||
DEPS = $(if $(filter cljs,$(clojure_MODE)),node_modules,deps)
|
||||
|
||||
dist: mal.jar mal
|
||||
dist: $(if $(filter cljs,$(clojure_MODE)),,mal.jar mal)
|
||||
|
||||
deps:
|
||||
lein deps
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
export PATH=$PATH:$(dirname $0)/node_modules/.bin
|
||||
STEP=${STEP:-stepA_mal}
|
||||
if [ "${CLJ_MODE}" = "cljs" ]; then
|
||||
if [ "${clojure_MODE}" = "cljs" ]; then
|
||||
exec lumo -c $(dirname $0)/src -m mal.${STEP//_/-} "${@}"
|
||||
else
|
||||
exec java -jar $(dirname $0)/target/${STEP}.jar "${@}"
|
||||
|
@ -8,12 +8,12 @@ STEPS = 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
|
||||
|
||||
HAXE_DIST_MODE = neko
|
||||
haxe_MODE ?= neko
|
||||
dist_neko = mal.n
|
||||
dist_python = mal.py
|
||||
dist_cpp = cpp/mal
|
||||
|
||||
all: all-neko all-python all-cpp all-js
|
||||
all: all-$(haxe_MODE)
|
||||
|
||||
all-neko: $(foreach x,$(STEPS),$(x).n)
|
||||
|
||||
@ -38,18 +38,18 @@ mal.js: stepA_mal.js
|
||||
cp $< $@
|
||||
|
||||
|
||||
mal: $(dist_$(HAXE_DIST_MODE))
|
||||
$(if $(filter cpp,$(HAXE_DIST_MODE)),\
|
||||
mal: $(dist_$(haxe_MODE))
|
||||
$(if $(filter cpp,$(haxe_MODE)),\
|
||||
cp $< $@;,\
|
||||
$(if $(filter neko,$(HAXE_DIST_MODE)),\
|
||||
$(if $(filter neko,$(haxe_MODE)),\
|
||||
nekotools boot $<;,\
|
||||
$(if $(filter js,$(HAXE_DIST_MODE)),\
|
||||
$(if $(filter js,$(haxe_MODE)),\
|
||||
echo "#!/usr/bin/env node" > $@;\
|
||||
cat $< >> $@;,\
|
||||
$(if $(filter python,$(HAXE_DIST_MODE)),\
|
||||
$(if $(filter python,$(haxe_MODE)),\
|
||||
echo "#!/usr/bin/env python3" > $@;\
|
||||
cat $< >> $@;,\
|
||||
$(error Invalid HAXE_DIST_MODE: $(HAXE_DIST_MODE))))))
|
||||
$(error Invalid haxe_MODE: $(haxe_MODE))))))
|
||||
chmod +x $@
|
||||
|
||||
|
||||
|
4
haxe/run
4
haxe/run
@ -1,8 +1,8 @@
|
||||
#!/bin/bash
|
||||
case ${HAXE_MODE:-neko} in
|
||||
case ${haxe_MODE:-neko} in
|
||||
neko) exec neko $(dirname $0)/${STEP:-stepA_mal}.n "${@}" ;;
|
||||
python) exec python3 $(dirname $0)/${STEP:-stepA_mal}.py "${@}" ;;
|
||||
js) exec node $(dirname $0)/${STEP:-stepA_mal}.js "${@}" ;;
|
||||
cpp) exec $(dirname $0)/cpp/${STEP:-stepA_mal} "${@}" ;;
|
||||
*) echo "Invalid HAXE_MODE: ${HAXE_MODE}"; exit 2 ;;
|
||||
*) echo "Invalid haxe_MODE: ${haxe_MODE}"; exit 2 ;;
|
||||
esac
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM ubuntu:vivid
|
||||
FROM ubuntu:xenial
|
||||
MAINTAINER Joel Martin <github@martintribe.org>
|
||||
|
||||
##########################################################
|
||||
@ -22,8 +22,8 @@ WORKDIR /mal
|
||||
##########################################################
|
||||
|
||||
# Java and maven deps
|
||||
RUN apt-get -y install openjdk-7-jdk
|
||||
RUN apt-get -y install maven2
|
||||
RUN apt-get -y install openjdk-8-jdk
|
||||
RUN apt-get -y install maven
|
||||
ENV MAVEN_OPTS -Duser.home=/mal
|
||||
|
||||
# GNU Octave
|
||||
@ -32,3 +32,4 @@ RUN apt-get -y install software-properties-common && \
|
||||
apt-get -y update && \
|
||||
apt-get -y install octave
|
||||
|
||||
ENV HOME /mal
|
||||
|
@ -6,8 +6,8 @@ if [ "$#" -gt 0 ]; then
|
||||
args="$args,'$a'"
|
||||
done
|
||||
fi
|
||||
if [ -n "$USE_MATLAB" ] ; then
|
||||
if [ "$matlab_MODE" = "matlab" ] ; then
|
||||
exec matlab -nodisplay -nosplash -nodesktop -nojvm -r "${STEP:-stepA_mal}($args);quit;"
|
||||
else
|
||||
exec octave --no-gui --no-history -q --traditional --eval "${STEP:-stepA_mal}($args);quit;"
|
||||
exec octave -q --no-gui --no-history --eval "${STEP:-stepA_mal}($args);quit;"
|
||||
fi
|
||||
|
@ -1,2 +1,2 @@
|
||||
#!/bin/bash
|
||||
exec python $(dirname $0)/${STEP:-stepA_mal}.py "${@}"
|
||||
exec ${python_MODE:-python} $(dirname $0)/${STEP:-stepA_mal}.py "${@}"
|
||||
|
Loading…
Reference in New Issue
Block a user