ref: 02b360fe6c10ef6ec280c44a7935df743e68e0de
dir: /macro.ml/
module T = Types.Types let rec expand ast env args sym meta = print_endline (" THIS IS A MACRO: " ^ Printer.print sym true); print_endline (" META: " ^ Printer.print meta true); print_endline (" ARGS: " ^ Printer.dump args); print_endline (" AST: " ^ Printer.print ast true); (* and expand args env sym meta = *) (* let sub_env = Env.make (Some env) in * Env.set * sub_env * (Types.symbol "_") * (Types.proc (function * | [ ast ] -> eval ast sub_env * | _ -> T.Nil)); *) match meta with | T.Map { T.value = m } -> (try let literals = Types.M9map.find Types.macro_literals m in let transformers = Types.M9map.find Types.macro_transformers m in print_endline ("--EVAL_MACRO: literals: " ^ Printer.print literals true ^ " transformers: " ^ Printer.print transformers true); let rec match_transform transforms = match transforms with | hd :: tl -> print_endline ("__ hd: " ^ Printer.print hd true); print_endline ("__ arg length: " ^ string_of_int (List.length args)); (match hd with | T.List { T.value = [ T.List { T.value = pattern }; T.List { T.value = body } ] } -> print_endline (" _ pattern: " ^ Printer.dump pattern); print_endline ("__ pattern length: " ^ string_of_int (List.length pattern) ^ " body: " ^ Printer.dump body) | T.List { T.value = [ T.List { T.value = pattern }; atom ] } -> print_endline (" _ pattern: " ^ Printer.dump pattern); print_endline ("__ atomic pattern length: " ^ string_of_int (List.length pattern) ^ " atom: " ^ Printer.print atom true) | _ -> ()); let foo = Reader.read (Printer.print hd false) in print_endline (" foo: " ^ Printer.print foo true); (* print_endline ("__ transform length: " ^ string_of_int (List.length foo)); *) match_transform tl | [] -> () in match_transform (Core.seq transformers) with | Not_found -> ()) | _ -> ()