ref: 6a277f5b5fd8b91b71aba6352118f004b1f4fc3a
parent: 02e52de48838943242250b85d2bf23c97755111f
author: smazga <smazga@greymanlabs.com>
date: Tue Aug 25 12:54:09 EDT 2020
macro
--- a/macro.ml
+++ b/macro.ml
@@ -29,40 +29,26 @@
match transforms with
| hd :: tl ->
print_endline ("__ hd: " ^ Printer.print hd true);
- print_endline ("__ arg length: " ^ string_of_int (List.length args));
print_endline ("__ args: " ^ Printer.dump args);
(match hd with
| T.List
{ T.value = [ T.List { T.value = pattern }; T.List { T.value = template } ] }
->
- print_endline (" _ pattern: " ^ Printer.dump pattern);
- print_endline
- ("__ pattern length: "
- ^ string_of_int (List.length pattern)
- ^ " template: "
- ^ Printer.dump template)
+ print_endline (" _ multi pattern: " ^ Printer.dump pattern)
| T.List { T.value = [ T.List { T.value = pattern }; atom ] } ->
- let rec wrangle p a pp =
- (match (p, a) with
- | sh :: st, ph :: pt ->
- print_endline (">>>>> sh:" ^ (Printer.print sh true) ^ " ph:" ^ (Printer.print ph true)); wrangle st pt pp
- | sh :: st, [] ->
- print_endline (">>>>> sh:" ^ (Printer.print sh true));
- let ss = Printer.print sh true in
- let x = if ss = "_" then sym else (if List.mem sh (Core.seq literals) then sh else (T.String "")) in
- wrangle st args []
- | _, _ -> "<end>") in
- print_endline ("wrangle: " ^ wrangle pattern (Core.seq args) []);
- print_endline (" _ pattern: " ^ Printer.dump pattern);
- print_endline
- ("__ atomic pattern length: "
- ^ string_of_int (List.length pattern)
- ^ " atom: "
- ^ Printer.print atom true)
+ let rec foobar p a pp =
+ (match p, a with
+ | ph :: pt, ah :: at ->
+ print_endline "one"; foobar pt at (pp @ [T.Nil])
+ | ph :: pt, [] ->
+ print_endline "two"; foobar pt [] (pp @ [T.Nil])
+ | _, _ -> print_endline ("three: " ^ Printer.dump pp); pp) in
+ print_endline ("foobar: " ^ Printer.dump (foobar pattern args []));
+ print_endline "out";
+ (* let tweaked = Str.global_replace (Str.regexp "^_") (Printer.print sym true) (Printer.dump pattern) in
+ * print_endline ("tweaked: " ^ tweaked); *)
+ print_endline (" _ single pattern: " ^ Printer.dump pattern)
| _ -> ());
- 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