git @ Cat's Eye Technologies Pixley / 153c5b6
Generalize tower.sh more; we have some success with tinyscheme now. catseye 13 years ago
3 changed file(s) with 47 addition(s) and 30 deletion(s). Raw diff Collapse all Expand all
33
44 # See tower.scm for documentation.
55
6 if [ "${R5RS}x" = "x" ]; then
7 R5RS=plt-r5rs
6 if [ "${SCHEME}x" = "x" ]; then
7 SCHEME=plt-r5rs
8 fi
9
10 if [ "${USE_EVAL}x" = "x" ]; then
11 USE_EVAL=yes
12 fi
13
14 if [ "${SCHEME}" = "miniscm" -o "${SCHEME}" = "tinyscheme" ]; then
15 USE_EVAL=no
816 fi
917
1018 SCRIPT=`realpath $0`
1119 SCRIPTDIR=`dirname ${SCRIPT}`
1220
1321 cd ${SCRIPTDIR}/..
14 echo -n '' >init.scm
15 if [ $R5RS = your-weird-scheme ]; then
16 cat >>init.scm <<EOF
22 echo -n '' >t.scm
23 if [ "$SCHEME" = "your-weird-scheme" ]; then
24 cat >>t.scm <<EOF
1725 (stuff (to support your weird scheme))
1826 EOF
1927 fi
20 cat <src/tower.scm >>init.scm
21 echo '(tower (quote (' >>init.scm
28 cat <src/tower.scm >>t.scm
29
30 echo '(define tower (make-tower (quote (' >>t.scm
2231 for SEXPFILE do
23 cat $SEXPFILE >>init.scm
32 cat $SEXPFILE >>t.scm
2433 done
25 echo ')))' >>init.scm
34 echo '))))' >>t.scm
2635
27 ${R5RS} init.scm
28 rm -f init.scm
36 if [ "${USE_EVAL}" = "yes" ]; then
37 cat >>t.scm <<EOF
38 (eval tower (scheme-report-environment 5))
39 EOF
40 ${SCHEME} t.scm
41 else
42 cat >>t.scm <<EOF
43 (display tower)
44 EOF
45 echo >init.scm '(display'
46 ${SCHEME} t.scm >>init.scm
47 echo >>init.scm ') (newline)'
48 ${SCHEME} init.scm
49 fi
50
51 rm -f t.scm init.scm
1818 ; while there are sexps remaining on the tower:
1919 ; pop the top sexp off the tower
2020 ; wrap the current sexp with it as an interpreter -> current sexp
21 ; evaluate current sexp as Scheme
21 ; you now have a sexp that you can evaluate as Scheme
2222
2323 (define wrap-sexp
2424 (lambda (wrapee-sexp wrapper-sexp)
2929 (define tower-rec
3030 (lambda (sexp-tower sexp)
3131 (if (null? sexp-tower)
32 (eval sexp (scheme-report-environment 5))
32 sexp
3333 (let* ((interpreter-sexp (car sexp-tower))
3434 (rest (cdr sexp-tower)))
3535 (tower-rec rest (wrap-sexp sexp interpreter-sexp))))))
3636
37 (define tower
37 (define make-tower
3838 (lambda (sexp-tower)
3939 (let* ((sexp-tower (reverse sexp-tower)))
4040 (if (null? sexp-tower)
2020 rm -f expected.sexp out.sexp
2121
2222 echo "Testing Pixley programs as Scheme programs..."
23
2423 falderal test -f 'Interpret Pixley Program:shell command "script/tower.sh %(test) >%(output)"' src/tests.falderal
2524
2625 echo "Testing Pixley programs on Pixley reference interpreter..."
27
2826 falderal test -f 'Interpret Pixley Program:shell command "script/tower.sh src/pixley.pix %(test) >%(output)"' src/tests.falderal
2927
30 echo "Testing Pixley programs on (Pixley reference interpreter)^2..."
31
28 echo "Testing Pixley programs on Pixley interpreter on Pixley interpreter..."
3229 falderal test -f 'Interpret Pixley Program:shell command "script/tower.sh src/pixley.pix src/pixley.pix %(test) >%(output)"' src/tests.falderal
3330
34 echo "Testing Pixley programs on (Pixley reference interpreter)^3..."
31 # On my computer, the following test takes about 19 seconds on plt-r5rs, but
32 # about 32 minutes with tinyscheme -- possibly because of frequent GC?
3533
36 # Takes about 19 seconds on plt-r5rs on my computer
37 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
34 # echo "Testing Pixley programs on (Pixley reference interpreter)^3..."
35 # 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
3836
39 # If you have an hour or so to kill, you can try the next level up!
37 # And if you have an hour or so to kill, you can try the next level up!
38 # (That's with plt-r5rs; I imagine tinyscheme would take much longer)
39
4040 # echo "Testing Pixley programs on (Pixley reference interpreter)^4..."
4141 # 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
4242
43 # Tinyscheme doesn't pass this yet, because it insists on abbreviating quote
44 # forms in its output.
4345 echo "Running Falderal tests for P-Normalizer..."
44
4546 falderal test dialect/p-normal.falderal
4647
4748 echo "P-Normalizing Pixley interpreter..."
48
4949 script/tower.sh src/pixley.pix dialect/p-normal.pix src/pixley.pix > src/p-normal-pixley.pix
5050
5151 echo "Testing Pixley programs on P-Normalized interpreter..."
52
5352 falderal test -f 'Interpret Pixley Program:shell command "script/tower.sh src/p-normal-pixley.pix %(test) >%(output)"' src/tests.falderal
5453
5554 rm -f src/p-normal-pixley.pix
5655
5756 echo "Testing Pixley programs on Pixley interpreter in Pifxley..."
58
5957 falderal test -f 'Interpret Pixley Program:shell command "script/tower.sh dialect/pixley.pifx %(test) >%(output)"' src/tests.falderal
6058
6159 echo "Testing Pifxley programs as Scheme..."
62
6360 falderal test -f 'Interpret Pifxley Program:shell command "script/tower.sh %(test) >%(output)"' dialect/pifxley.falderal
6461
6562 echo "Testing Pifxley programs on Pifxley interpreter in Pifxley..."
66
6763 falderal test -f 'Interpret Pifxley Program:shell command "script/tower.sh dialect/pifxley.pifx %(test) >%(output)"' dialect/pifxley.falderal
6864
6965 echo "Testing Pixley programs on Crabwell interpreter..."
70
7166 falderal test -f 'Interpret Pixley Program:shell command "script/tower.sh dialect/crabwell.pix %(test) >%(output)"' src/tests.falderal
7267
7368 echo "Testing Crabwell-specific programs..."
74
7569 falderal test -f 'Interpret Crabwell Program:shell command "script/tower.sh dialect/crabwell.pix %(test) >%(output)"' dialect/crabwell.falderal
7670
7771 # Optional Mini-Scheme tests