1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-20 01:57:09 +03:00

Implement step 0

This commit is contained in:
Vasilij Schneidermann 2017-09-02 00:46:52 +02:00
parent 7e9e7fbd8c
commit 244ac2d6d2
4 changed files with 65 additions and 2 deletions

View File

@ -81,8 +81,8 @@ IMPLS = ada awk bash basic c d chuck clojure coffee common-lisp cpp crystal cs d
erlang elisp elixir es6 factor forth fsharp go groovy gst guile haskell \ erlang elisp elixir es6 factor forth fsharp go groovy gst guile haskell \
haxe io java julia js kotlin logo lua make mal ocaml matlab miniMAL \ haxe io java julia js kotlin logo lua make mal ocaml matlab miniMAL \
nim objc objpascal perl perl6 php pil plpgsql plsql powershell ps \ nim objc objpascal perl perl6 php pil plpgsql plsql powershell ps \
python r racket rexx rpython ruby rust scala skew swift swift3 tcl ts vb vhdl \ python r racket rexx rpython ruby rust scala scm skew swift swift3 tcl \
vimscript livescript elm ts vb vhdl vimscript livescript elm
EXTENSION = .mal EXTENSION = .mal
@ -208,6 +208,7 @@ rpython_STEP_TO_PROG = rpython/$($(1))
ruby_STEP_TO_PROG = ruby/$($(1)).rb ruby_STEP_TO_PROG = ruby/$($(1)).rb
rust_STEP_TO_PROG = rust/target/release/$($(1)) rust_STEP_TO_PROG = rust/target/release/$($(1))
scala_STEP_TO_PROG = scala/target/scala-2.11/classes/$($(1)).class scala_STEP_TO_PROG = scala/target/scala-2.11/classes/$($(1)).class
scm_STEP_TO_PROG = scm/$($(1)).scm
skew_STEP_TO_PROG = skew/$($(1)).js skew_STEP_TO_PROG = skew/$($(1)).js
swift_STEP_TO_PROG = swift/$($(1)) swift_STEP_TO_PROG = swift/$($(1))
swift3_STEP_TO_PROG = swift3/$($(1)) swift3_STEP_TO_PROG = swift3/$($(1))

17
scm/Makefile Normal file
View File

@ -0,0 +1,17 @@
SOURCES_BASE = reader.scm printer.scm types.scm
SOURCES_LISP = env.scm func.scm core.scm stepA_mal.scm
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
all:
clean:
.PHONY: stats tests $(TESTS)
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]"

12
scm/run Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
case ${SCM_MODE:-chibi} in
chibi) exec chibi-scheme $(dirname $0)/${STEP:-stepA_mal}.scm "${@}" ;;
kawa) exec kawa --r7rs $(dirname $0)/${STEP:-stepA_mal}.scm "${@}" ;;
chicken) exec csi -R r7rs -s $(dirname $0)/${STEP:-stepA_mal}.scm "${@}" ;;
gauche) exec gosh $(dirname $0)/${STEP:-stepA_mal}.scm "${@}" ;;
picrin) exec picrin $(dirname $0)/${STEP:-stepA_mal}.scm "${@}" ;;
sagittarius) exec sagittarius -n $(dirname $0)/${STEP:-stepA_mal}.scm "${@}" ;;
cyclone) exec icyc -s $(dirname $0)/${STEP:-stepA_mal}.scm "${@}" ;;
foment) exec foment $(dirname $0)/${STEP:-stepA_mal}.scm "${@}" ;;
*) echo "Invalid SCM_MODE: ${SCM_MODE}"; exit 2 ;;
esac

33
scm/step0_repl.scm Normal file
View File

@ -0,0 +1,33 @@
(import (scheme base))
(import (scheme write))
(define (READ input)
input)
(define (EVAL input)
input)
(define (PRINT input)
input)
(define (rep input)
(PRINT (EVAL (READ input))))
(define (readline prompt)
(display prompt)
(flush-output-port)
(let ((input (read-line)))
(if (eof-object? input)
#f
input)))
(define (main)
(let loop ()
(let ((input (readline "user> ")))
(when input
(display (rep input))
(newline)
(loop))))
(newline))
(main)