#!/usr/bin/env bash source $[dirname $0]/reader.sh source $[dirname $0]/printer.sh source $[dirname $0]/env.sh source $[dirname $0]/core.sh # read proc READ { test $(1) && global r := $(1) || READLINE READ_STR $(r) } # eval proc IS_PAIR { if _sequential? $(1) { _count $(1) [[ "${r}" > 0 ]] && return 0 } return 1 } proc QUASIQUOTE { if ! IS_PAIR $(1) { _symbol quote _list $(r) $(1) return } else { _nth $(1) 0; var a0 = $(r) if [[ "${ANON["${a0}"]}" == "unquote" ]] { _nth $(1) 1 return } elif IS_PAIR $(a0) { _nth $(a0) 0; var a00 = $(r) if [[ "${ANON["${a00}"]}" == "splice-unquote" ]] { _symbol concat; var a = $(r) _nth $(a0) 1; var b = $(r) _rest $(1) QUASIQUOTE $(r); var c = $(r) _list $(a) $(b) $(c) return } } } _symbol cons; var a = $(r) QUASIQUOTE $(a0); var b = $(r) _rest $(1) QUASIQUOTE $(r); var c = $(r) _list $(a) $(b) $(c) return } proc IS_MACRO_CALL { if ! _list? $(1) { return 1; } _nth $(1) 0; var a0 = $(r) if _symbol? $(a0) { ENV_FIND $(2) $(a0) if [[ "${r}" ]] { ENV_GET $(2) $(a0) test $(ANON["${r}_ismacro_"]) return $? } } return 1 } proc MACROEXPAND { var ast = $(1), env = $(2) while IS_MACRO_CALL "${ast}" "${env}" { _nth $(ast) 0; var a0 = $(r) ENV_GET $(env) $(a0); var mac = $(ANON["${r}"]) _rest $(ast) $(mac%%@*) $(ANON["${r}"]) ast := $(r) } global r := $(ast) } proc EVAL_AST { var ast = $(1), env = $(2) #_pr_str "${ast}"; echo "EVAL_AST '${ast}:${r} / ${env}'" _obj_type $(ast); var ot = $(r) matchstr $(ot) { symbol { ENV_GET $(env) $(ast) return } list { _map_with_type _list EVAL $(ast) $(env) } vector { _map_with_type _vector EVAL $(ast) $(env) } hash_map { var res = '',"" key = '', val = '',"" hm = $(ANON["${ast}"]) _hash_map; var new_hm = $(r) eval local keys="\${!$(hm)[@]}" for key in [$(keys)] { eval val="\${$(hm)[\"$(key)\"]}" EVAL $(val) $(env) _assoc! $(new_hm) $(key) $(r) } global r := $(new_hm) } * { global r := $(ast) } } } proc EVAL { var ast = $(1), env = $(2) while true { global r := '' [[ "${__ERROR}" ]] && return 1 #_pr_str "${ast}"; echo "EVAL '${r} / ${env}'" if ! _list? $(ast) { EVAL_AST $(ast) $(env) return } # apply list MACROEXPAND $(ast) $(env) ast := $(r) if ! _list? $(ast) { EVAL_AST $(ast) $(env) return } _empty? $(ast) && global r := $(ast) && return _nth $(ast) 0; var a0 = $(r) _nth $(ast) 1; var a1 = $(r) _nth $(ast) 2; var a2 = $(r) matchstr $(ANON["${a0}"]) { def! { EVAL $(a2) $(env) [[ "${__ERROR}" ]] && return 1 ENV_SET $(env) $(a1) $(r) return } let* { ENV $(env); var let_env = $(r) var let_pairs = '('${ANON["${a1}"]}) var idx = '0' #echo "let: [${let_pairs[*]}] for ${a2}" while [[ "${let_pairs["${idx}"]}" ]] { EVAL $(let_pairs[$(( idx + 1))]) $(let_env) ENV_SET $(let_env) $(let_pairs[${idx}]) $(r) idx := $( idx + 2) } ast := $(a2) env := $(let_env) # Continue loop } quote { global r := $(a1) return } quasiquote { QUASIQUOTE $(a1) ast := $(r) # Continue loop } defmacro! { EVAL $(a2) $(env) [[ "${__ERROR}" ]] && return 1 ANON["$(r)_ismacro_"]="yes" ENV_SET $(env) $(a1) $(r) return } macroexpand { MACROEXPAND $(a1) $(env) return } sh* { EVAL $(a1) $(env) var output = ''"" var line = ''"" while read line { output := ""$(output)$(line)"\n" } < <(eval ${ANON["${r}"]}) _string $(output%\\n) return } try* { EVAL $(a1) $(env) [[ -z "${__ERROR}" ]] && return _nth $(a2) 0; var a20 = $(r) if test $(ANON["${a20}"]) == "catch__STAR__" { _nth $(a2) 1; var a21 = $(r) _nth $(a2) 2; var a22 = $(r) _list $(a21); var binds = $(r) ENV $(env) $(binds) $(__ERROR) var try_env = $(r) global __ERROR := '' EVAL $(a22) $(try_env) } # if no catch* clause, just propagate __ERROR return } do { _count $(ast) _slice $(ast) 1 $( ${r} - 2 ) EVAL_AST $(r) $(env) [[ "${__ERROR}" ]] && global r := '' && return 1 _last $(ast) ast := $(r) # Continue loop } if { EVAL $(a1) $(env) [[ "${__ERROR}" ]] && return 1 if [[ "${r}" == "${__false}" || "${r}" == "${__nil}" ]] { # eval false form _nth $(ast) 3; var a3 = $(r) if [[ "${a3}" ]] { ast := $(a3) } else { global r := $(__nil) return } } else { # eval true condition ast := $(a2) } # Continue loop } fn* { _function "ENV \"$(env)\" \"$(a1)\" \"\${@}\"; \ EVAL \"$(a2)\" \"\${r}\"" \ $(a2) $(env) $(a1) return } * { EVAL_AST $(ast) $(env) [[ "${__ERROR}" ]] && global r := '' && return 1 var el = $(r) _first $(el); var f = $(ANON["${r}"]) _rest $(el); var args = $(ANON["${r}"]) #echo "invoke: [${f}] ${args}" if [[ "${f//@/ }" != "${f}" ]] { set -- $(f//@/ ) ast := $(2) ENV $(3) $(4) $(args) env := $(r) } else { eval $(f%%@*) $(args) return } # Continue loop } } } } # print proc PRINT { if [[ "${__ERROR}" ]] { _pr_str $(__ERROR) yes global r := ""Error: $(r)"" global __ERROR := '' } else { _pr_str $(1) yes } } # repl ENV; global REPL_ENV := $(r) proc REP { global r := '' READ $(1) EVAL $(r) $(REPL_ENV) PRINT $(r) } # core.sh: defined using bash proc _fref { _symbol $(1); var sym = $(r) _function "$(2) \"\${@}\"" ENV_SET $(REPL_ENV) $(sym) $(r) } for n in [$(!core_ns[@])] { _fref $(n) $(core_ns["${n}"]); } proc _eval { EVAL $(1) $(REPL_ENV); } _fref "eval" _eval _list; global argv := $(r) for _arg in [$(@:2)] { _string $(_arg); _conj! $(argv) $(r); } _symbol "__STAR__ARGV__STAR__" ENV_SET $(REPL_ENV) $(r) $(argv); # core.mal: defined using the language itself REP "(def! *host-language* \"bash\")" REP "(def! not (fn* (a) (if a false true)))" REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" REP "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))" REP "(def! *gensym-counter* (atom 0))" REP "(def! gensym (fn* [] (symbol (str \"G__\" (swap! *gensym-counter* (fn* [x] (+ 1 x)))))))" REP "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) \`(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))" # load/run file from command line (then exit) if [[ "${1}" ]] { REP "(load-file \"$(1)\")" exit 0 } # repl loop REP "(println (str \"Mal [\" *host-language* \"]\"))" while true { READLINE "user> " || exit "$Status" [[ "${r}" ]] && REP $(r) && echo $(r) } (CommandList children: [ (C {(source)} { (CommandSubPart command_list: (CommandList children:[(C {(dirname)} {($ VSub_Number "$0")})]) left_token: spids: [6 10] ) (/reader.sh) } ) (C {(source)} { (CommandSubPart command_list: (CommandList children:[(C {(dirname)} {($ VSub_Number "$0")})]) left_token: spids: [15 19] ) (/printer.sh) } ) (C {(source)} { (CommandSubPart command_list: (CommandList children:[(C {(dirname)} {($ VSub_Number "$0")})]) left_token: spids: [24 28] ) (/env.sh) } ) (C {(source)} { (CommandSubPart command_list: (CommandList children:[(C {(dirname)} {($ VSub_Number "$0")})]) left_token: spids: [33 37] ) (/core.sh) } ) (FuncDef name: READ body: (BraceGroup children: [ (AndOr children: [ (C {(Lit_Other "[")} {(DQ (${ VSub_Number 1))} {(Lit_Other "]")}) (AndOr children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:r) op: Equal rhs: {(DQ (${ VSub_Number 1))} spids: [64] ) ] spids: [64] ) (C {(READLINE)}) ] op_id: Op_DPipe ) ] op_id: Op_DAmp ) (C {(READ_STR)} {(DQ (${ VSub_Name r))}) ] spids: [49] ) spids: [44 48] ) (FuncDef name: IS_PAIR body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(_sequential) (Lit_Other "?")} {(DQ (${ VSub_Number 1))}) terminator: ) ] action: [ (C {(_count)} {(DQ (${ VSub_Number 1))}) (AndOr children: [ (DBracket expr: (BoolBinary op_id:Redir_Great left:{(DQ (${ VSub_Name r))} right:{(0)}) ) (ControlFlow token: arg_word: {(0)} ) ] op_id: Op_DAmp ) ] spids: [-1 110] ) ] spids: [-1 143] ) (ControlFlow token: arg_word:{(1)}) ] spids: [95] ) spids: [90 94] ) (FuncDef name: QUASIQUOTE body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [(C {(IS_PAIR)} {(DQ (${ VSub_Number 1))})] negated: True ) terminator: ) ] action: [ (C {(_symbol)} {(quote)}) (C {(_list)} {(DQ (${ VSub_Name r))} {(DQ (${ VSub_Number 1))}) (ControlFlow token:) ] spids: [-1 174] ) ] else_action: [ (Sentence child: (C {(_nth)} {(DQ (${ VSub_Number 1))} {(0)}) terminator: ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:a0) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [216] ) ] spids: [214] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: { (DQ (BracedVarSub token: bracket_op: (ArrayIndex expr: (ArithWord w:{(DQ (${ VSub_Name a0))}) ) spids: [229 238] ) ) } right: {(DQ (unquote))} ) ) terminator: ) ] action: [ (C {(_nth)} {(DQ (${ VSub_Number 1))} {(1)}) (ControlFlow token:) ] spids: [-1 250] ) (if_arm cond: [ (Sentence child: (C {(IS_PAIR)} {(DQ (${ VSub_Name a0))}) terminator: ) ] action: [ (Sentence child: (C {(_nth)} {(DQ (${ VSub_Name a0))} {(0)}) terminator: ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:a00) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [294] ) ] spids: [292] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: { (DQ (BracedVarSub token: bracket_op: (ArrayIndex expr: (ArithWord w:{(DQ (${ VSub_Name a00))}) ) spids: [307 316] ) ) } right: {(DQ (splice-unquote))} ) ) terminator: ) ] action: [ (Sentence child: (C {(_symbol)} {(concat)}) terminator: ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:a) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [338] ) ] spids: [336] ) (Sentence child: (C {(_nth)} {(DQ (${ VSub_Name a0))} {(1)}) terminator: ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:b) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [359] ) ] spids: [357] ) (C {(_rest)} {(DQ (${ VSub_Number 1))}) (Sentence child: (C {(QUASIQUOTE)} {(DQ (${ VSub_Name r))}) terminator: ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:c) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [387] ) ] spids: [385] ) (C {(_list)} {(DQ (${ VSub_Name a))} {(DQ (${ VSub_Name b))} {(DQ (${ VSub_Name c))} ) (ControlFlow token: ) ] spids: [-1 328] ) ] spids: [-1 419] ) ] spids: [267 278] ) ] spids: [-1 422] ) ] spids: [200 425] ) (Sentence child:(C {(_symbol)} {(cons)}) terminator:) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:a) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [435] ) ] spids: [433] ) (Sentence child: (C {(QUASIQUOTE)} {(DQ (${ VSub_Name a0))}) terminator: ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:b) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [454] ) ] spids: [452] ) (C {(_rest)} {(DQ (${ VSub_Number 1))}) (Sentence child: (C {(QUASIQUOTE)} {(DQ (${ VSub_Name r))}) terminator: ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:c) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [482] ) ] spids: [480] ) (C {(_list)} {(DQ (${ VSub_Name a))} {(DQ (${ VSub_Name b))} {(DQ (${ VSub_Name c))}) (ControlFlow token:) ] spids: [158] ) spids: [153 157] ) (FuncDef name: IS_MACRO_CALL body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [(C {(_list) (Lit_Other "?")} {(DQ (${ VSub_Number 1))})] negated: True ) terminator: ) ] action: [ (Sentence child: (ControlFlow token: arg_word:{(1)}) terminator: ) ] spids: [-1 538] ) ] spids: [-1 545] ) (Sentence child: (C {(_nth)} {(DQ (${ VSub_Number 1))} {(0)}) terminator: ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:a0) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [561] ) ] spids: [559] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(_symbol) (Lit_Other "?")} {(DQ (${ VSub_Name a0))}) terminator: ) ] action: [ (C {(ENV_FIND)} {(DQ (${ VSub_Number 2))} {(DQ (${ VSub_Name a0))}) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr:(WordTest w:{(DQ (${ VSub_Name r))})) terminator: ) ] action: [ (C {(ENV_GET)} {(DQ (${ VSub_Number 2))} {(DQ (${ VSub_Name a0))}) (C {(Lit_Other "[")} { (DQ (BracedVarSub token: bracket_op: (ArrayIndex expr: (ArithWord w:{(DQ (${ VSub_Name r) (_ismacro_))}) ) spids: [633 643] ) ) } {(Lit_Other "]")} ) (ControlFlow token: arg_word: {($ VSub_QMark "$?")} ) ] spids: [-1 612] ) ] spids: [-1 654] ) ] spids: [-1 581] ) ] spids: [-1 657] ) (ControlFlow token: arg_word:{(1)}) ] spids: [521] ) spids: [516 520] ) (FuncDef name: MACROEXPAND body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:ast) op: Equal rhs: {(DQ (${ VSub_Number 1))} spids: [677] ) (assign_pair lhs: (LhsName name:env) op: Equal rhs: {(DQ (${ VSub_Number 2))} spids: [684] ) ] spids: [675] ) (While cond: [ (Sentence child: (C {(IS_MACRO_CALL)} {(DQ (${ VSub_Name ast))} {(DQ (${ VSub_Name env))}) terminator: ) ] body: (DoGroup children: [ (Sentence child: (C {(_nth)} {(DQ (${ VSub_Name ast))} {(0)}) terminator: ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:a0) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [725] ) ] spids: [723] ) (Sentence child: (C {(ENV_GET)} {(DQ (${ VSub_Name env))} {(DQ (${ VSub_Name a0))}) terminator: ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:mac) op: Equal rhs: { (DQ (BracedVarSub token: bracket_op: (ArrayIndex expr:(ArithWord w:{(DQ (${ VSub_Name r))})) spids: [752 761] ) ) } spids: [750] ) ] spids: [748] ) (C {(_rest)} {(DQ (${ VSub_Name ast))}) (C { (BracedVarSub token: suffix_op: (StringUnary op_id:VOp1_DPercent arg_word:{("@*")}) spids: [774 778] ) } { (BracedVarSub token: bracket_op: (ArrayIndex expr:(ArithWord w:{(DQ (${ VSub_Name r))})) spids: [780 789] ) } ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ast) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [792] ) ] spids: [792] ) ] spids: [709 800] ) ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:r) op: Equal rhs: {(DQ (${ VSub_Name ast))} spids: [803] ) ] spids: [803] ) ] spids: [672] ) spids: [667 671] ) (FuncDef name: EVAL_AST body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:ast) op: Equal rhs: {(DQ (${ VSub_Number 1))} spids: [824] ) (assign_pair lhs: (LhsName name:env) op: Equal rhs: {(DQ (${ VSub_Number 2))} spids: [831] ) ] spids: [822] ) (Sentence child: (C {(_obj_type)} {(DQ (${ VSub_Name ast))}) terminator: ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:ot) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [854] ) ] spids: [852] ) (Case to_match: {(DQ (${ VSub_Name ot))} arms: [ (case_arm pat_list: [{(symbol)}] action: [ (C {(ENV_GET)} {(DQ (${ VSub_Name env))} {(DQ (${ VSub_Name ast))}) (ControlFlow token:) ] spids: [873 874 894 -1] ) (case_arm pat_list: [{(list)}] action: [ (C {(_map_with_type)} {(_list)} {(EVAL)} {(DQ (${ VSub_Name ast))} {(DQ (${ VSub_Name env))} ) ] spids: [897 898 919 -1] ) (case_arm pat_list: [{(vector)}] action: [ (C {(_map_with_type)} {(_vector)} {(EVAL)} {(DQ (${ VSub_Name ast))} {(DQ (${ VSub_Name env))} ) ] spids: [922 923 944 -1] ) (case_arm pat_list: [{(hash_map)}] action: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:res) op: Equal rhs: {(DQ )} spids: [953] ) (assign_pair lhs: (LhsName name:key) op: Equal rhs: {(SQ )} spids: [957] ) (assign_pair lhs: (LhsName name:val) op: Equal rhs: {(DQ )} spids: [959] ) (assign_pair lhs: (LhsName name:hm) op: Equal rhs: { (DQ (BracedVarSub token: bracket_op: (ArrayIndex expr:(ArithWord w:{(DQ (${ VSub_Name ast))})) spids: [965 974] ) ) } spids: [963] ) ] spids: [951] ) (Sentence child:(C {(_hash_map)}) terminator:) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:new_hm) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [983] ) ] spids: [981] ) (C {(eval)} {(Assign_Local local)} {(Lit_VarLike "keys=") (DQ (EscapedLiteralPart token:) ("{!") (${ VSub_Name hm) ("[@]}") ) } ) (ForEach iter_name: key iter_words: [{(${ VSub_Name keys)}] do_arg_iter: False body: (DoGroup children: [ (C {(eval)} {(Lit_VarLike "val=") (DQ (EscapedLiteralPart token:) ("{") (${ VSub_Name hm) ("[") (EscapedLiteralPart token:) (${ VSub_Name key) (EscapedLiteralPart token: ) ("]}") ) } ) (C {(EVAL)} {(DQ (${ VSub_Name val))} {(DQ (${ VSub_Name env))}) (C {(_assoc) (KW_Bang "!")} {(DQ (${ VSub_Name new_hm))} {(DQ (${ VSub_Name key))} {(DQ (${ VSub_Name r))} ) ] spids: [1017 1076] ) spids: [1011 1015] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:r) op: Equal rhs: {(DQ (${ VSub_Name new_hm))} spids: [1079] ) ] spids: [1079] ) ] spids: [947 948 1086 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:r) op: Equal rhs: {(DQ (${ VSub_Name ast))} spids: [1093] ) ] spids: [1093] ) ] spids: [1089 1090 1100 -1] ) ] spids: [862 870 1103] ) ] spids: [819] ) spids: [814 818] ) (FuncDef name: EVAL body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:ast) op: Equal rhs: {(DQ (${ VSub_Number 1))} spids: [1118] ) (assign_pair lhs: (LhsName name:env) op: Equal rhs: {(DQ (${ VSub_Number 2))} spids: [1125] ) ] spids: [1116] ) (While cond: [(Sentence child:(C {(true)}) terminator:)] body: (DoGroup children: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:r) op:Equal rhs:{(SQ )} spids:[1141])] spids: [1141] ) (AndOr children: [ (DBracket expr: (WordTest w:{(DQ (${ VSub_Name __ERROR))}) ) (ControlFlow token: arg_word: {(1)} ) ] op_id: Op_DAmp ) (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [(C {(_list) (Lit_Other "?")} {(DQ (${ VSub_Name ast))})] negated: True ) terminator: ) ] action: [ (C {(EVAL_AST)} {(DQ (${ VSub_Name ast))} {(DQ (${ VSub_Name env))}) (ControlFlow token: ) ] spids: [-1 1179] ) ] spids: [-1 1200] ) (C {(MACROEXPAND)} {(DQ (${ VSub_Name ast))} {(DQ (${ VSub_Name env))}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ast) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [1223] ) ] spids: [1223] ) (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [(C {(_list) (Lit_Other "?")} {(DQ (${ VSub_Name ast))})] negated: True ) terminator: ) ] action: [ (C {(EVAL_AST)} {(DQ (${ VSub_Name ast))} {(DQ (${ VSub_Name env))}) (ControlFlow token: ) ] spids: [-1 1245] ) ] spids: [-1 1266] ) (AndOr children: [ (C {(_empty) (Lit_Other "?")} {(DQ (${ VSub_Name ast))}) (AndOr children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:r) op: Equal rhs: {(DQ (${ VSub_Name ast))} spids: [1280] ) ] spids: [1280] ) (ControlFlow token: ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) (Sentence child: (C {(_nth)} {(DQ (${ VSub_Name ast))} {(0)}) terminator: ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:a0) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [1306] ) ] spids: [1304] ) (Sentence child: (C {(_nth)} {(DQ (${ VSub_Name ast))} {(1)}) terminator: ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:a1) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [1327] ) ] spids: [1325] ) (Sentence child: (C {(_nth)} {(DQ (${ VSub_Name ast))} {(2)}) terminator: ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:a2) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [1348] ) ] spids: [1346] ) (Case to_match: { (DQ (BracedVarSub token: bracket_op: (ArrayIndex expr:(ArithWord w:{(DQ (${ VSub_Name a0))})) spids: [1359 1368] ) ) } arms: [ (case_arm pat_list: [{(def) (KW_Bang "!")}] action: [ (C {(EVAL)} {(DQ (${ VSub_Name a2))} {(DQ (${ VSub_Name env))}) (AndOr children: [ (DBracket expr: (WordTest w:{(DQ (${ VSub_Name __ERROR))}) ) (ControlFlow token: arg_word: {(1)} ) ] op_id: Op_DAmp ) (C {(ENV_SET)} {(DQ (${ VSub_Name env))} {(DQ (${ VSub_Name a1))} {(DQ (${ VSub_Name r))} ) (ControlFlow token: ) ] spids: [1374 1376 1433 -1] ) (case_arm pat_list: [{(let) (Lit_Other "*")}] action: [ (Sentence child: (C {(ENV)} {(DQ (${ VSub_Name env))}) terminator: ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:let_env) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [1451] ) ] spids: [1449] ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:let_pairs) op: Equal rhs: { (ArrayLiteralPart words: [ { (BracedVarSub token: bracket_op: (ArrayIndex expr: (ArithWord w:{(DQ (${ VSub_Name a1))}) ) spids: [1463 1472] ) } ] ) } spids: [1461] ) ] spids: [1459] ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:idx) op: Equal rhs: {(0)} spids: [1478] ) ] spids: [1476] ) (While cond: [ (Sentence child: (DBracket expr: (WordTest w: { (DQ (BracedVarSub token: bracket_op: (ArrayIndex expr: (ArithWord w:{(DQ (${ VSub_Name idx))}) ) spids: [1491 1500] ) ) } ) ) terminator: ) ] body: (DoGroup children: [ (C {(EVAL)} { (DQ (BracedVarSub token: bracket_op: (ArrayIndex expr: (ArithWord w: { (ArithSubPart anode: (ArithBinary op_id: Arith_Plus left: (ArithVarRef name:idx) right: (ArithWord w:{(Lit_Digits 1)}) ) spids: [1515 1523] ) } ) ) spids: [1512 1525] ) ) } {(DQ (${ VSub_Name let_env))} ) (C {(ENV_SET)} {(DQ (${ VSub_Name let_env))} { (DQ (BracedVarSub token: bracket_op: (ArrayIndex expr: (ArithWord w:{(${ VSub_Name idx)}) ) spids: [1544 1551] ) ) } {(DQ (${ VSub_Name r))} ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:idx) op: Equal rhs: { (ArithSubPart anode: (ArithBinary op_id: Arith_Plus left: (ArithVarRef name:idx) right: (ArithWord w:{(Lit_Digits 2)}) ) spids: [1562 1570] ) } spids: [1561] ) ] spids: [1561] ) ] spids: [1506 1573] ) ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ast) op: Equal rhs: {(DQ (${ VSub_Name a2))} spids: [1576] ) ] spids: [1576] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:env) op: Equal rhs: {(DQ (${ VSub_Name let_env))} spids: [1584] ) ] spids: [1584] ) ] spids: [1436 1438 1596 -1] ) (case_arm pat_list: [{(quote)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:r) op: Equal rhs: {(DQ (${ VSub_Name a1))} spids: [1603] ) ] spids: [1603] ) (ControlFlow token: ) ] spids: [1599 1600 1613 -1] ) (case_arm pat_list: [{(quasiquote)}] action: [ (C {(QUASIQUOTE)} {(DQ (${ VSub_Name a1))}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ast) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [1629] ) ] spids: [1629] ) ] spids: [1616 1617 1641 -1] ) (case_arm pat_list: [{(defmacro) (KW_Bang "!")}] action: [ (C {(EVAL)} {(DQ (${ VSub_Name a2))} {(DQ (${ VSub_Name env))}) (AndOr children: [ (DBracket expr: (WordTest w:{(DQ (${ VSub_Name __ERROR))}) ) (ControlFlow token: arg_word: {(1)} ) ] op_id: Op_DAmp ) (C {(ANON) (Lit_Other "[") (DQ (${ VSub_Name r) (_ismacro_)) (Lit_Other "]") (Lit_Other "=") (DQ (yes)) } ) (C {(ENV_SET)} {(DQ (${ VSub_Name env))} {(DQ (${ VSub_Name a1))} {(DQ (${ VSub_Name r))} ) (ControlFlow token: ) ] spids: [1644 1646 1719 -1] ) (case_arm pat_list: [{(macroexpand)}] action: [ (C {(MACROEXPAND)} {(DQ (${ VSub_Name a1))} {(DQ (${ VSub_Name env))}) (ControlFlow token: ) ] spids: [1722 1723 1743 -1] ) (case_arm pat_list: [{(sh) (Lit_Other "*")}] action: [ (C {(EVAL)} {(DQ (${ VSub_Name a1))} {(DQ (${ VSub_Name env))}) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:output) op: Equal rhs: {(DQ )} spids: [1767] ) ] spids: [1765] ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:line) op: Equal rhs: {(DQ )} spids: [1774] ) ] spids: [1772] ) (While cond: [(Sentence child:(C {(read)} {(line)}) terminator:)] body: (DoGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:output) op: Equal rhs: { (DQ (${ VSub_Name output) (${ VSub_Name line) (EscapedLiteralPart token: ) ) } spids: [1789] ) ] spids: [1789] ) ] spids: [1786 1801] ) redirects: [ (Redir op_id: Redir_Less fd: -1 arg_word: { (CommandSubPart command_list: (CommandList children: [ (C {(eval)} { (BracedVarSub token: bracket_op: (ArrayIndex expr: (ArithWord w:{(DQ (${ VSub_Name r))}) ) spids: [1808 1817] ) } ) ] ) left_token: spids: [1805 1818] ) } spids: [1803] ) ] ) (C {(_string)} { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id: VOp1_Percent arg_word: {(EscapedLiteralPart token:) (n)} ) spids: [1824 1829] ) ) } ) (ControlFlow token: ) ] spids: [1746 1748 1835 -1] ) (case_arm pat_list: [{(try) (Lit_Other "*")}] action: [ (C {(EVAL)} {(DQ (${ VSub_Name a1))} {(DQ (${ VSub_Name env))}) (AndOr children: [ (DBracket expr: (BoolUnary op_id: BoolUnary_z child: {(DQ (${ VSub_Name __ERROR))} ) ) (ControlFlow token: ) ] op_id: Op_DAmp ) (Sentence child: (C {(_nth)} {(DQ (${ VSub_Name a2))} {(0)}) terminator: ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:a20) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [1887] ) ] spids: [1885] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} { (DQ (BracedVarSub token: bracket_op: (ArrayIndex expr: (ArithWord w:{(DQ (${ VSub_Name a20))}) ) spids: [1900 1909] ) ) } {(Lit_Other "=") (Lit_Other "=")} {(DQ (catch__STAR__))} {(Lit_Other "]")} ) terminator: ) ] action: [ (Sentence child: (C {(_nth)} {(DQ (${ VSub_Name a2))} {(1)}) terminator: ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:a21) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [1938] ) ] spids: [1936] ) (Sentence child: (C {(_nth)} {(DQ (${ VSub_Name a2))} {(2)}) terminator: ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:a22) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [1959] ) ] spids: [1957] ) (Sentence child: (C {(_list)} {(DQ (${ VSub_Name a21))}) terminator: ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:binds) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [1978] ) ] spids: [1976] ) (C {(ENV)} {(DQ (${ VSub_Name env))} {(DQ (${ VSub_Name binds))} {(DQ (${ VSub_Name __ERROR))} ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:try_env) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [2009] ) ] spids: [2007] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:__ERROR) op: Equal rhs: {(SQ )} spids: [2017] ) ] spids: [2017] ) (C {(EVAL)} {(DQ (${ VSub_Name a22))} {(DQ (${ VSub_Name try_env))}) ] spids: [-1 1922] ) ] spids: [-1 2035] ) (ControlFlow token: ) ] spids: [1838 1840 2043 -1] ) (case_arm pat_list: [{(KW_Do do)}] action: [ (C {(_count)} {(DQ (${ VSub_Name ast))}) (C {(_slice)} {(DQ (${ VSub_Name ast))} {(1)} { (ArithSubPart anode: (ArithBinary op_id: Arith_Minus left: (ArithWord w:{(${ VSub_Name r)}) right: (ArithWord w:{(Lit_Digits 2)}) ) spids: [2068 2079] ) } ) (C {(EVAL_AST)} {(DQ (${ VSub_Name r))} {(DQ (${ VSub_Name env))}) (AndOr children: [ (DBracket expr: (WordTest w:{(DQ (${ VSub_Name __ERROR))}) ) (AndOr children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:r) op: Equal rhs: {(SQ )} spids: [2109] ) ] spids: [2109] ) (ControlFlow token: arg_word: {(1)} ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) (C {(_last)} {(DQ (${ VSub_Name ast))}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ast) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [2127] ) ] spids: [2127] ) ] spids: [2046 2047 2139 -1] ) (case_arm pat_list: [{(KW_If if)}] action: [ (C {(EVAL)} {(DQ (${ VSub_Name a1))} {(DQ (${ VSub_Name env))}) (AndOr children: [ (DBracket expr: (WordTest w:{(DQ (${ VSub_Name __ERROR))}) ) (ControlFlow token: arg_word: {(1)} ) ] op_id: Op_DAmp ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (LogicalOr left: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ (${ VSub_Name r))} right: {(DQ (${ VSub_Name __false))} ) right: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ (${ VSub_Name r))} right: {(DQ (${ VSub_Name __nil))} ) ) ) terminator: ) ] action: [ (Sentence child: (C {(_nth)} {(DQ (${ VSub_Name ast))} {(3)}) terminator: ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:a3) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [2234] ) ] spids: [2232] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (WordTest w:{(DQ (${ VSub_Name a3))}) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ast) op: Equal rhs: {(DQ (${ VSub_Name a3))} spids: [2258] ) ] spids: [2258] ) ] spids: [-1 2255] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:r) op: Equal rhs: {(DQ (${ VSub_Name __nil))} spids: [2269] ) ] spids: [2269] ) (ControlFlow token: ) ] spids: [2266 2280] ) ] spids: [-1 2214] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ast) op: Equal rhs: {(DQ (${ VSub_Name a2))} spids: [2290] ) ] spids: [2290] ) ] spids: [2283 2298] ) ] spids: [2142 2143 2305 -1] ) (case_arm pat_list: [{(fn) (Lit_Other "*")}] action: [ (C {(_function)} { (DQ ("ENV ") (EscapedLiteralPart token:) (${ VSub_Name env) (EscapedLiteralPart token:) (" ") (EscapedLiteralPart token: ) (${ VSub_Name a1) (EscapedLiteralPart token:) (" ") (EscapedLiteralPart token: ) (EscapedLiteralPart token:) ("{@}") (EscapedLiteralPart token: ) ("; ") (" EVAL ") (EscapedLiteralPart token:) (${ VSub_Name a2) (EscapedLiteralPart token:) (" ") (EscapedLiteralPart token: ) (EscapedLiteralPart token:) ("{r}") (EscapedLiteralPart token: ) ) } {(DQ (${ VSub_Name a2))} {(DQ (${ VSub_Name env))} {(DQ (${ VSub_Name a1))} ) (ControlFlow token: ) ] spids: [2308 2310 2370 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [ (C {(EVAL_AST)} {(DQ (${ VSub_Name ast))} {(DQ (${ VSub_Name env))}) (AndOr children: [ (DBracket expr: (WordTest w:{(DQ (${ VSub_Name __ERROR))}) ) (AndOr children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:r) op: Equal rhs: {(SQ )} spids: [2403] ) ] spids: [2403] ) (ControlFlow token: arg_word: {(1)} ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:el) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [2414] ) ] spids: [2412] ) (Sentence child: (C {(_first)} {(DQ (${ VSub_Name el))}) terminator: ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:f) op: Equal rhs: { (DQ (BracedVarSub token: bracket_op: (ArrayIndex expr: (ArithWord w:{(DQ (${ VSub_Name r))}) ) spids: [2435 2444] ) ) } spids: [2433] ) ] spids: [2431] ) (Sentence child: (C {(_rest)} {(DQ (${ VSub_Name el))}) terminator: ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:args) op: Equal rhs: { (DQ (BracedVarSub token: bracket_op: (ArrayIndex expr: (ArithWord w:{(DQ (${ VSub_Name r))}) ) spids: [2461 2470] ) ) } spids: [2459] ) ] spids: [2457] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobNEqual left: { (DQ (BracedVarSub token: suffix_op: (PatSub pat: {("@")} replace: {(" ")} do_all: True do_prefix: False do_suffix: False ) spids: [2483 2490] ) ) } right: {(DQ (${ VSub_Name f))} ) ) terminator: ) ] action: [ (C {(set)} {(--)} { (BracedVarSub token: suffix_op: (PatSub pat: {("@")} replace: {(" ")} do_all: True do_prefix: False do_suffix: False ) spids: [2511 2518] ) } ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ast) op: Equal rhs: {(DQ (${ VSub_Number 2))} spids: [2521] ) ] spids: [2521] ) (C {(ENV)} {(DQ (${ VSub_Number 3))} {(DQ (${ VSub_Number 4))} {(${ VSub_Name args)} ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:env) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [2548] ) ] spids: [2548] ) ] spids: [-1 2504] ) ] else_action: [ (C {(eval)} { (BracedVarSub token: suffix_op: (StringUnary op_id:VOp1_DPercent arg_word:{("@*")}) spids: [2561 2565] ) } {(${ VSub_Name args)} ) (ControlFlow token: ) ] spids: [2556 2575] ) ] spids: [2373 2374 2582 -1] ) ] spids: [1356 1371 2585] ) ] spids: [1138 2588] ) ) ] spids: [1113] ) spids: [1108 1112] ) (FuncDef name: PRINT body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr:(WordTest w:{(DQ (${ VSub_Name __ERROR))})) terminator: ) ] action: [ (C {(_pr_str)} {(DQ (${ VSub_Name __ERROR))} {(yes)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:r) op: Equal rhs: {(DQ ("Error: ") (${ VSub_Name r))} spids: [2631] ) ] spids: [2631] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:__ERROR) op: Equal rhs: {(SQ )} spids: [2640] ) ] spids: [2640] ) ] spids: [-1 2617] ) ] else_action: [(C {(_pr_str)} {(DQ (${ VSub_Number 1))} {(yes)})] spids: [2643 2657] ) ] spids: [2601] ) spids: [2596 2600] ) (Sentence child:(C {(ENV)}) terminator:) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:REPL_ENV) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [2668] ) ] spids: [2668] ) (FuncDef name: REP body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:r) op:Equal rhs:{(SQ )} spids:[2683])] spids: [2683] ) (C {(READ)} {(DQ (${ VSub_Number 1))}) (C {(EVAL)} {(DQ (${ VSub_Name r))} {(DQ (${ VSub_Name REPL_ENV))}) (C {(PRINT)} {(DQ (${ VSub_Name r))}) ] spids: [2680] ) spids: [2675 2679] ) (FuncDef name: _fref body: (BraceGroup children: [ (Sentence child: (C {(_symbol)} {(DQ (${ VSub_Number 1))}) terminator: ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:sym) op: Equal rhs: {(DQ (${ VSub_Name r))} spids: [2743] ) ] spids: [2741] ) (C {(_function)} { (DQ (${ VSub_Number 2) (" ") (EscapedLiteralPart token:) (EscapedLiteralPart token:) ("{@}") (EscapedLiteralPart token:) ) } ) (C {(ENV_SET)} {(DQ (${ VSub_Name REPL_ENV))} {(DQ (${ VSub_Name sym))} {(DQ (${ VSub_Name r))} ) ] spids: [2729] ) spids: [2724 2728] ) (ForEach iter_name: n iter_words: [ { (DQ (BracedVarSub token: prefix_op: VSub_Bang bracket_op: (WholeArray op_id:Lit_At) spids: [2794 2800] ) ) } ] do_arg_iter: False body: (DoGroup children: [ (Sentence child: (C {(_fref)} {(DQ (${ VSub_Name n))} { (DQ (BracedVarSub token: bracket_op: (ArrayIndex expr:(ArithWord w:{(DQ (${ VSub_Name n))})) spids: [2815 2824] ) ) } ) terminator: ) ] spids: [2804 2828] ) spids: [2792 2802] ) (FuncDef name: _eval body: (BraceGroup children: [ (Sentence child: (C {(EVAL)} {(DQ (${ VSub_Number 1))} {(DQ (${ VSub_Name REPL_ENV))}) terminator: ) ] spids: [2835] ) spids: [2830 2834] ) (C {(_fref)} {(DQ (eval))} {(_eval)}) (Sentence child:(C {(_list)}) terminator:) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:argv) op:Equal rhs:{(DQ (${ VSub_Name r))} spids:[2865])] spids: [2865] ) (ForEach iter_name: _arg iter_words: [ { (DQ (BracedVarSub token: suffix_op: (Slice begin:(ArithWord w:{(Lit_Digits 2)})) spids: [2879 2883] ) ) } ] do_arg_iter: False body: (DoGroup children: [ (Sentence child: (C {(_string)} {(DQ (${ VSub_Name _arg))}) terminator: ) (Sentence child: (C {(_conj) (KW_Bang "!")} {(DQ (${ VSub_Name argv))} {(DQ (${ VSub_Name r))}) terminator: ) ] spids: [2887 2914] ) spids: [2877 2885] ) (C {(_symbol)} {(DQ (__STAR__ARGV__STAR__))}) (Sentence child: (C {(ENV_SET)} {(DQ (${ VSub_Name REPL_ENV))} {(DQ (${ VSub_Name r))} {(DQ (${ VSub_Name argv))}) terminator: ) (C {(REP)} { (DQ ("(def! *host-language* ") (EscapedLiteralPart token:) (bash) (EscapedLiteralPart token:) (")") ) } ) (C {(REP)} {(DQ ("(def! not (fn* (a) (if a false true)))"))}) (C {(REP)} { (DQ ("(def! load-file (fn* (f) (eval (read-string (str ") (EscapedLiteralPart token:) ("(do ") (EscapedLiteralPart token:) (" (slurp f) ") (EscapedLiteralPart token:) (")") (EscapedLiteralPart token:) (")))))") ) } ) (C {(REP)} { (DQ ( "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw " ) (EscapedLiteralPart token:) ("odd number of forms to cond") (EscapedLiteralPart token:) (")) (cons 'cond (rest (rest xs)))))))") ) } ) (C {(REP)} {(DQ ("(def! *gensym-counter* (atom 0))"))}) (C {(REP)} { (DQ ("(def! gensym (fn* [] (symbol (str ") (EscapedLiteralPart token:) (G__) (EscapedLiteralPart token:) (" (swap! *gensym-counter* (fn* [x] (+ 1 x)))))))") ) } ) (C {(REP)} { (DQ ( "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) " ) (EscapedLiteralPart token:) ("(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))") ) } ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr:(WordTest w:{(DQ (${ VSub_Number 1))})) terminator: ) ] action: [ (C {(REP)} { (DQ ("(load-file ") (EscapedLiteralPart token:) (${ VSub_Number 1) (EscapedLiteralPart token:) (")") ) } ) (C {(exit)} {(0)}) ] spids: [-1 3028] ) ] spids: [-1 3048] ) (C {(REP)} { (DQ ("(println (str ") (EscapedLiteralPart token:) ("Mal [") (EscapedLiteralPart token:) (" *host-language* ") (EscapedLiteralPart token:) ("]") (EscapedLiteralPart token:) ("))") ) } ) (While cond: [(Sentence child:(C {(true)}) terminator:)] body: (DoGroup children: [ (AndOr children: [(C {(READLINE)} {(DQ ("user> "))}) (C {(exit)} {(DQ ($ VSub_QMark "$?"))})] op_id: Op_DPipe ) (AndOr children: [ (DBracket expr:(WordTest w:{(DQ (${ VSub_Name r))})) (AndOr children: [(C {(REP)} {(DQ (${ VSub_Name r))}) (C {(echo)} {(DQ (${ VSub_Name r))})] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [3074 3122] ) ) ] )