git @ Cat's Eye Technologies Pixley / 8dda7e4
Awkwardly support miniscm in tower.sh, and see it pass some tests. catseye 13 years ago
3 changed file(s) with 58 addition(s) and 39 deletion(s). Raw diff Collapse all Expand all
1919 SCRIPTDIR=`dirname ${SCRIPT}`
2020
2121 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)))))
2639 EOF
40 cat <prelude.scm >>init.scm
2741 fi
28 cat <src/tower.scm >>t.scm
42 cat <src/tower.scm >>init.scm
2943
30 echo '(define tower (make-tower (quote (' >>t.scm
44 echo '(define tower (make-tower (quote (' >>init.scm
3145 for SEXPFILE do
32 cat $SEXPFILE >>t.scm
46 cat $SEXPFILE >>init.scm
3347 done
34 echo '))))' >>t.scm
48 echo '))))' >>init.scm
3549
3650 if [ "${USE_EVAL}" = "yes" ]; then
37 cat >>t.scm <<EOF
51 cat >>init.scm <<EOF
3852 (eval tower (scheme-report-environment 5))
3953 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
4163 else
42 cat >>t.scm <<EOF
64 cat >>init.scm <<EOF
4365 (display tower)
4466 EOF
4567 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
4971 fi
5072
51 rm -f t.scm init.scm
73 rm -f init.scm output.scm prelude.scm
2020 ; wrap the current sexp with it as an interpreter -> current sexp
2121 ; you now have a sexp that you can evaluate as Scheme
2222
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
2335 (define wrap-sexp
2436 (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)))
2843
2944 (define tower-rec
3045 (lambda (sexp-tower sexp)
3030
3131 # On my computer, the following test takes about 19 seconds on plt-r5rs, but
3232 # about 32 minutes with tinyscheme -- possibly because of frequent GC?
33 # Meanwhile, it breaks miniscm completely.
3334
3435 # echo "Testing Pixley programs on (Pixley reference interpreter)^3..."
3536 # 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
4041 # echo "Testing Pixley programs on (Pixley reference interpreter)^4..."
4142 # 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
4243
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.
4546 echo "Running Falderal tests for P-Normalizer..."
4647 falderal test dialect/p-normal.falderal
4748
6768
6869 echo "Testing Crabwell-specific programs..."
6970 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