From ea81a8087bcd7953b083a2be9db447f75e7ebf56 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Wed, 2 Apr 2014 22:23:37 -0500 Subject: All: split types into types, env, printer, core. - types: low-level mapping to the implementation language. - core: functions on types that are exposed directly to mal. - printer: implementation called by pr-str, str, prn, println. - env: the environment implementation - Also, unindent all TCO while loops so that the diff of step4 and step5 are minimized. --- bash/step2_eval.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'bash/step2_eval.sh') diff --git a/bash/step2_eval.sh b/bash/step2_eval.sh index 4d571e4..0f03a79 100755 --- a/bash/step2_eval.sh +++ b/bash/step2_eval.sh @@ -3,6 +3,8 @@ INTERACTIVE=${INTERACTIVE-yes} source $(dirname $0)/reader.sh +source $(dirname $0)/printer.sh +source $(dirname $0)/core.sh # READ: read and parse input READ () { @@ -20,17 +22,17 @@ EVAL_AST () { eval r="\${${env}["${val}"]}" [ "${r}" ] || _error "'${val}' not found" ;; list) - _map_with_type list EVAL "${ast}" "${env}" ;; + _map_with_type _list EVAL "${ast}" "${env}" ;; vector) - _map_with_type vector EVAL "${ast}" "${env}" ;; + _map_with_type _vector EVAL "${ast}" "${env}" ;; hash_map) local res="" val="" hm="${ANON["${ast}"]}" - hash_map; local new_hm="${r}" + _hash_map; local new_hm="${r}" eval local keys="\${!${hm}[@]}" for key in ${keys}; do eval val="\${${hm}[\"${key}\"]}" EVAL "${val}" "${env}" - assoc! "${new_hm}" "${key}" "${r}" + _assoc! "${new_hm}" "${key}" "${r}" done r="${new_hm}" ;; *) -- cgit v1.2.3