#!/bin/bash BASE="/usr/share/sicp/" cd ${BASE} doload="yay"; if [ -z "${1}" ]; then echo "please tell me what to load." echo echo "syntax: sicp []" echo "" echo " chapter: which sources to load, sorted by sicp chapter (1-5)" echo " part: for chapters 4 and 5, the code is split into smaller parts" echo " (to find out what parts are fine to load, simply run 'sicp 4' or 'sicp 5')" exit 1 fi; if [ "${1}" = "3" ]; then echo "SICP advises against loading this whole file." echo "Instead, you should capy & paste the parts you need." file="${BASE}/ch3support.scm ${BASE}/ch${1}.scm" elif [ "${1}" = "4" ]; then if [ -z "${2}" ]; then doload="nay" echo "The SICP sources say that you should rather load specific parts of the code for Chapter 4." echo "Possible parts are:" echo " * ambeval" echo " * leval" echo " * mceval" echo " * query" echo " * analyzingmceval" echo "Parts that depend on other parts will automatically load these." else file="${BASE}/ch${1}-${2}.scm" echo "Reminder: use" echo "(define the-global-environment (setup-environment))" echo "to set things up, and" echo "(driver-loop)" echo "to start the interpreter" fi; elif [ "${1}" = "5" ]; then if [ -z "${2}" ]; then doload="nay" echo "The SICP sources say that you should rather load specific parts of the code for Chapter 4." echo "Possible parts are:" echo " * compiler" echo " * eceval-compiler" echo " * eceval" echo " * regsim" echo "Parts that depend on other parts will automatically load these." else if [ "${2}" = "eceval-compiler" ]; then file="${BASE}/ch5-regsim.scm ${BASE}/ch5-eceval-support.scm ${BASE}/ch5-eceval-compiler.scm" echo ";; To start, you can use compile-and-go as in section 5.5.7" echo ";; or start-eceval as in the section 5.5.7 footnote." echo "" echo ";; To resume the machine without reinitializing the global environment" echo ";; if you have somehow interrupted out of the machine back to Scheme, do" echo "" echo ";: (set-register-contents! eceval 'flag false)" echo ";: (start eceval)" elif [ "${2}" = "eceval" ]; then file="${BASE}/ch5-regsim.scm ${BASE}/ch5-eceval-support.scm ${BASE}/ch5-eceval.scm" echo ";;; -- To initialize and start the machine, do" echo "" echo ";: (define the-global-environment (setup-environment))" echo "" echo ";: (start eceval)" echo "" echo ";; To restart, can do just" echo ";: (start eceval)" else file="${BASE}/ch${1}-${2}.scm" fi fi; else file="${BASE}/ch${1}.scm" fi; if [ "${doload}" = "yay" ]; then echo "SICP sources are loaded into the mzscheme interpreter. Use (exit) to quit." mzscheme --Load "${BASE}/helper.scm" ${file} fi;