diff options
| author | Joel Martin <github@martintribe.org> | 2014-04-02 22:23:37 -0500 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2014-04-02 22:23:37 -0500 |
| commit | ea81a8087bcd7953b083a2be9db447f75e7ebf56 (patch) | |
| tree | 6cf47a2dbd55d42efc4a901eaabdec952f40ce89 /bash/step2_eval.sh | |
| parent | 1617910ad342a55762f3ddabb975849d843cff85 (diff) | |
| download | mal-ea81a8087bcd7953b083a2be9db447f75e7ebf56.tar.gz mal-ea81a8087bcd7953b083a2be9db447f75e7ebf56.zip | |
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.
Diffstat (limited to 'bash/step2_eval.sh')
| -rwxr-xr-x | bash/step2_eval.sh | 10 |
1 files changed, 6 insertions, 4 deletions
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}" ;; *) |
