Awkwardly support miniscm in tower.sh, and see it pass some tests.
catseye
13 years ago
19 | 19 | SCRIPTDIR=`dirname ${SCRIPT}` |
20 | 20 | |
21 | 21 | cd ${SCRIPTDIR}/.. |
22 | echo -n '' >t.scm | |
23 | if [ "$SCHEME" = "your-weird-scheme" ]; then | |
24 | cat >>t.scm <<EOF | |
25 | (stuff (to support your weird scheme)) | |
22 | echo -n '' >init.scm | |
23 | if [ "$SCHEME" = "miniscm" ]; then | |
24 | cat >prelude.scm <<EOF | |
25 | ;;;;; following part is written by a.k | |
26 | ||
27 | ;;;; equal? | |
28 | (define (equal? x y) | |
29 | (if (pair? x) | |
30 | (and (pair? y) | |
31 | (equal? (car x) (car y)) | |
32 | (equal? (cdr x) (cdr y))) | |
33 | (and (not (pair? y)) | |
34 | (eqv? x y)))) | |
35 | ||
36 | ;;;;; following part is written by c.p. | |
37 | ||
38 | (define (list? x) (or (eq? x '()) (and (pair? x) (list? (cdr x))))) | |
26 | 39 | EOF |
40 | cat <prelude.scm >>init.scm | |
27 | 41 | fi |
28 | cat <src/tower.scm >>t.scm | |
42 | cat <src/tower.scm >>init.scm | |
29 | 43 | |
30 | echo '(define tower (make-tower (quote (' >>t.scm | |
44 | echo '(define tower (make-tower (quote (' >>init.scm | |
31 | 45 | for SEXPFILE do |
32 | cat $SEXPFILE >>t.scm | |
46 | cat $SEXPFILE >>init.scm | |
33 | 47 | done |
34 | echo '))))' >>t.scm | |
48 | echo '))))' >>init.scm | |
35 | 49 | |
36 | 50 | if [ "${USE_EVAL}" = "yes" ]; then |
37 | cat >>t.scm <<EOF | |
51 | cat >>init.scm <<EOF | |
38 | 52 | (eval tower (scheme-report-environment 5)) |
39 | 53 | EOF |
40 | ${SCHEME} t.scm | |
54 | ${SCHEME} init.scm | |
55 | elif [ "${SCHEME}" = "miniscm" ]; then | |
56 | echo '(display tower) (quit)' >>init.scm | |
57 | cat <prelude.scm >next.scm | |
58 | echo '(display' >>next.scm | |
59 | ${SCHEME} -q >>next.scm | |
60 | echo ') (newline) (quit)' >>next.scm | |
61 | mv next.scm init.scm | |
62 | ${SCHEME} -q | |
41 | 63 | else |
42 | cat >>t.scm <<EOF | |
64 | cat >>init.scm <<EOF | |
43 | 65 | (display tower) |
44 | 66 | EOF |
45 | 67 | echo >init.scm '(display' |
46 | ${SCHEME} t.scm >>init.scm | |
47 | echo >>init.scm ') (newline)' | |
48 | ${SCHEME} init.scm | |
68 | ${SCHEME} init.scm >>output.scm | |
69 | echo >>output.scm ') (newline)' | |
70 | ${SCHEME} output.scm | |
49 | 71 | fi |
50 | 72 | |
51 | rm -f t.scm init.scm | |
73 | rm -f init.scm output.scm prelude.scm |
20 | 20 | ; wrap the current sexp with it as an interpreter -> current sexp |
21 | 21 | ; you now have a sexp that you can evaluate as Scheme |
22 | 22 | |
23 | (define subst | |
24 | (lambda (sexp src dest) | |
25 | (cond | |
26 | ((equal? sexp src) | |
27 | dest) | |
28 | ((null? sexp) | |
29 | '()) | |
30 | ((list? sexp) | |
31 | (cons (subst (car sexp) src dest) (subst (cdr sexp) src dest))) | |
32 | (else | |
33 | sexp)))) | |
34 | ||
23 | 35 | (define wrap-sexp |
24 | 36 | (lambda (wrapee-sexp wrapper-sexp) |
25 | `(let* ((interpret ,wrapper-sexp) | |
26 | (sexp (quote ,wrapee-sexp))) | |
27 | (interpret sexp)))) | |
37 | (subst | |
38 | (subst (quote (let* ((interpret wrapper-sexp) | |
39 | (sexp (quote wrapee-sexp))) | |
40 | (interpret sexp))) | |
41 | (quote wrapper-sexp) wrapper-sexp) | |
42 | (quote wrapee-sexp) wrapee-sexp))) | |
28 | 43 | |
29 | 44 | (define tower-rec |
30 | 45 | (lambda (sexp-tower sexp) |
30 | 30 | |
31 | 31 | # On my computer, the following test takes about 19 seconds on plt-r5rs, but |
32 | 32 | # about 32 minutes with tinyscheme -- possibly because of frequent GC? |
33 | # Meanwhile, it breaks miniscm completely. | |
33 | 34 | |
34 | 35 | # echo "Testing Pixley programs on (Pixley reference interpreter)^3..." |
35 | 36 | # falderal test -f 'Interpret Pixley Program:shell command "script/tower.sh src/pixley.pix src/pixley.pix src/pixley.pix %(test) >%(output)"' src/tests.falderal |
40 | 41 | # echo "Testing Pixley programs on (Pixley reference interpreter)^4..." |
41 | 42 | # time falderal test -f 'Interpret Pixley Program:shell command "script/tower.sh src/pixley.pix src/pixley.pix src/pixley.pix src/pixley.pix %(test) >%(output)"' src/tests.falderal |
42 | 43 | |
43 | # Tinyscheme doesn't pass this yet, because it insists on abbreviating quote | |
44 | # forms in its output. | |
44 | # Tinyscheme and minischeme don't pass this yet, because they insist on | |
45 | # abbreviating quote forms in their output. | |
45 | 46 | echo "Running Falderal tests for P-Normalizer..." |
46 | 47 | falderal test dialect/p-normal.falderal |
47 | 48 | |
67 | 68 | |
68 | 69 | echo "Testing Crabwell-specific programs..." |
69 | 70 | falderal test -f 'Interpret Crabwell Program:shell command "script/tower.sh dialect/crabwell.pix %(test) >%(output)"' dialect/crabwell.falderal |
70 | ||
71 | # Optional Mini-Scheme tests | |
72 | ||
73 | echo 'quit' | miniscm >/dev/null 2>&1 | |
74 | if [ $? = 0 ] | |
75 | then | |
76 | echo "Right on, you have miniscm installed. Testing Pixley on it..." | |
77 | cd src | |
78 | cat >expected.out <<EOF | |
79 | > a | |
80 | > | |
81 | EOF | |
82 | echo '(pixley2 (quote (let* ((a (quote a))) a)))' | miniscm 2>&1 | grep '^>' > miniscm.out | |
83 | diff -u expected.out miniscm.out | |
84 | rm -f expected.out miniscm.out | |
85 | cd .. | |
86 | else | |
87 | echo "miniscm not installed, skipping. Your loss I guess." | |
88 | fi |